MrDagron / NamazuKingdomBot

0 stars 1 forks source link

Cannot connect and run on two guilds #14

Closed MrDagron closed 2 years ago

MrDagron commented 2 years ago

The bot cannot join two separate voice channels in different guilds.

If the bot is in a voice channel on one server and then a user types in a completely different server it will play the text from the different server on the original server. Most likely just need to do an if statement checking to see if the command was executing from the same server it is in vc with.

Will write more info on this later

MrDagron commented 2 years ago

Most likely caused by AudioServices being a singleton in the DL. I am almost certain that it is caused by the audioOutStream being replaced by a new PCM stream from the most recent server it joined. Will look into ways around it.

Maybe have a KeyValue list of guilds, audioOutStreams? Maybe there is a different DI option I could choose? Will research more later

Edit: Yeah seems best bet is a data structure to hold each guild. I do see a lot of performance issues down the line especially if the bot is in several hundred servers; however I do not foresee myself hosting this bot personally in several hundred servers since Discord will soon require those bots to become verified and then we wouldn't be able to use the text parsing functionality. (Maybe we could? I think there is a separate verification process to gain the ability to allow text commands to stay?)

MrDagron commented 2 years ago

Basic work for this done in latest commit.

Made a new class in AudioService.cs called GuildAudioService. In Program.cs I added a list of GuildAudioService as a singleton. AudioService handles adding and removing the guild from the list.