[Mod + Program] Minetest-Discord relay [discordmt] [v0.1]

Post Reply
User avatar
archfan7411
Member
Posts: 15
Joined: Wed Sep 26, 2018 00:37
GitHub: archfan7411
In-game: archfan

[Mod + Program] Minetest-Discord relay [discordmt] [v0.1]

by archfan7411 » Post

Minetest-Discord relay [discordmt]

An easy-to-use relay complete with login and command support, using an external program written in Python.

GitHub | Direct link to latest release (.zip) | Wiki

Licensed under MIT

Have you ever wanted to interact with and moderate your server without logging into the game (or IRC)?
Do you have an active community on Discord which you'd like to bridge to Minetest?
Are you unsatisfied with the features or long installation steps of the current Discord relays?


If you answered YES to any of these questions, discordmt is for you!

Setup

1. Download or clone the repository.

2. Create an application at the Discord Developer Dashboard and enable it as a bot (in the Bot tab.) For a more detailed guide on creating Discord bots, see this bot setup guide by reactiflux. Make sure you check the box to enable the Message Content intent.

3. Copy the token from your newly-created bot, and use it to finish setting up relay.conf along with any other settings you wish to change. The ID of the channel you wish to relay to must also be specified in relay.conf; you may obtain it by enabling Developer Mode on the Discord client and rightclicking the desired channel in the list.

Example relay.conf: (The token shown below has been regenerated)

Code: Select all

[BOT]
token = NjEwODk0MDU4ODY4NzAzMjMz.XVL5dA.8j8d2XN8_5UwRheG91P2XksYDoM
command_prefix = !
[RELAY]
port = 8080
channel_id = 576585506658189332
allow_logins = true
clean_invites = true
use_nicknames = true
4. Put discordmt in your Minetest mods directory. Server owners may wish to separate the Python and Lua portions of the relay - server.py and relay.conf can go just about anywhere as long as they stay together.

5. Enable mod security and add discordmt to the HTTP mods. In addition, set "discord.port" in your minetest.conf to match the port you used in relay.conf and optionally set "discord.text_color" to a hex color string if you'd like to color relayed messages from Discord.

Example minetest.conf excerpt:

Code: Select all

secure.enable_security = true
secure.http_mods = discordmt
discord.port = 8080
discord.text_color = #a7a7a7
(Side note: The port must be set in both relay.conf and minetest.conf because users may decide to run the relay in a different location than the mod, or to run multiple relays/servers at once, for which setting different ports would be required.)

6. Run the relay and, when you're ready, the Minetest server. The relay may be left up even when the server goes down, or may run continuously between several server restarts, for maximum convenience.

Logging in and running commands

Discord users may log in by using the !login <username> [password] command in DMs (Direct Messages) with the bot. This command should never be used outside of DMs.

Once a user is logged in, they may run commands with !cmd <command name> [command params] in either the relay channel or DMs with the bot.

Additional information

- Logins persist while the relay is up; users do not need to relogin after the Minetest server alone restarts.
- The relay program should be running if you start a Minetest server with `discordmt` enabled; otherwise harmless but annoying HTTP errors will be thrown.
- Running two Minetest servers connecting to a single relay, or multiple relays connected to a single bot, will work unexpectedly and is not recommended. Optimally, you should run a separate relay and bot for each Minetest server.

Thank you for using discordmt!
Last edited by archfan7411 on Tue Nov 01, 2022 23:24, edited 4 times in total.

User avatar
archfan7411
Member
Posts: 15
Joined: Wed Sep 26, 2018 00:37
GitHub: archfan7411
In-game: archfan

Re: [Mod + Program] Minetest-Discord relay [discordmt] [v0.1

by archfan7411 » Post

The relay has been updated to support a new relay.conf option, "clean_invites". When enabled, this option automatically strips Discord invite links from Discord messages when relaying them to Minetest.

A note: The current GitHub Release has had its binaries updated to reflect the change, however the source code bundled with the release is outdated. Releases are used in this project solely to distribute compiled binaries of the Python relay for those who do not wish to install the dependencies, and the source code should always be cloned from the master branch.

redblade7
Member
Posts: 316
Joined: Sun Feb 15, 2015 07:14
IRC: redneonglow redblade7
In-game: redblade7 redblade7_owner

Re: [Mod + Program] Minetest-Discord relay [discordmt] [v0.1

by redblade7 » Post

Looks great!

Caveat for people like me who try and stick with the stable versions, if you're on v5.0.1 you have to make this change to avoid annoying messages filling up your log:

https://github.com/minetest/minetest/co ... 604ef44a0b
-redblade7, admin of: THE CREATIVE GARDENS (creative), THE VALLEYS (sandbox), and THE DIGITAL FARMS (farming/hunger/shops)

User avatar
archfan7411
Member
Posts: 15
Joined: Wed Sep 26, 2018 00:37
GitHub: archfan7411
In-game: archfan

Re: [Mod + Program] Minetest-Discord relay [discordmt] [v0.1

by archfan7411 » Post

An update has been released on GitHub which fixes compatibility with the IRC mod.

User avatar
Nathan.S
Member
Posts: 1147
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21
Location: Bigsby Texas
Contact:

Re: [Mod + Program] Minetest-Discord relay [discordmt] [v0.1

by Nathan.S » Post

Running your executable gives me this error

Code: Select all

Error loading Python lib '/tmp/_MEIrBbt57/libpython3.7m.so.1.0': dlopen: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /tmp/_MEIrBbt57/libpython3.7m.so.1.0)
I'd like to try using the source but I don't know where to find discord.py or aiohttp could you possibly update the documentation to point to where to find those files. Thanks.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

User avatar
Nathan.S
Member
Posts: 1147
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21
Location: Bigsby Texas
Contact:

Re: [Mod + Program] Minetest-Discord relay [discordmt] [v0.1

by Nathan.S » Post

Forget everything I said, I got it figured out.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

User avatar
Nathan.S
Member
Posts: 1147
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21
Location: Bigsby Texas
Contact:

Re: [Mod + Program] Minetest-Discord relay [discordmt] [v0.1

by Nathan.S » Post

Quick question, is it possible to prefix a chat message with something to keep the bridge from copying it over to discord? I know some of the IRC mods have some sort of 'off' prefix you can use. I didn't see anything in the wiki, but I may have missed it.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

redblade7
Member
Posts: 316
Joined: Sun Feb 15, 2015 07:14
IRC: redneonglow redblade7
In-game: redblade7 redblade7_owner

Re: [Mod + Program] Minetest-Discord relay [discordmt] [v0.1

by redblade7 » Post

Nathan.S wrote:Quick question, is it possible to prefix a chat message with something to keep the bridge from copying it over to discord? I know some of the IRC mods have some sort of 'off' prefix you can use. I didn't see anything in the wiki, but I may have missed it.
If this "off prefix" feature was to be added to discordmt, there should be an option by the Minetest server owner to disable it globally.
-redblade7, admin of: THE CREATIVE GARDENS (creative), THE VALLEYS (sandbox), and THE DIGITAL FARMS (farming/hunger/shops)

Oliver4
New member
Posts: 1
Joined: Sat Jan 02, 2021 16:18
IRC: Oliver4
In-game: Oliver4

Re: [Mod + Program] Minetest-Discord relay [discordmt] [v0.1]

by Oliver4 » Post

archfan7411 wrote:
Wed Aug 28, 2019 12:53
Minetest-Discord relay [discordmt]

An easy-to-use relay complete with login and command support, using an external program written in Python.

GitHub | Releases | Wiki

Licensed under MIT

Have you ever wanted to interact with and moderate your server without logging into the game (or IRC)?
Do you have an active community on Discord which you'd like to bridge to Minetest?
Are you unsatisfied with the features or long installation steps of the current Discord relays?


If you answered YES to any of these questions, discordmt is for you!

Setup

1. Download or clone the repository. If you don't want to install Python and/or the dependencies for running the Python relay, take a look at the releases for binary executables.

2. Create an application at the Discord Developer Dashboard and enable it as a bot (in the Bot tab.) For a more detailed guide on creating Discord bots, see this bot setup guide by reactiflux.

3. Copy the token from your newly-created bot, and use it to finish setting up relay.conf along with any other settings you wish to change. The ID of the channel you wish to relay to must also be specified in relay.conf; you may obtain it by enabling Developer Mode on the Discord client and rightclicking the desired channel in the list.

Example relay.conf: (The token shown below has been regenerated)

Code: Select all

[BOT]
token = NjEwODk0MDU4ODY4NzAzMjMz.XVL5dA.8j8d2XN8_5UwRheG91P2XksYDoM
command_prefix = !
[RELAY]
port = 8080
channel_id = 576585506658189332
allow_logins = true
clean_invites = true
use_nicknames = true
4. Put discordmt in your Minetest mods directory. You may also run the relay program from the mod directory, though server owners may wish to separate the two for cleanliness. If you separate the two, ensure that at least the init.lua and settingtypes.txt make it into the mods directory.

5. Enable mod security and add discordmt to the HTTP mods. In addition, set "discord.port" in your minetest.conf to match the port you used in relay.conf and optionally set "discord.text_color" to a hex color string if you'd like to color relayed messages from Discord.

Example minetest.conf excerpt:

Code: Select all

secure.enable_security = true
secure.http_mods = discordmt
discord.port = 8080
discord.text_color = #a7a7a7
(Side note: The port must be set in both relay.conf and minetest.conf because users may decide to run the relay in a different location than the mod, or to run multiple relays/servers at once.)

6. Run the relay and, when you're ready, the Minetest server. The relay may be left up even when the server goes down, or may run continuously between several server restarts, for maximum convenience.

Logging in and running commands

Discord users may log in by using the !login <username> [password] command in DMs (Direct Messages) with the bot. This command should never be used outside of DMs.

Once a user is logged in, they may run commands with !cmd <command name> [command params] in either the relay channel or DMs with the bot.

Additional information

- Logins persist while the relay is up; users do not need to relogin after the Minetest server alone restarts.
- The relay program must be running if you start a Minetest server with `discordmt` enabled; otherwise HTTP errors will be thrown.
- Running two Minetest servers connecting to a single relay, or multiple relays connected to a single bot, will work unexpectedly and is not recommended. You should run a separate relay and bot for each Minetest server.

Thank you for taking the time to read my wall of text, and feel free to reply or otherwise contact me if you have any issues using the relay.
how do i run the relay?

User avatar
philipbenr
Member
Posts: 1897
Joined: Fri Jun 14, 2013 01:56
GitHub: philipbenr
IRC: philipbenr
In-game: robinspi
Location: United States

Re: [Mod + Program] Minetest-Discord relay [discordmt] [v0.1]

by philipbenr » Post

Oliver4 wrote:
Sun Jan 03, 2021 09:23
...
Please do not quote the whole original post when replying, as A) there is no need, and B) it makes the thread unnecessarily long.

User avatar
archfan7411
Member
Posts: 15
Joined: Wed Sep 26, 2018 00:37
GitHub: archfan7411
In-game: archfan

Re: [Mod + Program] Minetest-Discord relay [discordmt] [v0.1]

by archfan7411 » Post

Note: I am no longer actively updating this mod/program but will fix any reported issues.
Oliver4 wrote:
Sun Jan 03, 2021 09:23
archfan7411 wrote:
Wed Aug 28, 2019 12:53
<snip>
how do i run the relay?
The relay is comprised of two parts: a Minetest mod written in Lua, and a Discord bot written in Python. It is, last I checked, nearly impossible to write a direct Discord relay with Minetest's current Lua API due to how websockets work. As such, the mod discordmt communicates with the program discordmt, which in turn communicates with Discord.

First, you need a Python installation and pip. If you're on Linux, consult your package manager.
For Windows, go to the Python downloads page and acquire the installer. Once it is downloaded, run the installer. It is very important that during installation, you check the "Add to PATH" box. Without this you will find it difficult to run discordmt or any other Python programs from the command prompt.

When installation is complete, open a command prompt (Windows) or terminal (any other OS) and type

Code: Select all

pip install discord.py
(Exact command may vary, try variations such as "pip3", "python -m pip", "python3 -m pip" in place of "pip")
This should successfully install discord.py, the Python module used to communicate with Discord.

Beyond that, my original post you quoted should still be accurate for setting up the mod/program itself. Feel free to reply if you have any issues, and I hope discordmt is useful!

BlueR23
Member
Posts: 26
Joined: Thu Jul 23, 2020 15:34
GitHub: DiamondPlane
Location: Behind you

Re: [Mod + Program] Minetest-Discord relay [discordmt] [v0.1]

by BlueR23 » Post

Hi! Can someone help me? When I run command python3 server.py it says "Missing access"

User avatar
archfan7411
Member
Posts: 15
Joined: Wed Sep 26, 2018 00:37
GitHub: archfan7411
In-game: archfan

Re: [Mod + Program] Minetest-Discord relay [discordmt] [v0.1]

by archfan7411 » Post

BlueR23 wrote:
Mon Jan 11, 2021 17:39
Hi! Can someone help me? When I run command python3 server.py it says "Missing access"
Ensure that the channel ID you provided in the configuration file is correct, and ensure that the bot has access to the channel. If you're uncertain on how to get the channel ID: go into Discord Settings > Appearance > enable Developer Mode. Then, rightclick the channel in the list and select Copy ID.

BlueR23
Member
Posts: 26
Joined: Thu Jul 23, 2020 15:34
GitHub: DiamondPlane
Location: Behind you

Re: [Mod + Program] Minetest-Discord relay [discordmt] [v0.1]

by BlueR23 » Post

archfan7411 wrote:
Fri Jan 15, 2021 03:01
BlueR23 wrote:
Mon Jan 11, 2021 17:39
Hi! Can someone help me? When I run command python3 server.py it says "Missing access"
Ensure that the channel ID you provided in the configuration file is correct, and ensure that the bot has access to the channel. If you're uncertain on how to get the channel ID: go into Discord Settings > Appearance > enable Developer Mode. Then, rightclick the channel in the list and select Copy ID.
How do I give permissions to the discordmt?

User avatar
archfan7411
Member
Posts: 15
Joined: Wed Sep 26, 2018 00:37
GitHub: archfan7411
In-game: archfan

Re: [Mod + Program] Minetest-Discord relay [discordmt] [v0.1]

by archfan7411 » Post

BlueR23 wrote:
Fri Jan 29, 2021 08:44
How do I give permissions to the discordmt?
Ensure that the bot is able to talk in the channel you want it relayed to; i.e. that it has the send and read messages privileges.

If you're still having issues, could you post your relay.conf here? (With the token redacted, of course.)

User avatar
archfan7411
Member
Posts: 15
Joined: Wed Sep 26, 2018 00:37
GitHub: archfan7411
In-game: archfan

Re: [Mod + Program] Minetest-Discord relay [discordmt] [v0.1]

by archfan7411 » Post

discordmt has received a few new commits, including a fix from luk3yx to remove translation strings (as seen in join/leave messages for some users), and also better functionality for periods when the server is offline - specifically,
- !status and !cmd will now tell the user if the server is down
- !login can be used to queue a login attempt while the server is down, to be executed once the server goes up

A minor fix was also implemented that sets the debug level properly for logging Discord messages. None of these are breaking changes.

Thank you for using discordmt!

User avatar
amelaye
Member
Posts: 32
Joined: Sun Jun 14, 2020 10:47
GitHub: amelaye
Contact:

Re: [Mod + Program] Minetest-Discord relay [discordmt] [v0.1]

by amelaye » Post

I got an issue launching the program :

ubuntu@ns3209760:~/discordmt$ ./server.py
Traceback (most recent call last):
File "/home/ubuntu/discordmt/./server.py", line 45, in <module>
bot = commands.Bot(command_prefix=prefix)
TypeError: BotBase.__init__() missing 1 required keyword-only argument: 'intents'
My server : 188.165.239.63:30000 - My website : http://minetest.amelieonline.net

User avatar
archfan7411
Member
Posts: 15
Joined: Wed Sep 26, 2018 00:37
GitHub: archfan7411
In-game: archfan

Re: [Mod + Program] Minetest-Discord relay [discordmt] [v0.1]

by archfan7411 » Post

amelaye wrote:
Mon Oct 31, 2022 11:52
I got an issue launching the program :

ubuntu@ns3209760:~/discordmt$ ./server.py
Traceback (most recent call last):
File "/home/ubuntu/discordmt/./server.py", line 45, in <module>
bot = commands.Bot(command_prefix=prefix)
TypeError: BotBase.__init__() missing 1 required keyword-only argument: 'intents'
This has been fixed by a PR from luk3yx, updating to discord.py v2.

The documentation will be updated sometime, but in the meantime, you need to update your discordmt and then enable the Message Content intent in the Discord developer dashboard for your bot.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 9 guests