I'm making a discord bot, and I want it to play a random mp3 file when it joins channel.
case"join":
message.delete( {timeout: 5000})
const voiceChannel = message.member.voice.channel
if(voiceChannel) {
const connection = await voiceChannel.join()
const files = fs.readdirSync("./sounds/")
const randFile = files[Math.floor(Math.random() * files.length)]
const dispatcher = connection.play(randFile)
} else {
message.reply("you need to be in a voice channel!").then(message => message.delete( {timeout: 5000}))
}
break;
When I type $join in chat, it joins voice channel that I'm in but doesn't play anything.
Aucun commentaire:
Enregistrer un commentaire