Discord Bot语音播放器不会根据要求停止。帮助您将不胜感激
我环顾四周,但没有骰子。机器人启动并拉出所需的缩略图,但在发出停止命令时无法停止:
client.on('messageCreate', async (message) => {
if (message.content && message.content.toLowerCase() === 'play baka radio') {
if (!message.member.voice?.channel) return message.channel.send('You need to be a voice channel to execute this command')
const connection = joinVoiceChannel({
channelId: message.member.voice.channelId,
guildId: message.guildId,
adapterCreator: message.guild.voiceAdapterCreator
})
const player = createAudioPlayer()
const resource = createAudioResource('https://nrf1.newradio.it:10328/alfaanime')
connection.subscribe(player)
message.channel.send({ content: "Now Playing", embeds: [embed2], files: ['./logo/bkrlogo.png'] }) + player.play(resource)
if (message.content && message.content.toLowerCase() === 'stop')
player.stop(resource)
}
i have looked around for an answer but no dice. bot starts and pulls the required thumbnail but fails to stop when the stop command is issued:
client.on('messageCreate', async (message) => {
if (message.content && message.content.toLowerCase() === 'play baka radio') {
if (!message.member.voice?.channel) return message.channel.send('You need to be a voice channel to execute this command')
const connection = joinVoiceChannel({
channelId: message.member.voice.channelId,
guildId: message.guildId,
adapterCreator: message.guild.voiceAdapterCreator
})
const player = createAudioPlayer()
const resource = createAudioResource('https://nrf1.newradio.it:10328/alfaanime')
connection.subscribe(player)
message.channel.send({ content: "Now Playing", embeds: [embed2], files: ['./logo/bkrlogo.png'] }) + player.play(resource)
if (message.content && message.content.toLowerCase() === 'stop')
player.stop(resource)
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将不得不阅读以下内容: httpps:// https://discordjs.guide/popularjs.guide/popular-topics /collectors.html#await-messages 在使用Discord机器人时,它非常有用
。 filter
filter
,当某人发送“停止”时,触发了函数,并且播放器立即停止在这里,我只能调用我的函数createplayer,
您可以选择在等待中设置时间
You will have to read this : https://discordjs.guide/popular-topics/collectors.html#await-messages its very usefull while working with discord bots
Here I ask my bot to watch the origin message (
play baka radio
) channel for a message who fit to my filterfilter
, when someone send "stop", the function is triggered and the player is instantly stoppedHere I just call my function createPlayer
You can choose to set time in the awaitMessages, or not