【发布时间】:2020-09-12 11:59:20
【问题描述】:
我正在制作一个不和谐的机器人,我希望它在加入频道时播放随机的 mp3 文件。
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;
当我在聊天中键入 $join 时,它会加入我所在的语音频道,但不播放任何内容。
【问题讨论】:
-
遇到任何错误?
-
不,它不会给出任何错误...
标签: javascript node.js random discord.js fs