pawel02 / music_bot

Music discord bot with all the functionality you'll ever want

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

using in multiple servers

oktayozkan0 opened this issue · comments

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.

commented

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

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