Sign in to follow this  
whisper2shade

[RELEASED] Discord Relay

Recommended Posts

This is a great mod. It's absolutely wonderful that this type of integration has finally arrived for Wurm. However, I do have a few things I'd like to mention. Some of which I've already stated in the Wurm Modding discord, but I'll re-state them here for reference:

  • Packaging the libraries directly into the jar probably isn't the best practice. I believe packaging the library separately and adjusting the classpath in the properties to something similar to "classpath=*.jar,libs/*.jar" where the JDA library is in the libs folder is likely more ideal.
  • Channel names in-game do not accurately reflect channel names in Discord. For example, the "Freedom" chat in discord goes to "#freedom_isles" - instead I would recommend using "#freedom" for the Discord channel to keep them identical. This would change "#horde_of_the_summoned" to "#hots" which makes it easier for players to understand what channel they're actually typing in.
  • You may want to adjust the mod to focus on GL- communications instead of server-specific channels. This will help with cluster setup as well. When using multiple islands, the best option for integration was GL- only because otherwise players on other islands would only get half the conversation from Discord.
  • Non-login servers do not need to handle WcKingdomChat messages. In the current implementation, discord messages sent to the in-game chat are duplicated per server the app is running on. You can comment out the else and "wc.sendToLoginServer();" in the code, forcing the login server to handle and distribute all Discord chatter, as it should be.

I heavily appreciate the public release of this mod. I'm curious to see what you've got up your sleeve next. :)

Edited by Sindusk
  • Like 3

Share this post


Link to post
Share on other sites

Hello!

 

Have problems.

 

Bot sending msges from discord to game, but not send from game to discord with error in logs:

Quote

[06:21:25 PM] SEVERE org.gotti.wurmunlimited.modloader.server.Listeners: ChannelMessageListener handler for mod DiscordRelay failed
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.LinkedList.checkElementIndex(Unknown Source)
    at java.util.LinkedList.get(Unknown Source)
    at org.nyxcode.wurm.discordrelay.DiscordRelay.onKingdomMessage(DiscordRelay.java:64)
    at org.gotti.wurmunlimited.modloader.server.ServerHook.lambda$fireOnKingdomMessage$10(ServerHook.java:76)
    at org.gotti.wurmunlimited.modloader.server.Listeners.lambda$fire$1(Listeners.java:47)
    at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
    at java.util.Spliterators$ArraySpliterator.forEachRemaining(Unknown Source)
    at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
    at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
    at java.util.stream.ReferencePipeline.reduce(Unknown Source)
    at org.gotti.wurmunlimited.modloader.server.Listeners.fire(Listeners.java:53)
    at org.gotti.wurmunlimited.modloader.server.ServerHook.fireOnKingdomMessage(ServerHook.java:76)
    at org.gotti.wurmunlimited.modloader.server.ProxyServerHook.communicatorChannelHook(ProxyServerHook.java:248)
    at com.wurmonline.server.creatures.Communicator.reallyHandle_CMD_MESSAGE(Communicator.java:6289)
    at com.wurmonline.server.creatures.Communicator.reallyHandle(Communicator.java:2420)
    at com.wurmonline.communication.SocketConnection.tick(SocketConnection.java:615)
    at com.wurmonline.communication.SocketServer.tick(SocketServer.java:172)
    at com.wurmonline.server.Server.run(Server.java:2462)
    at java.util.TimerThread.mainLoop(Unknown Source)
    at java.util.TimerThread.run(Unknown Source)

 

My config:

Quote

classname=org.nyxcode.wurm.discordrelay.DiscordRelay
classpath=*.jar
sharedClassLoader=false

# Required
# Discord bot token
botToken=<app token from https://discordapp.com/developers/applications/me/>

# Required
# Discord server to connect to
discordServerName=210776794977140736
# Required
# In game relay identification
# Player name in Wurm that will prefix all discord messages
wurmBotName=Bot
# Optional
# true: Kingdom names that contain space will have matching discord
# channels with spaces replaced by underscores (Freedom Isles -> freedom_isles)
#
# false: Kingdom names that contain space will have matching discord
# channels without them (Freedom Isles -> freedomisles)
useUnderscore=false

 

In DB: Kingdom name = PvE (id 4), in discord channel #pve

 

Whats wrong I do?

Share this post


Link to post
Share on other sites
25 minutes ago, DiWorm said:

Hello!

 

Have problems.

 

Bot sending msges from discord to game, but not send from game to discord with error in logs:

 

My config:

 

In DB: Kingdom name = PvE (id 4), in discord channel #pve

 

Whats wrong I do?

Only real difference I see in your config and mine, is that I put the actual Discord server name (not number) in mine, and works perfectly, within its limitations (messages from other bot not being relayed)

So maybe you need to put <Server Name> rather than <234328947...>

  • Like 1

Share this post


Link to post
Share on other sites
7 minutes ago, Himeros said:

Only real difference I see in your config and mine, is that I put the actual Discord server name (not number) in mine, and works perfectly, within its limitations (messages from other bot not being relayed)

So maybe you need to put <Server Name> rather than <234328947...>

Thanks :)

Share this post


Link to post
Share on other sites

Can u add in next version config params for disable/enable kingdom global chat (GL-Kingdom Name)? And CA-Chat transfer will be amazing

Edited by DiWorm

Share this post


Link to post
Share on other sites

A Trade transfer would also be cool^^ If that is possible, since the Bot messages transferred ingame start with <DiscordName> and Trade chat requires a WTB/WTS as first word..

  • Like 2

Share this post


Link to post
Share on other sites
19 hours ago, Sindusk said:

You may want to adjust the mod to focus on GL- communications instead of server-specific channels. This will help with cluster setup as well. When using multiple islands, the best option for integration was GL- only because otherwise players on other islands would only get half the conversation from Discord.

Thats what we would need =)

 

Eject

  • Like 1

Share this post


Link to post
Share on other sites

Sorry guys, i've been off for a bit - RL stuff. I still need a bit of time to sort out stuff, but i will continue with my mods next week.

  • Like 3

Share this post


Link to post
Share on other sites

Have you some news for us? ;)

If discord relay would work with GL-Freedom, than i just need it at the loginserver and get no double posts =)

 

Eject

Share this post


Link to post
Share on other sites
On 11/19/2017 at 1:05 AM, Eject said:

Have you some news for us? ;)

If discord relay would work with GL-Freedom, than i just need it at the loginserver and get no double posts =)

 

Eject

Here's a re-write I did that no longer echos at all. However, it only works for GL-Freedom. You would need to edit it a bit if you wanted to make it do something else (like other kingdoms).

 

https://pastebin.com/ubXRmNrM

 

Here's that code compiled and repackaged slightly:

 

https://drive.google.com/open?id=1ExpXeeQpr56qB9ZVP6Ii4I9ejqBaAsQd

 

You'll need to edit your properties file with these changes as well to make it work. Your existing properties will function with these changes:

classpath=*.jar,libs/*.jar
sharedClassLoader=true

 

Edited by Sindusk
  • Like 2

Share this post


Link to post
Share on other sites

Hello Sindusk

 

Thank you very much =) i need the mod now just at the loginserver? or can i upload it to all servers if the loginserver is offline for some reason and i ilike to speak with the players at the other servers?

 

Eject

Share this post


Link to post
Share on other sites
14 minutes ago, Eject said:

Hello Sindusk

 

Thank you very much =) i need the mod now just at the loginserver? or can i upload it to all servers if the loginserver is offline for some reason and i ilike to speak with the players at the other servers?

 

Eject

It goes on every server and will not duplicate. The mod no longer has anything to do with something being a login server or not. When a player sends a message, the server that the player is on processes the message through the DiscordRelay that's on that current server to send the message to Discord. If a message is sent from Discord, each server individually processes it and adds a message to their own GL-Freedom channel directly instead of "broadcasting" the message as a global message. This prevents duplication of the messages entirely. If the login server is offline, and a message is sent on another server, it will still relay to Discord if the mod is installed on that other server. Equally, any server running the DiscordRelay mod will have any messages from Discord processed to their GL-Freedom channel.

  • Like 1

Share this post


Link to post
Share on other sites

I updated the mod now and editing the properties file with your lines

Now i get this message: 

 

 

[04:06:54 PM] SEVERE org.gotti.wurmunlimited.modloader.server.Listeners: ChannelMessageListener handler for mod DiscordRelay failed

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

at java.util.ArrayList.rangeCheck(ArrayList.java:653)

at java.util.ArrayList.get(ArrayList.java:429)

at java.util.Collections$UnmodifiableList.get(Collections.java:1309)

at org.nyxcode.wurm.discordrelay.DiscordRelay.sendToDiscord(DiscordRelay.java:64)

at org.nyxcode.wurm.discordrelay.DiscordRelay.onKingdomMessage(DiscordRelay.java:73)

at org.gotti.wurmunlimited.modloader.server.ServerHook.lambda$fireOnKingdomMessage$10(ServerHook.java:108)

at org.gotti.wurmunlimited.modloader.server.Listeners.lambda$fire$1(Listeners.java:82)

at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)

at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)

at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)

at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)

at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)

at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)

at java.util.stream.ReferencePipeline.reduce(ReferencePipeline.java:479)

at org.gotti.wurmunlimited.modloader.server.Listeners.fire(Listeners.java:88)

at org.gotti.wurmunlimited.modloader.server.ServerHook.fireOnKingdomMessage(ServerHook.java:108)

at org.gotti.wurmunlimited.modloader.server.ProxyServerHook.communicatorChannelHook(ProxyServerHook.java:248)

at com.wurmonline.server.creatures.Communicator.reallyHandle_CMD_MESSAGE(Communicator.java:6372)

at com.wurmonline.server.creatures.Communicator.reallyHandle(Communicator.java:2420)

at com.wurmonline.communication.SocketConnection.tick(SocketConnection.java:615)

at com.wurmonline.communication.SocketServer.tick(SocketServer.java:172)

at com.wurmonline.server.Server.run(Server.java:2462)

at java.util.TimerThread.mainLoop(Timer.java:555)

at java.util.TimerThread.run(Timer.java:505)

 

There is no text sending now in both directions.

 

Eject

Share this post


Link to post
Share on other sites
2 minutes ago, Eject said:

I updated the mod now and editing the properties file with your lines

Now i get this message: 

 

 

[04:06:54 PM] SEVERE org.gotti.wurmunlimited.modloader.server.Listeners: ChannelMessageListener handler for mod DiscordRelay failed

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

at java.util.ArrayList.rangeCheck(ArrayList.java:653)

at java.util.ArrayList.get(ArrayList.java:429)

at java.util.Collections$UnmodifiableList.get(Collections.java:1309)

at org.nyxcode.wurm.discordrelay.DiscordRelay.sendToDiscord(DiscordRelay.java:64)

at org.nyxcode.wurm.discordrelay.DiscordRelay.onKingdomMessage(DiscordRelay.java:73)

at org.gotti.wurmunlimited.modloader.server.ServerHook.lambda$fireOnKingdomMessage$10(ServerHook.java:108)

at org.gotti.wurmunlimited.modloader.server.Listeners.lambda$fire$1(Listeners.java:82)

at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)

at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)

at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)

at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)

at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)

at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)

at java.util.stream.ReferencePipeline.reduce(ReferencePipeline.java:479)

at org.gotti.wurmunlimited.modloader.server.Listeners.fire(Listeners.java:88)

at org.gotti.wurmunlimited.modloader.server.ServerHook.fireOnKingdomMessage(ServerHook.java:108)

at org.gotti.wurmunlimited.modloader.server.ProxyServerHook.communicatorChannelHook(ProxyServerHook.java:248)

at com.wurmonline.server.creatures.Communicator.reallyHandle_CMD_MESSAGE(Communicator.java:6372)

at com.wurmonline.server.creatures.Communicator.reallyHandle(Communicator.java:2420)

at com.wurmonline.communication.SocketConnection.tick(SocketConnection.java:615)

at com.wurmonline.communication.SocketServer.tick(SocketServer.java:172)

at com.wurmonline.server.Server.run(Server.java:2462)

at java.util.TimerThread.mainLoop(Timer.java:555)

at java.util.TimerThread.run(Timer.java:505)

 

There is no text sending now in both directions.

 

Eject

You'll need to add a #gl-freedom channel to your discord.

Share this post


Link to post
Share on other sites

Thank you Sindusk it works now =) 

Now i can give all the permissions in discord to write in the channel, perfect =)

 

Eject

Share this post


Link to post
Share on other sites
4 minutes ago, Eject said:

Thank you Sindusk it works now =) 

Now i can give all the permissions in discord to write in the channel, perfect =)

 

Eject

As a side note, after looking at it a little, I did actually code it so it will work for other kingdoms GL chats as well, so if you have kingdom based servers adding a #gl-hots channel for example should also work. The name of the channel in discord should match the name of the channel in-game exactly, all lowercase. In case you see that error again, it would be caused by someone chatting in a "GL" chat of a kingdom that has no channel on Discord. It wont crash the server or break the bot, though - it's mostly a harmless error.

Edited by Sindusk
  • Like 1

Share this post


Link to post
Share on other sites

Fixed it

Spoiler
Solved!

 

Edited by Governor

Share this post


Link to post
Share on other sites

IVUetMP.pngMaybe its because the botname, i use no space in the name and it works wonderful

 

Eject

 

add:

ok, i see now its not the botname in discord its the name in the game

 

# Player name in Wurm that will prefix all discord messages
wurmBotName=Requiem Bot#0428

 

at the first version i had simple

wurmBotName=Discord

and that was also working, you can use here a unique name, its not depending on the botname in discord and maybe the # makes also problems. Just to try, use a simple name and look.

 

Edited by Eject
  • Like 1

Share this post


Link to post
Share on other sites

Guys, i haven't forgotten about you.

It's just the real life that's throwing roadblocks for me right now. I haven't even read the rest of the thread yet (i will). I just wanted to say that i'm still alive and will continue with this mod. Just please be patient.

  • Like 1

Share this post


Link to post
Share on other sites

Fixed it

 

Spoiler
Solved!

 

Edited by Governor

Share this post


Link to post
Share on other sites

Anyway to get chats sent to GL too?  I mean so it sends from gl_freedomisles in Discord to GL-Freedom IG

Edited by Elsa

Share this post


Link to post
Share on other sites

I'm working on a new version and rewriting a lot of the code, just give me a bit more time.
No idea if i can make GL channels work, but i'll try.

  • Like 2

Share this post


Link to post
Share on other sites

Would it be possible to send server shutdowns in the discord?

 

Eject

Share this post


Link to post
Share on other sites

Is there any new news on this?
I'd like to use it, but the OP version sounds as though it's still buggy, and I have no need, nor desire for a GL chat.
So the requirement of the typical Freedom Chat is a must, which appears to have been removed from any updates anyone else has released.

Share this post


Link to post
Share on other sites

Here's a new release, but it's moderately different from how the original mod handles things:

  • Only applicable to GL-Kingdom chats. Uses abbreviated kingdom names instead of full ones (#gl-hots for example. Identical to how the name is displayed in-game but lowercased).
  • Prefixes messages from Discord -> ingame with [D] to signify they came from Discord, instead of using a custom name.
  • Prefixes all messages in Discord with the server-side timestamp of when the message was broadcast.
  • Uses member nicknames instead of usernames from Discord. This means if I'm SomeGuy#7799 as my Discord login but my screen name for my server discord is Sindusk, the relay will now use the Sindusk name instead of "SomeGuy"
  • Can now be utilized as a library from other mod authors to link messages into relay. For mod authors interested:
    • Add the line "depends.import=DiscordRelay" to your properties file. Keep in mind this will create a hard dependency on DiscordRelay, meaning if DiscordRelay is not installed on the server, your mod will not work.
    • From your mod, call the method "sendToDiscord(String channel, String message)" to send messages to channels of your choice.

https://github.com/Sindusk/DiscordRelay/releases/tag/v1.0

 

I'll likely expand a bit further on it as well in the near future and increase the functionality, including some of what my other mods are capable of:

  • Unique mob rumours and slay event channel.
  • Death tabs relay.
  • Any other ideas that might be requested.

Screenshots of some of the changes:

 

Timestamps in Discord:

Spoiler

B6p6NPO.png

Same messages displayed in game:

Spoiler

0aYq96r.png

Upcoming - Currently using a dependent mod with the "library" usage mentioned above to accomplish this:

Spoiler

dQPLZfL.png

 

  • Like 2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this