0
こんにちは私は、ボイスチャンネルのディスディスでポッドキャストとストリームを再生するボットに取り組んでいます。ボットが音声チャンネルになく、メンバーがコマンドを使用しているときに小さな問題にぶつかってきました!stopstreamメッセージ "Stop Streaming"を出すべきですが、 "Stopped!Tuning in Thanks in tuning"ボットを音声チャネルから離れるようにする!stopstreamコマンドを使用してストリームを停止した場合にのみ出力する必要があります。ここで メッセージ出力に関する問題
は、私は、コード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.`);
}
}
でそれを使用していますどのように私は
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.`);
相続人で働いているスニペットです私はここで何か間違っているようだ、あなたの助けに感謝します。
はまだ運がありません!チューニングをお寄せいただきありがとうございます:wave: "else if(client.leaveVoiceChannel == null) return message.channel.createMessage(':感嘆符:No Stream Playing.'); 'それは動作しますが、botそれは明らかに "停止!チューニングのおかげで:波:"これは私がそれをしたい、ではありませんが、返信いただきありがとうございます。 – John
あなたが上記のコメントの中で 'else if(client.leaveVoiceChannel == null)'と言ったようなものか、元の質問と私の応答のように 'else if(client.leaveVoiceChanne == null) ?タイプミスの場合、 'client.leaveVoiceChanne'は未定義になり、nullに等しくなります。 – met4000