https://github.com/botder/mtasa-discord-bot
Connects MTA:SA servers and Discord channels by sending messages/commands back and forth
https://github.com/botder/mtasa-discord-bot
discord discord-bot discord-js javascript lua mtasa mtasa-resource multi-theft-auto
Last synced: 6 months ago
JSON representation
Connects MTA:SA servers and Discord channels by sending messages/commands back and forth
- Host: GitHub
- URL: https://github.com/botder/mtasa-discord-bot
- Owner: botder
- License: isc
- Created: 2016-04-10T15:25:08.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2023-10-16T16:13:10.000Z (over 2 years ago)
- Last Synced: 2025-03-27T14:52:22.890Z (12 months ago)
- Topics: discord, discord-bot, discord-js, javascript, lua, mtasa, mtasa-resource, multi-theft-auto
- Language: JavaScript
- Homepage:
- Size: 96.7 KB
- Stars: 60
- Watchers: 5
- Forks: 42
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mta-discord-bot
Connects MTA:SA servers and Discord channels by sending messages/commands back and forth.
**Note:** The recent code update has breaking changes to your `config.json`, please replace _server_ with _guild_, thanks.
## Installation
### MTA:SA
The discord resource requires the socket module on your MTA:SA server. You can find the installation guide
and the binaries on the [MTA wiki](https://wiki.multitheftauto.com/wiki/Modules/Sockets).
The resources themselves require no special setup, you only have to edit the `discord/config.xml` to fit your setup.
The resource **discord** is responsible for message transfer between your MTA:SA server and the Discord relay.
On the other hand, **discord-events** is listening for events on the MTA:SA server to send these to the relay
through the **discord** resource.
> mta/discord/config.xml
```xml
name-of-your-channel
equal-to-the-server-passphrase
localhost
8100
```
### Relay
The relay server connects to Discord as a bot user; and starts a socket server listening for connections. I never
bothered to keep the code compatible with older releases of node.js, which might be an issue on some distributions.
The relay code needs a little preparation before you can run it. You have to run the command `npm install` in the `src`
directory to download the node.js modules required by the application. Furthermore, you have to copy the file
`src/example.config.json` to `src/config.json` and edit it to fit your setup
(the passphrase and port must be equal to the **discord** config.xml on your MTA:SA server).
You can start the relay with `node app.js`, but you should consider using [pm2](https://github.com/Unitech/pm2) to restart
the relay automatically on crashes.
> src/example.config.json
```json
{
"port": 8100,
"passphrase": "key",
"guild": "guild.id",
"bots": [{
"channel": "channel.name",
"token": "bot.token"
}]
}
```
## Notes
### Discord Bots
> **Note**
> Make sure your bot account has the `MESSAGE CONTENT INTENT` permission, because otherwise you will only see empty messages coming from Discord (in MTA:SA).
>
> 
This application doesn't magically add your bot(s) to your guild(s). You (better said: the guild owner) have to authorize every bot user. Navigate to your bot application on the following page and note the client id:
> https://discord.com/developers/applications
Then continue to replace the `client_id` field in the URL below and navigate to that page:
> https://discord.com/api/oauth2/authorize?scope=bot&permissions=0&client_id=
Proceed by authorizing the bot for the guild of your choice and you're done.