fix
This commit is contained in:
parent
7570dfffbe
commit
90e4bd6ccf
7 changed files with 173 additions and 76 deletions
26
test/vc.ts
Normal file
26
test/vc.ts
Normal file
|
@ -0,0 +1,26 @@
|
|||
import * as discord from '../mod.ts'
|
||||
import { TOKEN } from './config.ts'
|
||||
|
||||
const client = new discord.Client({
|
||||
token: TOKEN,
|
||||
intents: ['GUILDS', 'GUILD_VOICE_STATES', 'GUILD_MESSAGES']
|
||||
})
|
||||
|
||||
client.on('messageCreate', async (msg) => {
|
||||
if (msg.author.bot === true || msg.guild === undefined) return
|
||||
|
||||
if (msg.content === '!join') {
|
||||
const vs = await msg.guild.voiceStates.get(msg.author.id)
|
||||
if (vs === undefined) return msg.reply("You're not in Voice Channel!")
|
||||
const data = await vs.channel!.join()
|
||||
console.log(data)
|
||||
msg.reply('Joined voice channel.')
|
||||
} else if (msg.content === '!leave') {
|
||||
const vs = await msg.guild.voiceStates.get(msg.client.user!.id!)
|
||||
if (vs === undefined) return msg.reply("I'm not in Voice Channel!")
|
||||
await vs.channel!.leave()
|
||||
msg.reply('Left voice channel.')
|
||||
}
|
||||
})
|
||||
|
||||
client.connect().then(() => console.log('Ready!'))
|
Loading…
Add table
Add a link
Reference in a new issue