the-obsidian / DiscordBridge

:speech_balloon: Chat bridge between Minecraft and Discord
Other
45 stars 7 forks source link

Chat from Minecraft isn't going to Discord #3

Closed Pawned closed 8 years ago

Pawned commented 8 years ago

Hello,

First of all thanks a lot for making this plugin, it's pretty awesome.

I have one issue though in that chat from Minecraft isn't being output in Discord.

The bot connects to the Discord channel no problem and messages from Discord are output in Minecraft, but for some reason Minecraft messages aren't going into Discord.

There are no error messages shown in the console to indicate why this wouldn't be working...

jacobwgillespie commented 8 years ago

Odd - first, I've updated the Discord API client and bumped the version to v1.1.0 - check out https://github.com/the-obsidian/DiscordBridge/releases.

If it's still happening on the latest release, what other plugins are you running? DiscordBridge is just hooking into the basic Spigot chat event, but it's possible another plugin is interfering with that event.

Pawned commented 8 years ago

Thanks for the update.

Still no luck and I can't think what plugin could be interfering. The only chat plugin we're running is one that I wrote, which all it does really is change the format of the chat and only send the message to players within range if they're talking in "local" mode.

I've tried running this with my plugin disabled but still no joy. The only other plugins we have that do anything chat related are Towny and SimpleClans, but they both operate via commands so I can't see as to why they would be an issue.

We were even previously using CraftIRC before switching to Discord to relay chat between the two and that worked without issue.

Just on a side-note does the plugin hook into the join/leave events or is this something you're looking to do in the future? Would be nice when sitting on Discord to know when someone joins the Minecraft server.

EDIT: Have also just setup a Spigot server on my local PC, the only plugin I installed was DiscordBridge and the same issue occurs. Messages from Discord go to Minecraft but messages from Minecraft do not go to Discord.

jacobwgillespie commented 8 years ago

I just pushed a new release - 1.2.0 - https://github.com/the-obsidian/DiscordBridge/releases/tag/v1.2.0 - it adds a new debug setting option that spits out a few more debug messages.

So, here's an overview of how things should look. You should have a bot user at Discord that's connected to your server - you should know its username, email, and password. I don't have mine set up with any special permissions there, just a normal user joined to the server.

Under plugins/DiscordBridge/config.yml, the file should look like this (it'll get the debug key after you update):

settings:
  server-id: '103810560575411054'
  channel: channelname
  username: botusername
  email: botemail@example.com
  password: botpassword
  debug: false
version: 1.2.0

Pretty self-explanatory - the server ID is coming from Server Settings > Widgets in the app, and it's quoted so that it gets interpreted as a string and not as a number. The channel name is the human-friendly channel name (so I can put test for the #test channel), the username, email, and password are the credentials for the bot account.

On the server console when it's starting, if it's able to connect properly, you should see some log lines like the following:

[08:47:50 INFO]: DiscordAPI: Attempting to login!
[08:47:51 INFO]: DiscordAPI: Logged in and starting session!
[08:47:51 INFO]: DiscordAPI: Token: xxxxxxxxxxxxxxxxxxxx
[08:47:51 INFO]: DiscordAPI: Logged in and loaded!
[08:47:51 INFO]: DiscordAPI: Successfully loaded user data!

With the new debug flag set to true, you'll start seeing some more log messages when chat messages are sent or received. So, if I say "test" in Minecraft chat, I should see logs like the following:

[08:48:07 INFO]: [DiscordBridge] Received a chat event from jacobwg: test
[08:48:07 INFO]: [DiscordBridge] Sending chat message to Discord - jacobwg: test
[08:48:07 INFO]: <jacobwg> test
[08:48:07 INFO]: [DiscordBridge] Received message 117637169962549253 from Discord
[08:48:07 INFO]: [DiscordBridge] Ignoring message 117637169962549253 from Discord: it matches the server's username

Anyways, all this may be super obvious, just wanted to cover our bases. Let me know what's happening after you update and if you see those new debug messages.

jacobwgillespie commented 8 years ago

Oh, and join / leave events would be great - I'll add those!

Pawned commented 8 years ago

[15:19:51] [Thread-36/INFO]: <Pawned(discord)> test from discord [15:19:51] [Thread-53/INFO]: [DiscordBridge] Broadcasting message 117645152796934151 from Discord as user Pawned [15:19:51] [Thread-53/INFO]: [DiscordBridge] Received message 117645152796934151 from Discord [15:19:18] [Server thread/INFO]: [G] [Owner] Pawned: test [15:19:18] [Async Chat Thread - #29/INFO]: [DiscordBridge] Sending chat message to Discord - Pawned: ?8[?4G?8] [?4Owner?8]?f Pawned?4:?f test [15:19:18] [Async Chat Thread - #29/INFO]: [DiscordBridge] Received a chat event from Pawned: ?8[?4G?8] [?4Owner?8]?f Pawned?4:?f test [15:19:17] [Thread-53/INFO]: DiscordAPI: Successfully loaded user data! [15:19:17] [Thread-53/INFO]: DiscordAPI: Logged in and loaded! [15:19:16] [Craft Scheduler Thread - 411/INFO]: DiscordAPI: Token: MTE2ODg3NTY2ODQ1NzM5MDE3.CTIc9A.leOCRRcLwVE-s3udyUqVDepwDvg [15:19:16] [Craft Scheduler Thread - 411/INFO]: DiscordAPI: Logged in and starting session! [15:19:16] [Craft Scheduler Thread - 411/INFO]: DiscordAPI: Attempting to login! [15:19:16] [Server thread/INFO]: [DiscordBridge] Enabling DiscordBridge v1.2.0

Here's what we've got, doesn't make debugging any easier lmao. No idea why the chat isn't going into Discord

jacobwgillespie commented 8 years ago

Oddly enough, that last line "test from discord" should be the broadcast message, so that should have shown up in your Minecraft chat, but it's missing a username though, which is weird. Anyways. Also, it looks like you're using prefixes with color codes which is something I haven't tested against yet - it's possible that's throwing things off (like maybe Discord doesn't like the special characters).

So, new release - https://github.com/the-obsidian/DiscordBridge/releases/tag/v1.3.0

This strips colors before sending to Discord, adds messages on join / leave, and adds settings to customize the message templates. Let me know if that changes anything.

Pawned commented 8 years ago

Still no joy. That "test from discord" did go through to Minecraft, it's just the "test" that didn't go through to Discord.

I've tried this on my local server as well, which is 100% vanilla with just your plugin and still no luck there either

Pawned commented 8 years ago

Just checked the console with the new version and even with the join events it is logging it but nothing is getting put into the Discord chat:

[16:58:02] [Server thread/INFO]: [DiscordBridge] Sending message to Discord - Pawned joined the server [16:58:02] [Server thread/INFO]: [DiscordBridge] Received a join event for Pawned

It's strange that the bot is able to connect to the Discord chat, read all the messages and post them on Minecraft but not vice versa. There are no permissions set on the channel that could be stopping it either.

jacobwgillespie commented 8 years ago

Odd - let me do some more digging and get in touch with @NotGGhost who authored the API client library I'm using to see what might cause that.

jacobwgillespie commented 8 years ago

Don't have anything new to try yet, but for reference, what OS are you using?

Pawned commented 8 years ago

Have tried on my PC which is Windows 10 64bit and my server which is on MineOS Turnkey 64bit

Pawned commented 8 years ago

Also logged in as the bot just to make sure it can definitely talk in Discord and it can.

image

Pawned commented 8 years ago

My plugin never cancels the chat event, simply removes people that aren't in range from the event's recipients so it shouldn't interfere with this. We were using CraftIRC before this and had no problems.

And as I said even with DiscordBridge as the only plugin loaded, all looks OK in the console but nothing goes through to Discord.

Pawned commented 8 years ago

Couple screenshots to show it not working with only DiscordBridge running

image

image

Pawned commented 8 years ago

@NotGGhost @jacobwgillespie Any ideas guys?

jacobwgillespie commented 8 years ago

Though due to the logic here, that should ensure that the server and group IDs are correct since he's seeing Discord messages in Minecraft.

@Pawned, it would help if you posted your config though, email / password sanitized of course.

Pawned commented 8 years ago

Sure, it's:

settings:
  server-id: '115199507196542983'
  channel: Pawncraft
  username: Pawnbot
  email: blah@blah.com
  password: *******
  debug: true
  templates:
    discord:
      chat_message: <%u> %m
      player_join: '%u joined the server'
      player_leave: '%u left the server'
    minecraft:
      chat_message: <%u&b(discord)&r> %m
version: 1.3.0
Pawned commented 8 years ago

@NotGGhost Yeah that fixed it! That's a good spot, I forgot that Discord automatically converts the channel to all lowercase. Though I didn't think it'd have that much of an effect on this plugin lol.

Thanks guys :)

jacobwgillespie commented 8 years ago

Ah, nice! I'll update the plugin to automatically convert to downcase to prevent in the future. Thanks @NotGGhost!