Popular Post Mr.Loki Posted June 22, 2018 Popular Post Share Posted June 22, 2018 (edited) OK so after many requests from people asking me to install discord bots to their servers I have decided to make the simplest tutorial on setting up a bot for your servers. [NOTE]: THIS IS A VPS TUTORIAL. IF YOUR SERVER ISN'T RUNNING ON A VPS THIS WILL NOT WORK FOR YOU UNLESS YOU UNDERSTAND HOW NODE.JS WORKS. Part 1: Bot creation Spoiler Go to this site. Then you will need to login with your discord account. Click Applications to the left then click New Application. Spoiler Then give your bot a name and hit Create Spoiler After creating the app click on the Bot button to the left then select Add Bot Spoiler The app will be converted to a bot now we will copy the token and store it somewhere for later use. Spoiler Do not share this token with anyone else they will be able to access your bot. Now we need to invite the bot to join our discord server. To the left click on OAuth2 then scroll down to scopes and select bot then for bot permissions a good choice would be administrator. Next hit the copy button and paste that link into a new tab in your browser. Spoiler If done correctly you should get to this page Spoiler Next select your server from the drop down list and authorize the bot to the server you want it in If done correctly you will now see the bot offline in your server: Spoiler Part 2: Files Configuration Spoiler Firstly you will need the mo_sockets module installed on your server. Now we need to download the files needed to get the bot running. Spoiler Now extract those files and you should get a folder called "mta-discord-bot-master" In that folder we will rename the 2 folders called mta and src Rename mta to [Discord] and src to Discordbot. Upload the [Discord] folder to your resources folder in your server. Spoiler open the discord resource folder and edit the config.xml. Set the name of the channel to the name of the channel you want your bot to speak in Set the passphrase to anything you want <discord> <channel>name-of-your-channel</channel> <passphrase>equal-to-the-server-passphrase</passphrase> <hostname>localhost</hostname> <port>8100</port> </discord> Now upload the Discordbot folder to somewhere in your VPS. I uploaded to the same folder that my server is in for easy access. Spoiler Rename the example.config.json file to config.json and open it { "port": 8100, "passphrase": "key", "guild": "guild.id", "bots": [{ "channel": "channel.name", "token": "bot.token" }] } Set the passphrase to the same as your discord resource passphrase we set earlier. Your guild id is located in your server settings > widgets Spoiler Set the channel to the same as the channel you set earlier. This is where the bot will read messages. Input the token we got earlier when we created the bot. Spoiler Part 3: SSH commands Spoiler Now that we have everything setup and ready here comes the fun part Login to your VPS's console and install node.js Here's a site containing different OS and how to install nodejs on those systems. Once it's installed perform these commands to check if you have node installed correctly along with npm "npm -v" and "node -v" Spoiler Now that we have them installed we need to install process manager 2 aka pm2 To install pm2 we run this command "npm install pm2 -g" to make sure it's installed do a version check like we did with npm and node Navigate to your Discordbot directory with the command "cd path/to/folder" Now that we are in the Discordbot directory we run the command "ls" to list the items in that directory. Spoiler Now we use the command "npm install" to install all discord modules needed for the bot. Listed in the directory we can see app.js which we must run with pm2 so we use the command "pm2 start app.js" Spoiler Make sure the bot is running correctly by checking the logs on the app by doing "pm2 logs app" You should now see these messages: And you will now see your bot online in the server Now all that's left to do is to start the discord resource in your server and once you do the bot will test it's connection to the discord by sending a message back and forth in the channel you set the bot That should be all now go have fun annoying players in your server. Some feedback would be appreciated Good luck Edited December 10, 2019 by Mr.Loki Adjusted the tutorial to the new site layout. ? 12 2 Link to comment
Tails Posted June 22, 2018 Share Posted June 22, 2018 Very nice Loki! Hopefully this will help out everyone who needs help setting this whole thing up. It's not an easy thing to do if you're completely new to all of this. 1 Link to comment
Storm-Hanma Posted June 23, 2018 Share Posted June 23, 2018 (edited) Well mostly don't know about this they think it will work from discord without vps but by this tutoring they will know how to add discord for there server thanks for sharing this tutorial help full ! Meanwhile you had used connecting instead of adding Edited June 23, 2018 by Khadeer143 1 Link to comment
Equis Posted July 3, 2018 Share Posted July 3, 2018 @Mr.Loki wouldn't this work on your local server? only on a VPS? Link to comment
Mr.Loki Posted July 3, 2018 Author Share Posted July 3, 2018 @Equis Yes it can work on a local server. Pretty much the same steps. I mentioned VPS because i know some people have their server based on slots and not a VPS. Link to comment
Equis Posted July 3, 2018 Share Posted July 3, 2018 4 hours ago, Mr.Loki said: @Equis Yes it can work on a local server. Pretty much the same steps. I mentioned VPS because i know some people have their server based on slots and not a VPS. Thanks for the respond! Link to comment
Layla Posted July 4, 2018 Share Posted July 4, 2018 Can anyone give me an example for sending a command from Discord to MTA. E.G: !ban random123 reason123 !onlineplayers Btw thank you in advance if anyone could reply. Link to comment
Mr.Loki Posted July 4, 2018 Author Share Posted July 4, 2018 @JamesB You will need to modify the onDiscordPacket event at line 75 in the discord-events resource. Link to comment
Layla Posted July 5, 2018 Share Posted July 5, 2018 5 hours ago, Mr.Loki said: @JamesB You will need to modify the onDiscordPacket event at line 75 in the discord-events resource. Could you enlighten it, because I don't understand why I should modify that event? Link to comment
Mr.Loki Posted July 5, 2018 Author Share Posted July 5, 2018 14 hours ago, JamesB said: Could you enlighten it, because I don't understand why I should modify that event? That event captures every thing that happens in the discord server it is connected to. By monitoring the packed and payload parameters you can see what gets sent to the event. You can monitor it by using the iprint function. Link to comment
xFroxDz Posted April 10, 2020 Share Posted April 10, 2020 any tutorial for a normal server? [Opg] open game panel Link to comment
Storm-Hanma Posted April 10, 2020 Share Posted April 10, 2020 9 minutes ago, xFroxDz said: any tutorial for a normal server? [Opg] open game panel Install of mta sa server in ogp ? Link to comment
xFroxDz Posted April 10, 2020 Share Posted April 10, 2020 n a host selling servers (ogp system) Link to comment
Storm-Hanma Posted April 10, 2020 Share Posted April 10, 2020 YouTube have many tutorials on installing mta sa on ogp panel Link to comment
xFroxDz Posted April 10, 2020 Share Posted April 10, 2020 i mean bro i dont have vps and i bought a server a guy had vps selling servers u got it? gimme ur discord Link to comment
Storm-Hanma Posted April 10, 2020 Share Posted April 10, 2020 1 minute ago, xFroxDz said: i mean bro i dont have vps and i bought a server a guy had vps selling servers u got it? gimme ur discord Storm-Hanma#9704 Link to comment
WASSIm. Posted May 3, 2020 Share Posted May 3, 2020 (edited) Thank you for this TUT but you forget to show how to setup npm. Please anyone where i can get (packet) and (payload) TUT and how to use it Or something like https://wiki.multitheftauto.com/wiki/Resource:Irc Edited May 3, 2020 by WASSIm. Link to comment
Deebs Posted May 5, 2020 Share Posted May 5, 2020 It gives me this error when i start the bot, or type something in the cmd (node:6364) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or B uffer.from() methods instead. Link to comment
Recommended Posts