fix slash modules
This commit is contained in:
parent
94a447921d
commit
015b7951d8
2 changed files with 15 additions and 3 deletions
|
@ -418,10 +418,22 @@ export class SlashClient {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadModule(module: SlashModule): SlashClient {
|
||||||
|
this.modules.push(module)
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
getHandlers(): SlashCommandHandler[] {
|
getHandlers(): SlashCommandHandler[] {
|
||||||
let res = this.handlers
|
let res = this.handlers
|
||||||
for (const mod of this.modules) {
|
for (const mod of this.modules) {
|
||||||
res = [...res, ...mod.commands]
|
if (mod === undefined) continue
|
||||||
|
res = [
|
||||||
|
...res,
|
||||||
|
...mod.commands.map((cmd) => {
|
||||||
|
cmd.handler = cmd.handler.bind(mod)
|
||||||
|
return cmd
|
||||||
|
})
|
||||||
|
]
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,9 +218,9 @@ class VCExtension extends Extension {
|
||||||
const client = new MyClient()
|
const client = new MyClient()
|
||||||
|
|
||||||
client.on('raw', (e, d) => {
|
client.on('raw', (e, d) => {
|
||||||
if (e === 'READY') console.log(d)
|
if (e === 'GUILD_MEMBER_ADD' || e === 'GUILD_MEMBER_UPDATE') console.log(e, d)
|
||||||
})
|
})
|
||||||
|
|
||||||
client.extensions.load(VCExtension)
|
client.extensions.load(VCExtension)
|
||||||
|
|
||||||
client.connect(TOKEN, Intents.None)
|
client.connect(TOKEN, Intents.All)
|
||||||
|
|
Loading…
Reference in a new issue