remove slashModule decorator
This commit is contained in:
parent
33f103279d
commit
b112b6ae36
3 changed files with 11 additions and 37 deletions
|
@ -134,7 +134,6 @@ export class Client extends EventEmitter {
|
||||||
handler: (interaction: Interaction) => any
|
handler: (interaction: Interaction) => any
|
||||||
}>
|
}>
|
||||||
|
|
||||||
_decoratedSlashModules?: string[]
|
|
||||||
_id?: string
|
_id?: string
|
||||||
|
|
||||||
/** Shard on which this Client is */
|
/** Shard on which this Client is */
|
||||||
|
@ -362,12 +361,3 @@ export function groupslash(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Decorator to add a Slash Module to Client */
|
|
||||||
export function slashModule() {
|
|
||||||
return function (client: Client | SlashClient, prop: string) {
|
|
||||||
if (client._decoratedSlashModules === undefined)
|
|
||||||
client._decoratedSlashModules = []
|
|
||||||
client._decoratedSlashModules.push(prop)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -353,8 +353,6 @@ export class SlashClient {
|
||||||
handler: (interaction: Interaction) => any
|
handler: (interaction: Interaction) => any
|
||||||
}>
|
}>
|
||||||
|
|
||||||
_decoratedSlashModules?: string[]
|
|
||||||
|
|
||||||
constructor(options: SlashOptions) {
|
constructor(options: SlashOptions) {
|
||||||
let id = options.id
|
let id = options.id
|
||||||
if (options.token !== undefined) id = atob(options.token?.split('.')[0])
|
if (options.token !== undefined) id = atob(options.token?.split('.')[0])
|
||||||
|
@ -376,36 +374,12 @@ export class SlashClient {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.client?._decoratedSlashModules !== undefined) {
|
|
||||||
this.client._decoratedSlashModules.forEach((e) => {
|
|
||||||
const mod = ((this.client as unknown) as {
|
|
||||||
[name: string]: SlashModule
|
|
||||||
})[e]
|
|
||||||
if (!(mod instanceof SlashModule))
|
|
||||||
throw new Error(
|
|
||||||
'@slashModule can only be used on SlashModule instances'
|
|
||||||
)
|
|
||||||
this.modules.push(mod)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this._decoratedSlash !== undefined) {
|
if (this._decoratedSlash !== undefined) {
|
||||||
this._decoratedSlash.forEach((e) => {
|
this._decoratedSlash.forEach((e) => {
|
||||||
this.handlers.push(e)
|
this.handlers.push(e)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._decoratedSlashModules !== undefined) {
|
|
||||||
this._decoratedSlashModules.forEach((e) => {
|
|
||||||
const mod = ((this as unknown) as { [name: string]: SlashModule })[e]
|
|
||||||
if (!(mod instanceof SlashModule))
|
|
||||||
throw new Error(
|
|
||||||
'@slashModule can only be used on SlashModule instances'
|
|
||||||
)
|
|
||||||
this.modules.push(mod)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
this.rest =
|
this.rest =
|
||||||
options.client === undefined
|
options.client === undefined
|
||||||
? options.rest === undefined
|
? options.rest === undefined
|
||||||
|
|
|
@ -1,8 +1,18 @@
|
||||||
import { SlashClient } from '../models/slashClient.ts'
|
import { SlashClient } from '../models/slashClient.ts'
|
||||||
import { SlashCommandPartial } from '../types/slash.ts'
|
import { SlashCommandPartial } from '../types/slash.ts'
|
||||||
import { TOKEN } from './config.ts'
|
import { TOKEN } from './config.ts'
|
||||||
|
import { SlashModule, slashModule } from '../../mod.ts'
|
||||||
|
|
||||||
export const slash = new SlashClient({ token: TOKEN })
|
class MyMod extends SlashModule {}
|
||||||
|
|
||||||
|
class MySlashClient extends SlashClient {
|
||||||
|
@slashModule()
|
||||||
|
mod = new MyMod()
|
||||||
|
}
|
||||||
|
|
||||||
|
export const slash = new MySlashClient({ token: TOKEN })
|
||||||
|
|
||||||
|
console.log(slash.modules)
|
||||||
|
|
||||||
// Cmd objects come here
|
// Cmd objects come here
|
||||||
const commands: SlashCommandPartial[] = []
|
const commands: SlashCommandPartial[] = []
|
||||||
|
|
Loading…
Reference in a new issue