fix slash modules

This commit is contained in:
DjDeveloperr 2020-12-23 15:26:02 +05:30
parent 94a447921d
commit 015b7951d8
2 changed files with 15 additions and 3 deletions

View File

@ -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
} }

View File

@ -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)