You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 25, 2020. It is now read-only.
So, I tried to do like here in my code. It worked, but now bot tries to leave from voice channel twice.
And not only twice! When I repeat '8-request' message for several times It just starts to spam my console with errors:
So here is the code (It's not full):
varlogger=require('winston');varservers={};functionplay(channelID,message){varserver=servers[bot.channels[channelID].guild_id];varvoiceChannelID=bot.servers[bot.channels[channelID].guild_id].members[bot.id].voice_channel_id;if(server.isPlaying!=1)server.isPlaying=1;bot.getAudioContext(voiceChannelID,function(error,stream){if(error)returnconsole.error(error);fs.createReadStream("myFile.mp3"/*ytdl(server.queue[0], { filter: "audioonly" })*/).pipe(stream,{end: false});server.queue.shift();logger.info("В очереди теперь "+server.queue.length+" песни(ен)");stream.on('done',function(){if(server.queue[0]){logger.warn("play() calls itself")play(channelID,message);}elseif(!server.queue[0]){logger.warn("play() ended it's work")server.isPlaying=0;bot.leaveVoiceChannel(voiceChannelID,function(error,stream){if(error)returnconsole.error(error);});}});});}bot.on('message',function(user,userID,channelID,message,evt){varargs=message.substring(2).split(' ');switch(args[0]){//8-requestcase'request':
if(!args[1]){bot.sendMessage({to: channelID,message: 'Уважаемий, '+user+', сначала выбери что тебе душа изволит.'});break;}If(!bot.servers[bot.channels[channelID].guild_id].members[bot.id].voice_channel_id){bot.sendMessage({to: channelID,message: 'Все бы хорошо... Да только я не в голосовом чате :grimacing:'});break;}if(!servers[bot.channels[channelID].guild_id])servers[bot.channels[channelID].guild_id]={queue: [],isPlaying: []}varserver=servers[bot.channels[channelID].guild_id];if(server.isPlaying==1){server.queue.push(args[1]);logger.info("В очереди теперь "+server.queue.length+" песни(ен)");}else{server.queue.push(args[1]);logger.info("В очереди теперь "+server.queue.length+" песни(ен)");play(channelID,message);}break;}}
P.S. Feel free to ask me to post any part of my full code
P.P.S I am sorry if my English is not good.
The text was updated successfully, but these errors were encountered:
@PatiHox You do know breakpoints exist, right? That's much better than manual console logging.
I'm not currently fluent in this library, but it looks like calling play for each item yields unnecessary performance degradation by pulling the file twice using the createReadStream function.
I also cleaned up your code a bit, and fixed a syntax error. Did you copy it wrongly? Here it is.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
So, I tried to do like here in my code. It worked, but now bot tries to leave from voice channel twice.
And not only twice! When I repeat '8-request' message for several times It just starts to spam my console with errors:
So here is the code (It's not full):
P.S. Feel free to ask me to post any part of my full code
P.P.S I am sorry if my English is not good.
The text was updated successfully, but these errors were encountered: