amsam0 / voicechat-discord

A mod and plugin to make a bridge between Simple Voice Chat and Discord to allow for players without the mod to hear and speak.
https://modrinth.com/mod/simple-voice-chat-discord-bridge
MIT License
24 stars 7 forks source link

Invalid token #21

Closed washhtubs closed 1 year ago

washhtubs commented 1 year ago

I have just finished setting up this mod for the first time and have completed the setup instructions and restarted my server and reloaded the configs etc. On server startup, the server recognised that there was one bot and that the debug mode was set to level 1:

09.06 22:50:13 [Server] Thread-17/[INFO] Using 1 bot 09.06 22:50:13 [Server] Thread-17/[INFO] Debug mode has been set to level 1

However, in my discord server, the bot is offline, and running the command /dvc start gives this message in the console:

09.06 22:50:38 [Server] Thread-18/[ERROR] Failed to login to the bot using vc_id 861688883246137344 09.06 22:50:38 [Server] [INFO] dev.naturecodevoid.voicechatdiscord.shadow.jda.api.exceptions.InvalidTokenException: The provided token is invalid! 09.06 22:50:38 [Server] [INFO] at dev.naturecodevoid.voicechatdiscord.shadow.jda.internal.JDAImpl.verifyToken(JDAImpl.java:414) ~[voicechat-discord-fabric-2.0.0-beta-nightly.c836c4436ec4f47b8c13f7c0d9fbc9fe165c2938.jar:?] 09.06 22:50:38 [Server] [INFO] at dev.naturecodevoid.voicechatdiscord.shadow.jda.internal.JDAImpl.login(JDAImpl.java:331) ~[voicechat-discord-fabric-2.0.0-beta-nightly.c836c4436ec4f47b8c13f7c0d9fbc9fe165c2938.jar:?] 09.06 22:50:38 [Server] [INFO] at dev.naturecodevoid.voicechatdiscord.shadow.jda.internal.JDAImpl.login(JDAImpl.java:297) ~[voicechat-discord-fabric-2.0.0-beta-nightly.c836c4436ec4f47b8c13f7c0d9fbc9fe165c2938.jar:?] 09.06 22:50:38 [Server] [INFO] at dev.naturecodevoid.voicechatdiscord.shadow.jda.api.JDABuilder.build(JDABuilder.java:1828) ~[voicechat-discord-fabric-2.0.0-beta-nightly.c836c4436ec4f47b8c13f7c0d9fbc9fe165c2938.jar:?] 09.06 22:50:38 [Server] [INFO] at dev.naturecodevoid.voicechatdiscord.DiscordBot.login(DiscordBot.java:99) ~[voicechat-discord-fabric-2.0.0-beta-nightly.c836c4436ec4f47b8c13f7c0d9fbc9fe165c2938.jar:?] 09.06 22:50:38 [Server] [INFO] at dev.naturecodevoid.voicechatdiscord.SubCommands.lambda$register$0(SubCommands.java:62) ~[voicechat-discord-fabric-2.0.0-beta-nightly.c836c4436ec4f47b8c13f7c0d9fbc9fe165c2938.jar:?] 09.06 22:50:38 [Server] [INFO] at java.lang.Thread.run(Thread.java:831) ~[?:?] 09.06 22:50:38 [Server] Thread-18/[ERROR] Tried to start audio transfer system but the bot has not been logged into. Please report this on GitHub Issues!

I've double checked the Token ID and VC ID to make sure they are right, and they are, so I'm not sure why it's saying it's invalid.

In the voicechat-discord.yml file the vc_id is written in orange, the same as the debug_level, but the token is written in black.

Also, when starting the server for the first time, the console reported that voicechat-discord was incompatible with "voicechat 1.19.4-2.4.9" and to replace it with "voicechat 2.4.8 or higher". I got around this by changing the "voicechat" dependency value in the fabric.mod.json file:

"depends": { "fabricloader": ">=0.14.10", "fabric-api": "*", "minecraft": ">=1.19.2", "java": ">=17", "voicechat": ">=1.19.4-2.4.9"

Any thoughts or solutions would be greatly appreciated.

PS This mod is really cool, thank you very much for the work you've put in :)

amsam0 commented 1 year ago

Something about the way you entered your token or the way it is in the yaml made it invalid. You might also need to regenerate it.

I'll look into the dependency issue

washhtubs commented 1 year ago

I've regenerated my token and followed the steps in the set-up again and am getting the same console outputs.

amsam0 commented 1 year ago

Could you send the config yaml and replace the token characters and VC ID with X's? (Keep the periods)

washhtubs commented 1 year ago

Sure:

To add a bot, just copy paste the following into bots:

#

bots:

- token: DISCORD_BOT_TOKEN_HERE

vc_id: VOICE_CHANNEL_ID_HERE

#

Example for 2 bots:

#

bots:

- token: MyFirstBotsToken

vc_id: 1234567890123456789

- token: MySecondBotsToken

vc_id: 9876543210987654321

#

If you are only using 1 bot, just replace DISCORD_BOT_TOKEN_HERE with your bot's token and replace VOICE_CHANNEL_ID_HERE with the voice channel ID.

#

If you are reporting an issue or trying to figure out what's causing an issue, you may find the debug_level option helpful.

It will enable debug logging according to the level:

- 0 (or lower): No debug logging

- 1: Some debug logging (mainly logging that won't spam the console but can be helpful)

- 2: Most debug logging (will spam the console but excludes logging that is extremely verbose and usually not helpful)

- 3 (or higher): All debug logging (will spam the console)

#

For more information on getting everything setup: https://github.com/naturecodevoid/voicechat-discord#readme

bots:

This is what the file looks like in a text editor:

image
amsam0 commented 1 year ago

I might've located the problem. It may be an issue with JDA, but it seems that the first part of the token (base64 of user ID iirc, so nothing sensitive) has 2 more characters than that part of one of the tokens I used for testing. This may be because of the bot being created more recently.

amsam0 commented 1 year ago

The issue with the voicechat dependency is also fixed, I just forgot to mention it

washhtubs commented 1 year ago

Right, that makes sense. Is there an easy way to fix this?

amsam0 commented 1 year ago

I'll ask in the JDA discord server, I'm pretty sure the first part of the token is user ID encoded in base64 which means it's nothing sensitive. If you want to DM it to me on Discord or something instead of posting here, it would be very helpful (and you can always regenerate the token after sharing the first part to invalidate the old one)

washhtubs commented 1 year ago

Yeah for sure, what's your discord info?

amsam0 commented 1 year ago

Just naturecodevoid with the new usernames

Also, some people from the JDA discord server responded. JDA does not validate tokens, Discord is saying the token is invalid when attempting to login to the bot. So something about your token is incorrect. It's also possible that some hidden whitespace is being added to the token due to you being on windows, so I'll add a .trim(). Tell me if that fixes it (however, the fix won't be available for a few more days since I'm currently in the middle of a big refactor)

amsam0 commented 1 year ago

Could you try updating to 2.0.0 and see if that fixes the issue?

washhtubs commented 1 year ago

Updating to 2.0.0 works, which is great, thank you very much. Although, when a few console players on my server run /dvc start they are booted from the server. I don't think that's an issue with the mod though as I wasn't able to replicate it