Makar8000 / ACT-Discord-Triggers

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

Bot unable to join channel #48

Closed jonrozen closed 5 years ago

jonrozen commented 5 years ago

[Audio #2] Connecting [Audio #2] Disconnecting Error joining channel. [Audio #2] Disconnected A task was canceled. Unable to join channel. Does your bot have permission to join this channel?

Is what is shown. Attempted to reinstall ACT, did not fix. Issue persistent over 2-3 days now. Bot has administrator permissions, so it should have no permission issues for joining the channel.

jonrozen commented 5 years ago

I dropped to the previous version and now the plugin works.

Webberjo commented 5 years ago

Can confirm, overwriting OverlayPlugin's Newtonsoft.Json.dll file with the one in ACT_DiscordTriggers-1.0.1.1 release and using ACT_DiscordTriggers v1.0.1.0 works.

Makar8000 commented 5 years ago

Does 1.0.1.1 work for you if you disable overlayplugin completely then restart ACT?

Webberjo commented 5 years ago

With OverlayPlugin v0.3.4.0 disabled and ACT_DiscordTriggers v1.0.1.1 enabled on ACT startup, attempting to connect my bot to a server has it connect and then immediately disconnect. The debug log shows:

[Discord] Discord.Net v2.1.0 (API v6)
[Gateway] Connecting
[Gateway] Connected
Bot in ready state. Populating servers...
Found X discord server(s).
Found X available voice channel(s) for DISCORD SERVER
[Gateway] Ready
[Audio #1] Connecting
[Audio #1] Disconnecting
Error joining channel.
[Audio #1] Disconnected
A task was canceled.
Unable to join channel. Does your bot have permission to join this channel?
Found X discord server(s).
Found X available voice channel(s) for DISCORD SERVER
linoth commented 5 years ago

Experienced this issue (Discord Plugin 1.0.1.1, Windows 10 Build 1903) with OverlayPlugin and Triggernometry disabled.

Attempted the Newtonsoft.Json.dll downgrade.

Now when attempting to connect to Discord, I receive:

Error connecting to Discord. Error converting value {null} to type 'Discord.Optional`1[System.String]'. Path 'email', line 1, position 219. Error connecting to Discord.

Providing this info in hopes that it might assist in locating the cause. If I'm wrong, apologies, and disregard.

Makar8000 commented 5 years ago

linoth, thanks for checking that. I can confirm that specific error happens if you are using an old version of Newtonsoft.Json, so it makes since for it to appear if you manually use an older version.

For the original issue, I will have to look into it. I know it has to do with ACT having versions of the dependencies loaded in the AppDomain that are not compatible with the Discord API I'm using, but I'm not exactly sure how to solve it yet. Even if I force load mine (like we do with Newtonsoft.Json) it may cause issues with ACT or other plugins.

I-Am-Buggy commented 5 years ago

Is there any other fix for this by chance? I'm seeing the same thing and have copied over the latest Newtonsoft from the zip file. The bot will join and immediately disconnect with the same error message Webberjo posted above. Downgrading fixes the problem, but replacing all other Newtonsoft instances I can find on my computer does not resolve the issue using the current version.

megaoka commented 5 years ago

@linoth I resolved this by overwriting the DLL files with the ones included in 1.0.1.1

However, I also am having trouble connecting to channels with this version.

megaoka commented 5 years ago

I have localized the issue to this line: audioClient = await chan.ConnectAsync(); #130

The failure is here, but I'm not sure why.

https://github.com/discord-net/Discord.Net/commit/fc48c6606d293f1cd9d9a7df10f747e1e9fc93de ? Similar issue: https://github.com/discord-net/Discord.Net/issues/1343

I'm just going to revert back to 1.0.1.0 but hope this helps.

Moonbase2004 commented 5 years ago

I'm not even using this plugin. This is with Discord.NET.

Someone suggested just using .NET Core which i'm gonna do.

megaoka commented 5 years ago

@Moonbase2004 Hi. I was using your issue as reference, not the other way around. Apologies for the confusion but it was not meant for you. Thank you for the suggestion, however.

Moonbase2004 commented 5 years ago

Well I just discovered that .NET Core fixed nothing. Back to the drawing board.

Moonbase2004 commented 5 years ago

Problem Solved: It's a bug with WS4NET.

Makar8000 commented 5 years ago

I believe we can remove WS4NET if we swap to .NET Core. I was planning on doing this once .NET 5 releases so that I can use the same .NET for both the plugin and the Discord API.

From what I remember, WS4NET is only needed for Windows 7 support. This was the case a year or two ago, but maybe now most users have upgraded already and it is safe to remove that support.

megaoka commented 5 years ago

Wouldn't be a bad idea. Since 1.0.1.0 works for the most part, it can serve as a legacy release for people still running Win 7 and earlier.

Makar8000 commented 5 years ago

I have hopefully fixed this issue with the latest release. Please give it a try.

Also, thanks to a new feature in ACT, you can change the load order of the plugins. By making sure the discord plugin loads first (at the top), we can avoid the conflicts caused by OverlayPlugin and replacing files is not needed.

Make sure to delete the old discord plugin folder too. With the removal of WS4Net, many of the old .dll files in the release are not longer necessary.

I-Am-Buggy commented 5 years ago

This new update appears to have solved the problem for me. This is the first release it has worked. Thanks for your help and hard work!

Makar8000 commented 5 years ago

Sweet. I will close this issue then. Feel free to open again if this issue comes up again.

lucagiacometti19 commented 5 years ago

[Command("join", RunMode = RunMode.Async)] [Summary("Connects the bot to the voice channel")] public async Task JoinVoiceChannelAsync(IVoiceChannel channel = null) { channel = channel ?? (Context.User as IGuildUser)?.VoiceChannel; if (channel == null) { await Context.Channel.SendMessageAsync("User must be in a voice channel, or a voice channel must be specified"); } else { var audioClient = await channel.ConnectAsync(); } }

This command is still throwing error and I can't find a way to make if work. The bot joins the voice channel and then it immediately leaves. As before, the error is thrown at this line: var audioClient = await channel.ConnectAsync();. The error says "the task has been canceled" -> System.Threading.Tasks.TaskCanceledException in mscorlib.dll. I've seeked help in Discord API, but none is taking me seriously or none knows how to solve this problem... . Uh and yes, I have the right binaries in the right folder (since I'm working with .NET framework it shoud be bin/debug, correct me if I'm wrong) and as you can see from the block of code above, the command is marked with RunMode.Async.

Webberjo commented 5 years ago

What OS are you using?

lucagiacometti19 commented 5 years ago

Windows 7, I'm in fact using WS4NetProvider as WebSocketProvider for the client.

Webberjo commented 5 years ago

What version of the plugin are you using?

lucagiacometti19 commented 5 years ago

By plugin I suppose you're talking about the Discord.Net package. If that's the case, I'm using v2.1.1. Thanks for your patience!

Webberjo commented 5 years ago

I meant what version of the ACT_DiscordTriggers.dll plugin are you using?

lucagiacometti19 commented 5 years ago

Sorry for my inexperience, It's just my first day working with this project. In the discord documentation I don't see anything about plugins... are they needed to just sustain a connection to a voice channel? I don't need to reproduce any audio right now, I just want it to sustain a stable connection to a voice channel without disconnecting...

Makar8000 commented 5 years ago

I am assuming you are building from source? I think WS4Net is just buggy, since removing it fixes the problem, but unfortunately this comes at the cost of Windows 7 support. I will migrate the DiscordAPI part of the project to .NET Core eventually since from what I have read, it fixes the need for WS4Net in the first place. The only concern is that SpeechSynthesis doesn't exist in .NET Core, so I will have to move that over to the ACT Plugin project (which will be using .NET Framework probably until .NET 5 releases as long as ACT itself can support it).

lucagiacometti19 commented 5 years ago

So there is no way for me to connect my bot to a voice channel since my OS is Windows 7 and I need .NET framework...

The only concern is that SpeechSynthesis doesn't exist in .NET Core

It's because of Speech Recognition and Speech Synthesis that I'd like to work with .NET framework instead of .NET core...

Anyway I'll try to upgrade my OS since Windows 7 is way outdated. Thank you all for your kind help and patience! :)

Webberjo commented 5 years ago

Wouldn't be a bad idea. Since 1.0.1.0 works for the most part, it can serve as a legacy release for people still running Win 7 and earlier.

This means no Windows 7 Support until I decide to migrate this project to .NET Core. If you need to use this plugin with Windows 7, please try v1.0.1.0