Bot Discord: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "400px|thumb|right|Discord Bot for MTA:SA This resource is designed to connect an MTA:SA server with a Discord server. This page is always updated for the latest bot version! '''Status''': Open Source & Work in Progress '''Github Repository''': https://github.com/Ahmed-Ly/botdiscord '''Current Version''': 1.4.0 = Features = Send and receive messages between Discord and MTA:SA Execute admin commands via Discord Support for sending server n...")
 
No edit summary
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
<pageclass class="resource" subcaption="Resource"></pageclass>
[[Image:DiscordBot.png|400px|thumb|right|Discord Bot for MTA:SA]]
[[Image:DiscordBot.png|400px|thumb|right|Discord Bot for MTA:SA]]


Line 8: Line 10:


'''Github Repository''': https://github.com/Ahmed-Ly/botdiscord
'''Github Repository''': https://github.com/Ahmed-Ly/botdiscord
'''community''': https://community.multitheftauto.com/index.php?p=resources&s=details&id=18961


'''Current Version''': 1.4.0
'''Current Version''': 1.4.0
Line 62: Line 67:


discordia or discord.py library on the server.
discordia or discord.py library on the server.
Additional dependencies: Install discord.py, Flask, and requests using:
pip install discord.py Flask requests


= Troubleshooting =
= Troubleshooting =


Ensure the bot token is correct in config.lua.
Ensure the bot token is correct in config.ini.


Verify that the bot has permission to send messages in the required channel.
Verify that the bot has permission to send messages in the required channel.


Use /debugscript 3 to monitor any errors within MTA.
Use /debugscript 3 to monitor any errors within MTA.
= Notes =
Ensure MTA is correctly configured in the script and that you have updated credentials such as username, password, host, and port to match your MTA server settings.


[[Category:Resources]]
[[Category:Resources]]

Revision as of 21:21, 20 February 2025

Discord Bot for MTA:SA

This resource is designed to connect an MTA:SA server with a Discord server.

This page is always updated for the latest bot version!

Status: Open Source & Work in Progress

Github Repository: https://github.com/Ahmed-Ly/botdiscord

community: https://community.multitheftauto.com/index.php?p=resources&s=details&id=18961


Current Version: 1.4.0

Features

Send and receive messages between Discord and MTA:SA

Execute admin commands via Discord

Support for sending server notifications to a Discord channel

Installation Guide

Download the files from the link above.

Place the discord-bot folder inside the resources folder in MTA:SA.

Update mtaserver.conf to add the resource to the list.

Add the bot token details in config.lua.

Start the server and use the command /start yourresourcename.

Usage

1. Sending Messages from Discord to MTA

When a message is sent in the designated Discord channel, it will automatically appear in-game.

2. Executing Admin Commands from Discord

Admins in Discord can use the following command:

!kick playerName reason

and the player will be kicked from the server.

3. Sending Notifications from MTA to Discord

When a new player joins, a notification will be sent to the designated Discord channel:

addEventHandler("onPlayerJoin", root, function() local playerName = getPlayerName(source) sendDiscordMessage("" .. playerName .. " has joined the server!") end)


Requirements

MTA:SA server running version 1.6.0 or later.

A Discord bot activated with a token.

discordia or discord.py library on the server.

Additional dependencies: Install discord.py, Flask, and requests using:

pip install discord.py Flask requests

Troubleshooting

Ensure the bot token is correct in config.ini.

Verify that the bot has permission to send messages in the required channel.

Use /debugscript 3 to monitor any errors within MTA.

Notes

Ensure MTA is correctly configured in the script and that you have updated credentials such as username, password, host, and port to match your MTA server settings.