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 Feb 13, 2022. It is now read-only.
I found that it is possible to run two instances of the bot with different tokens one for joining and leaving.
This enables the bot to join any channel and not just a set voice channel like "General".
Sample code for anyone that wants to use this: (These two can be in the same dir as index.js and should be run at the same time.)
// Join.jsrequire('dotenv').config()constDiscord=require('discord.js');constclient=newDiscord.Client();client.on('ready',()=>{console.log(`Logged in as ${client.user.tag}!`);});client.on('voiceStateUpdate',async(oldState,newState)=>{if(oldState.channel!==newState.channel){if(newState.channel&&!oldState.member.user.bot){//const havingAGoodTime = Math.random() <= 0.05;//const file = havingAGoodTime ? './sounds/connected-but-its-loud-af.mp3' : './sounds/connected.wav';//play(newState.channel, file);play(newState.channel,'./sounds/connected.wav');console.log(`Joined ${newState.channel.name} for ${newState.member.user.tag} joining.`);}}if(oldState.selfDeaf&&!newState.selfDeaf){play(oldState.channel,'./sounds/talkpower_granted.wav');console.log(`Joined ${oldState.channel.name} for ${oldState.member.user.tag} Undeafen.`);}})client.login(process.env.DISCORD_BOT_TOKEN);asyncfunctionplay(channel,file){constconnection=awaitchannel.join();connection.play(file);}
and
//Leave.jsrequire('dotenv').config()constDiscord=require('discord.js');constclient=newDiscord.Client();client.on('ready',()=>{console.log(`Logged in as ${client.user.tag}!`);});client.on('voiceStateUpdate',async(oldState,newState)=>{if(oldState.channel!==newState.channel){if(oldState.channel&&!oldState.member.user.bot){play(oldState.channel,'./sounds/disconnected.wav');console.log(`Joined ${oldState.channel.name} for ${oldState.member.user.tag} leaving.`);}}})client.login("SECOND BOT TOKEN");asyncfunctionplay(channel,file){constconnection=awaitchannel.join();connection.play(file);}
For example; when you leave General1 to join General2, The first bot will go to General2 and the second bot will go to General1 at the same time.
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I found that it is possible to run two instances of the bot with different tokens one for joining and leaving.
This enables the bot to join any channel and not just a set voice channel like "General".
Sample code for anyone that wants to use this: (These two can be in the same dir as index.js and should be run at the same time.)
and
For example; when you leave General1 to join General2, The first bot will go to General2 and the second bot will go to General1 at the same time.
The text was updated successfully, but these errors were encountered: