Makar8000 / ACT-Discord-Triggers

An ACT plugin for routing audio to discord
50 stars 14 forks source link

Potential Login Fix #40

Closed megaoka closed 5 years ago

megaoka commented 5 years ago

https://github.com/Makar8000/ACT-Discord-Triggers/blob/f665c2824939f3502a1a4a7d934ede49e5681409/ACT_DiscordTriggers/DiscordAPI/DiscordClient.cs#L37

I think there is an issue where line 37 and 38 aren't being waited upon and getting skipped causing login issues. I also think it is not catching the exceptions and not throwing an error.

Here are the edits I have made to my method:

        public static async void InIt(string logintoken) {
            try {
                bot = new DiscordSocketClient(new DiscordSocketConfig {
                    WebSocketProvider = WS4NetProvider.Instance
                });
            } catch (NotSupportedException) { Log("Unsupported Operating System."); }

            try {
                bot.MessageReceived -= MessageReceived
                bot.MessageReceived += MessageReceived; //messaging support
                bot.Ready -= Bot_Ready; //just in case
                bot.Ready += Bot_Ready;
                await bot.LoginAsync(TokenType.Bot, logintoken);
                await bot.StartAsync();
            } catch (Exception ex) { Log(ex.Message); }
        }

However I had to butcher the button click method:

        private void discordConnectbtn_Click(object sender, EventArgs e) {

            DiscordClient.InIt(txtToken.Text);
                Log("Connected to Discord.");
        }

I'm not knowledgeable enough to fix this part and it will need to be fixed. However, after making it awaiting those two bot commands it has helped with login problems.

megaoka commented 5 years ago

Also: Unticking and then re-ticking the plugin in the plugin listing will do a couple things.. either it will throw an error about TextBox() or the server and channel lists won't show up. Basically it doesn't work at all. You have to close ACT to safely reset the plugin.

Makar8000 commented 5 years ago

Fixed! Thank you for your contribution! 🥇