Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bot unable to join channel #48

Closed
jonrozen opened this issue Jun 8, 2019 · 28 comments
Closed

Bot unable to join channel #48

jonrozen opened this issue Jun 8, 2019 · 28 comments

Comments

@jonrozen
Copy link

jonrozen commented Jun 8, 2019

[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
Copy link
Author

jonrozen commented Jun 9, 2019

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

@Webberjo
Copy link

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
Copy link
Owner

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

@Webberjo
Copy link

Webberjo commented Jun 13, 2019

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
Copy link

linoth commented Jun 15, 2019

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
Copy link
Owner

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
Copy link

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
Copy link

megaoka commented Jul 10, 2019

@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
Copy link

megaoka commented Jul 11, 2019

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

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

discord-net/Discord.Net@fc48c66 ?
Similar issue: discord-net/Discord.Net#1343

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

@Moonbase2004
Copy link

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

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

@megaoka
Copy link

megaoka commented Jul 12, 2019

@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
Copy link

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

@Moonbase2004
Copy link

Problem Solved: It's a bug with WS4NET.

@Makar8000
Copy link
Owner

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
Copy link

megaoka commented Jul 19, 2019

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
Copy link
Owner

Makar8000 commented Jul 26, 2019

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
Copy link

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
Copy link
Owner

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

@lucagiacometti19
Copy link

[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
Copy link

What OS are you using?

@lucagiacometti19
Copy link

lucagiacometti19 commented Jul 29, 2019

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

@Webberjo
Copy link

Webberjo commented Jul 29, 2019

What version of the plugin are you using?

@lucagiacometti19
Copy link

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
Copy link

Webberjo commented Jul 29, 2019

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

@lucagiacometti19
Copy link

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
Copy link
Owner

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
Copy link

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants