您好我正在制作一个在语音频道中播放Discord播客和流媒体的机器人。当机器人不在语音通道中并且成员使用命令时,我遇到了一个小问题!停止它应该输出消息" No Stream Playing"但它继续输出消息"停止!感谢您在"这应该仅在使用!stopstream命令停止流时输出,该命令使机器人离开语音通道。
以下是我使用
的代码段
client.leaveVoiceChannel(message.member.voiceState.channelID);
message.channel.createMessage(`:stop_button: Stopped! Thanks for tuning in :wave:`);
if(client.leaveVoiceChanne == null)
return message.channel.createMessage(`:exclamation: No Stream Playing.`);

Heres是我在代码
中使用它的方式
if (command == 'stopstream') {
if (!message.member.voiceState.channelID)
return message.channel.createMessage(`:exclamation: You have to join the voice channel to stop the stream.`);
client.leaveVoiceChannel(message.member.voiceState.channelID);
message.channel.createMessage(`:stop_button: Stopped! Thanks for tuning in :wave:`);
if (client.leaveVoiceChanne == null)
return message.channel.createMessage(`:exclamation: No Stream Playing.`);
}
if (command == 'streams') {
message.channel.createMessage(stations);
} else if (command == 'radio') {
if (args == '')
return message.channel.createMessage(`:exclamation: Please specify the radio stream example: **!radio <stream>** or use command **!streams** to see list. Use **!streamhelp** to show commands list.`);
if (require('./stations.json')[args]) {
if (!message.member.voiceState.channelID)
return message.channel.createMessage(`:exclamation: You need to be in a voice channel to play that stream.`);
client.joinVoiceChannel(message.member.voiceState.channelID).then(vc => {
if (vc.playing) vc.stopPlaying();
message.channel.createMessage(`:radio: You are listening to **${args}**. To change the stream use **!radio <stream>**`);
vc.play(require('./stations.json')[args]);
})
} else {
return message.channel.createMessage(`:frowning2: I cannot find a radio stream with that name. Make sure it has capitals and the correct spelling. Type **!streams** to see stream list.`);
}
}
&#13;
似乎我在这里做错了,你的帮助将不胜感激。
答案 0 :(得分:0)
您正在发送&#34;流已停止&#34;检查流是否正在播放之前的消息。在此之前移动支票:
private void timerWorkStep_Tick(object sender, EventArgs e)
{
try
{
// Retreive Some value from web proxy and set to label
}
catch (Exception ex)
{
timerWorkStep.Stop();
MessageBoxHelper.ShowException(LanguagePack.LanguageHelper.GetString(GlobalParameters.Language, "Error_ExecutionEx"), ex);
}
finally
{
timerWorkStep.Start();
}
}
&#13;