2020-12-06 07:28:01 +00:00
|
|
|
import {
|
|
|
|
CommandClient,
|
|
|
|
event,
|
|
|
|
Intents,
|
|
|
|
command,
|
|
|
|
CommandContext,
|
2020-12-08 06:43:06 +00:00
|
|
|
Extension,
|
|
|
|
CommandBuilder
|
2021-04-04 05:52:47 +00:00
|
|
|
} from '../mod.ts'
|
2020-12-06 07:28:01 +00:00
|
|
|
import { TOKEN } from './config.ts'
|
|
|
|
|
|
|
|
class MyClient extends CommandClient {
|
|
|
|
constructor() {
|
|
|
|
super({
|
2020-12-08 07:05:34 +00:00
|
|
|
prefix: ['!', '!!'],
|
2020-12-06 07:28:01 +00:00
|
|
|
caseSensitive: false
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
@event()
|
|
|
|
ready(): void {
|
|
|
|
console.log(`Logged in as ${this.user?.tag}!`)
|
|
|
|
}
|
|
|
|
|
2020-12-08 06:43:06 +00:00
|
|
|
@command({ aliases: 'pong' })
|
2020-12-06 07:28:01 +00:00
|
|
|
Ping(ctx: CommandContext): void {
|
|
|
|
ctx.message.reply('Pong!')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class VCExtension extends Extension {
|
2020-12-08 06:43:06 +00:00
|
|
|
name = 'VC'
|
|
|
|
subPrefix = 'vc'
|
|
|
|
|
2020-12-06 07:28:01 +00:00
|
|
|
@command()
|
|
|
|
async join(ctx: CommandContext): Promise<void> {
|
|
|
|
const userVS = await ctx.guild?.voiceStates.get(ctx.author.id)
|
|
|
|
if (userVS === undefined) {
|
|
|
|
ctx.message.reply("You're not in VC.")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
await userVS.channel?.join()
|
|
|
|
ctx.message.reply(`Joined VC channel - ${userVS.channel?.name}!`)
|
|
|
|
}
|
|
|
|
|
|
|
|
@command()
|
|
|
|
async leave(ctx: CommandContext): Promise<void> {
|
|
|
|
const userVS = await ctx.guild?.voiceStates.get(
|
|
|
|
(ctx.client.user?.id as unknown) as string
|
|
|
|
)
|
|
|
|
if (userVS === undefined) {
|
|
|
|
ctx.message.reply("I'm not in VC.")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
userVS.channel?.leave()
|
|
|
|
ctx.message.reply(`Left VC channel - ${userVS.channel?.name}!`)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const client = new MyClient()
|
|
|
|
|
|
|
|
client.extensions.load(VCExtension)
|
|
|
|
|
2020-12-08 06:43:06 +00:00
|
|
|
client.commands.add(
|
|
|
|
new CommandBuilder()
|
|
|
|
.setName('join')
|
|
|
|
.onExecute((ctx) => ctx.message.reply('haha'))
|
|
|
|
)
|
|
|
|
|
2020-12-06 07:28:01 +00:00
|
|
|
client.connect(TOKEN, Intents.All)
|