pawel02 / music_bot

Music discord bot with all the functionality you'll ever want
66 stars 91 forks source link

using in multiple servers #13

Open oktayozkan0 opened 1 year ago

oktayozkan0 commented 1 year ago

how can i use this bot in multiple channels with different servers? bot cant join different voice channels when connect to a voice channel and play music.

jeremycanlas commented 1 year ago

Hi not sure if you still need it but what worked for me is changing self.music_queue into a dictionary with ctx.guild.id as the key and the rest as the value just so that the music queue isn't all in one list. I had an issue where server#2's music also plays in server#1's music as well. Also change any reference of self.music_queue to self.music_queue[ctx.guild.id].

Another thing I changed was in the cogs specifically: in the async def play_music(self, ctx): function

I changed the line from if self.vc == None or not self.vc.is_connected():

to

voice_client = nextcord.utils.get(self.bot.voice_clients, guild=ctx.guild)
if self.vc == None or not voice_client:

I use nextcord but discord.py should work.

I might be wrong but seems like self.vc.is_connected() checks if your bot connected to any voice channel at all servers it is in so changing that should allow your bot to join different voice channels in different servers

oktayozkan0 commented 1 year ago

thank you so much, yes i still need it. i will try.