Post by karageek on Dec 26, 2021 14:28:32 GMT -5
I want to start this off by saying I am not a coder at all and there are probably much better ways to make this bot. Use this bot at YOUR OWN RISK.
Long Post but is important I recommend you read through it atleast once completely BEFORE you start doing anything.
This bot DOES NOT replace the ASM Discord bot and is designed to work in conjunction with it.
I followed a few tutorials on how to make a javascript discord bot then adapted them to do what I wanted. I STRONGLY recommend you watch all the videos in this tutorial to fully understand how javascript bots work. I followed this series to a very large degree on creating my bot. Major congrats to Tyler for their series.
Discord V13 Tutorial by Tyler Potts.
Disclaimer out of the way here's what this bot does, it is very very simple.
This bot will send commands to the ASM Discord bot to start, stop, backup etc for server clusters. I have tested this as much as I can but there are possible bugs still. I currently have 36 ARK servers spread over 3 instances of ASM. This the creation of 3 additional ASM discord bots to use.
Also, this is NOT a ready to use bot you WILL have to modify the code in order to use it. I will do my best to explain what needs changes.
Important things that should not be changed.
I have setup a delay between commands of 4 seconds (expressed at 4000ms) in the code. I don't recommend setting this ANY lower as I have had occasional errors from ASM Discord bot where it was still processing the previous command. You may need to even increase the delay.
I set this bot up to use the new discord / slash command system. This was to future proof it because starting in April 2022 discord is making a bunch of changes to how bots work. Eventually all bots will need to use these / slash commands. There needs to be a warning regarding slash commands as well, if you allow the use of / slash commands on your server these commands will appear to ANYONE in ANY channel who has perms.
That said they SHOULD NOT actually work on the ASM Discord bot except in the designated channel. This bot will need perms to send messages in the same channel as the ASM Bot. I cannot guarantee permissions as I have only a very basic understanding of how to code them.
First, you will need to very similarly follow the tutorial/instructions that Bletch made for his Bot to setup Relay Bot. You have to setup a completely separate bot. After you have done that and invited the bot to the server you will then need to get some information from the Bot APP page the same as you did for ASM's Bot.
Now for the nitty gritty. It is **VERY VERY** important that as you make changes you do not break the spacing and punctuation. A missplaced or missing (;{ will completely break the bot. I use Visual Studio Code, 100% free, for all editing and I recommend you use that or if you are already a coder your editor of choice.
There are very likely more server lines than you will need so you will need to remove some, Take care when deleting lines.
To download the code go to github.com/Karageek/ASM-Discord-Relay-Bot
Click the Green Code button and choose download ZIP.
Unzip the code on the system and into the folder where u plan to run it. It can be run anywhere it does NOT have to be on your ARK server, though I advise to do so to keep things organized. It uses minimal resources, ~100mb of ram.
Alternatively you can download the file directly here. One Drive Share Download
1) Open the .env file in your editor of choice.
After creating a new bot for Relay Bot, You need to copy the Token on the BOT page. Copy paste that into the .env file where it says TOKEN=salkJUHoILjOUIYH (that is example)
2) Right Click your Discord Server icon on the left side of the discord APP and Click Copy ID, if you do not see this as an option, you must then go to your discord settings, the advanced tab, and turn on Developer Mode. Paste this ID in the .env file after GUILD_ID=324534251 (that is example) Guild equals Server in Discord Language.
3) Open the bot.js file in your editor of choice.
Next Choose the channel that the ASM Discord bot currently resides, and right click copy ID (the channel ID).
Paste that inbetween teh quotes on Line 55 where it says // client.channels.cache.get("Channel ID Here").send("*ASM Relay Bot Online*");
4) The next parts are more time consuming and will depend entirely on how many servers you have and which Bulk Bot commands you wish to use.
open asmbackup.js in your editor of choice.
Starting at about line 35 where it says interaction.reply("asm!backup abermod");
You will need to change where it says *abermod* to the Alias name of your server, you will see the commands replicated below. Change each Alias for each of your servers.
The way these commands are structured was the easist way I found and you must use the same structure for them to work. You will see the sleep(4000) lines that represents the delay between messages. In my testing I found it slightly exceeded that time which was fine.
In discord once you trigger these commands they will run completely there is no way to stop them, until the list is completed, so be cautious when testing and using them.
5) You will need to repeat this process for all the commands listed. In my code template I uploaded the exact code I am using for my servers. If you have multiple instances of ASM, you will need to use a different bot and change the prefix trigger for each of those bots. I have 3 instances and so changed the trigger for each and grouped them how I wanted. Delete any duplicate .js files that you don't need. I used the asm!info and xsm! and psm!, for each asm instance and bot, commands as my test bed since it doesn't actually do anything to the server.
6) To actually run the bot you will have to install node.js to the Windows server/computer it is going to be run on. If you run this on cloud hosting or some other OS you will have to find instructions for those yourself as I don't know the specifics. Node.js found here nodejs.org/en/download/ I choose Windows Install (.msi) 64 bit.
7) Use defaults during install. On one page it asks about other tools and is NOT checked by default you don't need that, leave it unchecked.
8) After installation no reboot should be required. open file explorer go to the folder you have Relay bot files. Then in an empty space in that folder SHIFT-RIGHT-CLICK you should see a popup that shows Open PowerShell Window Here. Click that and after it opens type "npm run dev" No quotes.
This should launch the bot and it should then Display a few lines with One line saying "ASM Relay online" and the last line "Sucessfully registered commands locally".
Additionally, if the bot has perms it should post same "ASM Relay Bot Online." into the channel you setup in step 3.
9) You have to leave the powershell window running but you can minimize it.
10) You will need to now add the BOT's ID to the ASM Discord Bot Whitelist. I strongly recommend you use the whitelist and NOT allow all bots. Right Click the bot in discord and click COPY ID.
Go to ASM, Click the GEAR Icon, scroll down to Discord Bot section.
Click the Plus sign next to Bot Whitelist, then click in the box and paste the ID #.
Then you are ready to test the bot in discord.
11) in the channel where both the Relay bot and ASM Discord bot are running and authorized type /asm- This should show you a list of the / commands as defined in their respective .js files. I recommend using the /asm-info for testing. You can type the command fully and/or use arrow keys to select the command you want.
For questions or comments feel free to contact me on Discord AshleyLee#1988 You can also email me if you want ashley @ karasworlds.com
You are welcome to modify, share this code as you see fit. It is licensed under:
ARK ASM Relay Bot © 2021 by Kara's Worlds is licensed under Attribution-NonCommercial 4.0 International.
Additionally ARK ASM Relay Bot is covered under GNU GNPV3 License.
Long Post but is important I recommend you read through it atleast once completely BEFORE you start doing anything.
This bot DOES NOT replace the ASM Discord bot and is designed to work in conjunction with it.
I followed a few tutorials on how to make a javascript discord bot then adapted them to do what I wanted. I STRONGLY recommend you watch all the videos in this tutorial to fully understand how javascript bots work. I followed this series to a very large degree on creating my bot. Major congrats to Tyler for their series.
Discord V13 Tutorial by Tyler Potts.
Disclaimer out of the way here's what this bot does, it is very very simple.
This bot will send commands to the ASM Discord bot to start, stop, backup etc for server clusters. I have tested this as much as I can but there are possible bugs still. I currently have 36 ARK servers spread over 3 instances of ASM. This the creation of 3 additional ASM discord bots to use.
Also, this is NOT a ready to use bot you WILL have to modify the code in order to use it. I will do my best to explain what needs changes.
Important things that should not be changed.
I have setup a delay between commands of 4 seconds (expressed at 4000ms) in the code. I don't recommend setting this ANY lower as I have had occasional errors from ASM Discord bot where it was still processing the previous command. You may need to even increase the delay.
I set this bot up to use the new discord / slash command system. This was to future proof it because starting in April 2022 discord is making a bunch of changes to how bots work. Eventually all bots will need to use these / slash commands. There needs to be a warning regarding slash commands as well, if you allow the use of / slash commands on your server these commands will appear to ANYONE in ANY channel who has perms.
That said they SHOULD NOT actually work on the ASM Discord bot except in the designated channel. This bot will need perms to send messages in the same channel as the ASM Bot. I cannot guarantee permissions as I have only a very basic understanding of how to code them.
First, you will need to very similarly follow the tutorial/instructions that Bletch made for his Bot to setup Relay Bot. You have to setup a completely separate bot. After you have done that and invited the bot to the server you will then need to get some information from the Bot APP page the same as you did for ASM's Bot.
Now for the nitty gritty. It is **VERY VERY** important that as you make changes you do not break the spacing and punctuation. A missplaced or missing (;{ will completely break the bot. I use Visual Studio Code, 100% free, for all editing and I recommend you use that or if you are already a coder your editor of choice.
There are very likely more server lines than you will need so you will need to remove some, Take care when deleting lines.
To download the code go to github.com/Karageek/ASM-Discord-Relay-Bot
Click the Green Code button and choose download ZIP.
Unzip the code on the system and into the folder where u plan to run it. It can be run anywhere it does NOT have to be on your ARK server, though I advise to do so to keep things organized. It uses minimal resources, ~100mb of ram.
Alternatively you can download the file directly here. One Drive Share Download
1) Open the .env file in your editor of choice.
After creating a new bot for Relay Bot, You need to copy the Token on the BOT page. Copy paste that into the .env file where it says TOKEN=salkJUHoILjOUIYH (that is example)
2) Right Click your Discord Server icon on the left side of the discord APP and Click Copy ID, if you do not see this as an option, you must then go to your discord settings, the advanced tab, and turn on Developer Mode. Paste this ID in the .env file after GUILD_ID=324534251 (that is example) Guild equals Server in Discord Language.
3) Open the bot.js file in your editor of choice.
Next Choose the channel that the ASM Discord bot currently resides, and right click copy ID (the channel ID).
Paste that inbetween teh quotes on Line 55 where it says // client.channels.cache.get("Channel ID Here").send("*ASM Relay Bot Online*");
4) The next parts are more time consuming and will depend entirely on how many servers you have and which Bulk Bot commands you wish to use.
open asmbackup.js in your editor of choice.
Starting at about line 35 where it says interaction.reply("asm!backup abermod");
You will need to change where it says *abermod* to the Alias name of your server, you will see the commands replicated below. Change each Alias for each of your servers.
The way these commands are structured was the easist way I found and you must use the same structure for them to work. You will see the sleep(4000) lines that represents the delay between messages. In my testing I found it slightly exceeded that time which was fine.
In discord once you trigger these commands they will run completely there is no way to stop them, until the list is completed, so be cautious when testing and using them.
5) You will need to repeat this process for all the commands listed. In my code template I uploaded the exact code I am using for my servers. If you have multiple instances of ASM, you will need to use a different bot and change the prefix trigger for each of those bots. I have 3 instances and so changed the trigger for each and grouped them how I wanted. Delete any duplicate .js files that you don't need. I used the asm!info and xsm! and psm!, for each asm instance and bot, commands as my test bed since it doesn't actually do anything to the server.
6) To actually run the bot you will have to install node.js to the Windows server/computer it is going to be run on. If you run this on cloud hosting or some other OS you will have to find instructions for those yourself as I don't know the specifics. Node.js found here nodejs.org/en/download/ I choose Windows Install (.msi) 64 bit.
7) Use defaults during install. On one page it asks about other tools and is NOT checked by default you don't need that, leave it unchecked.
8) After installation no reboot should be required. open file explorer go to the folder you have Relay bot files. Then in an empty space in that folder SHIFT-RIGHT-CLICK you should see a popup that shows Open PowerShell Window Here. Click that and after it opens type "npm run dev" No quotes.
This should launch the bot and it should then Display a few lines with One line saying "ASM Relay online" and the last line "Sucessfully registered commands locally".
Additionally, if the bot has perms it should post same "ASM Relay Bot Online." into the channel you setup in step 3.
9) You have to leave the powershell window running but you can minimize it.
10) You will need to now add the BOT's ID to the ASM Discord Bot Whitelist. I strongly recommend you use the whitelist and NOT allow all bots. Right Click the bot in discord and click COPY ID.
Go to ASM, Click the GEAR Icon, scroll down to Discord Bot section.
Click the Plus sign next to Bot Whitelist, then click in the box and paste the ID #.
Then you are ready to test the bot in discord.
11) in the channel where both the Relay bot and ASM Discord bot are running and authorized type /asm- This should show you a list of the / commands as defined in their respective .js files. I recommend using the /asm-info for testing. You can type the command fully and/or use arrow keys to select the command you want.
For questions or comments feel free to contact me on Discord AshleyLee#1988 You can also email me if you want ashley @ karasworlds.com
You are welcome to modify, share this code as you see fit. It is licensed under:
ARK ASM Relay Bot © 2021 by Kara's Worlds is licensed under Attribution-NonCommercial 4.0 International.
Additionally ARK ASM Relay Bot is covered under GNU GNPV3 License.