Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 2 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 (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-08-09T16:40:32.000Z (over 1 year ago)
- Last Synced: 2023-08-09T18:27:16.953Z (over 1 year ago)
- Topics: discord, discord-bot, discord-js, javascript, lua, mtasa, mtasa-resource, multi-theft-auto
- Language: JavaScript
- Homepage:
- Size: 106 KB
- Stars: 47
- Watchers: 6
- Forks: 35
- Open Issues: 1
-
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
```xmlname-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).
>
> ![image](https://github.com/botder/mtasa-discord-bot/assets/38703318/f0df9eb7-cc40-44f6-8b22-3a7e38cfbc0d)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/applicationsThen 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.