63 lines
1.3 KiB
TypeScript
63 lines
1.3 KiB
TypeScript
|
import {
|
||
|
CommandClient,
|
||
|
event,
|
||
|
Intents,
|
||
|
command,
|
||
|
CommandContext,
|
||
|
Extension
|
||
|
} from '../../mod.ts'
|
||
|
import { TOKEN } from './config.ts'
|
||
|
|
||
|
class MyClient extends CommandClient {
|
||
|
constructor() {
|
||
|
super({
|
||
|
prefix: '!',
|
||
|
caseSensitive: false
|
||
|
})
|
||
|
}
|
||
|
|
||
|
@event()
|
||
|
ready(): void {
|
||
|
console.log(`Logged in as ${this.user?.tag}!`)
|
||
|
}
|
||
|
|
||
|
@command({
|
||
|
aliases: 'pong'
|
||
|
})
|
||
|
Ping(ctx: CommandContext): void {
|
||
|
ctx.message.reply('Pong!')
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class VCExtension extends Extension {
|
||
|
@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)
|
||
|
|
||
|
client.connect(TOKEN, Intents.All)
|