Jump to content

Python based discord relay script


Kyle Stemen

Recommended Posts

Warning: this technically isn't a mod.

 

I noticed there aren't any discord bridge mods yet. I wanted at least something basic for my server so that potential players could watch Discord to see when the server is active.

 

I wrote a python script that scrapes the server log files and relays important messages to discord. Unfortunately it's not a complete bridge. It only copies messages from in-game to discord. It does not copy messages from discord to in-game. I'm a bit embarrassed by it, but maybe other server owners can get some use out of it. I would be very pleased if someone else wrote a proper discord bridge mod instead.

 

To use the discord relay:

1. Create a discord bot and put its information (token and channel) inside of the config.json file.

2. Also edit the file paths in config.json to point to where your server stores its logs.

3. Keep config.json in the same directory as relay.py.

4. Install the python discord library, if you don't already have it. On my server, I installed it with

    $ pip install -U discord.py --user

5. Run relay.py.

 

I've only tried it on Linux. I run it from a tmux session to prevent it from stopping when I log out.

config.json relay.py

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.