diff --git a/README.md b/README.md index 43885da..28cf3d9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,16 @@ # CommanderBot ## What does it do? CommanderBot is an updated and improved version of [PhoenixAPI-Bot](https://github.com/Alex22sv/PhoenixAPI-Bot) which has the same commanods but the difference between both bots is that CommanderBot no longer uses message commands but slash commands. +## Features +- Get information about your exaroton account. +- List all servers in your exaroton account. +- Create an embed to automatically display the current status of your server. +- Start, stop & restart your own servers. +- Start servers that you have shared access to with your own credits. +- Get your server log or upload it to https://mclo.gs/. +- Update your server settings, like RAM, banned players & ips, whitelisted players, etc. +- Execute Minecraft commands. +- Get your server Dynamic IP (DynIP). ## Slash commands? Yes. CommanderBot will only reply through slash commands, e.g. `/help`. ![image](https://user-images.githubusercontent.com/70553543/203646292-dc042b32-d52e-43e4-a391-09e6c8a4f88c.png) @@ -36,7 +46,9 @@ Yes. CommanderBot will only reply through slash commands, e.g. `/help`. ### Starting the bot Once you have the bot on your server and added all the config to the `config.json` file, you can start the bot running the command `node main.js`. Make sure the path is set to the `CommanderBot` folder. You'll see this message when the bot is online: + ![image](https://user-images.githubusercontent.com/70553543/203649611-90e43061-8af3-49dc-af99-412406914933.png) + And done! The bot is set up and online. You can now run `/help` to get the list of commands. ## Support diff --git a/package-lock.json b/package-lock.json index d38d6bc..4fce3d5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@discordjs/rest": "^0.4.1", "discord-api-types": "^0.33.1", "discord.js": "^13.8.1", - "exaroton": "^1.8.0" + "exaroton": "^1.9.0" } }, "node_modules/@discordjs/builders": { @@ -319,11 +319,10 @@ } }, "node_modules/exaroton": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/exaroton/-/exaroton-1.8.0.tgz", - "integrity": "sha512-k6RbNkbzbEitJT3IjRGaIsqMC7H4XgIzYA4BOPGV9OAEpVsg01CUaJiB6NiApczoWrdA0uxOkVP3v6YnrOF4aQ==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/exaroton/-/exaroton-1.9.0.tgz", + "integrity": "sha512-zVdvX297AHiX8Tx2BLBAGeVaGl3uu14x2Nfy8Ht2mvXYhNMftvSH/cm5aj0IU+dhFs6iDBVPX8wQ5LwLh8uZ1A==", "dependencies": { - "form-data": "^3.0.1", "got": "^11.8.2", "ws": "^7.4.5" }, @@ -331,19 +330,6 @@ "node": ">=12.0.0" } }, - "node_modules/exaroton/node_modules/form-data": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", - "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/exaroton/node_modules/ws": { "version": "7.5.8", "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.8.tgz", @@ -864,25 +850,14 @@ } }, "exaroton": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/exaroton/-/exaroton-1.8.0.tgz", - "integrity": "sha512-k6RbNkbzbEitJT3IjRGaIsqMC7H4XgIzYA4BOPGV9OAEpVsg01CUaJiB6NiApczoWrdA0uxOkVP3v6YnrOF4aQ==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/exaroton/-/exaroton-1.9.0.tgz", + "integrity": "sha512-zVdvX297AHiX8Tx2BLBAGeVaGl3uu14x2Nfy8Ht2mvXYhNMftvSH/cm5aj0IU+dhFs6iDBVPX8wQ5LwLh8uZ1A==", "requires": { - "form-data": "^3.0.1", "got": "^11.8.2", "ws": "^7.4.5" }, "dependencies": { - "form-data": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", - "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - } - }, "ws": { "version": "7.5.8", "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.8.tgz", diff --git a/package.json b/package.json index 25d86b4..1bd5ca9 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,6 @@ "@discordjs/rest": "^0.4.1", "discord-api-types": "^0.33.1", "discord.js": "^13.8.1", - "exaroton": "^1.8.0" + "exaroton": "^1.9.0" } } diff --git a/src/commandDescriptions.json b/src/commandDescriptions.json index 4a26c9d..133dba1 100644 --- a/src/commandDescriptions.json +++ b/src/commandDescriptions.json @@ -15,11 +15,11 @@ "pardon": "Remove the ban of a player on your server.", "pardonip": "Remove the ban of an IP on your server.", "ram": "Get or change the RAM on your server.", - "restart": "Restart your Minecraft server. This command requires you to have the 'Server Manager' role.", + "restart": "Restart your Minecraft server.", "servers": "Get the list of servers on your exaroton account.", - "start": "Start your Minecraft server. This command requires you to have the 'Server Manager' role.", + "start": "Start your Minecraft server or one that you have shared access to.", "status": "Create an embed to display the status of your server.", - "stop": "Stop your Minecraft server. This command requires you to have the 'Server Manager' role.", + "stop": "Stop your Minecraft server.", "unwhitelist": "Remove Minecraft players from the whitelist/allowlist on your server.", "whitelist": "Add Minecraft players to the whitelist/allowlist on your server." } \ No newline at end of file diff --git a/src/commandUsages.json b/src/commandUsages.json index ebeb1ba..db69e87 100644 --- a/src/commandUsages.json +++ b/src/commandUsages.json @@ -17,7 +17,7 @@ "ram": "/ram []", "restart": "/restart .", "servers": "/servers", - "start": "/start ", + "start": "/start []", "status": "/status ", "stop": "/stop ", "unwhitelist": "/unwhitelist ", diff --git a/src/commands/start.js b/src/commands/start.js index 7e92b5d..3586510 100644 --- a/src/commands/start.js +++ b/src/commands/start.js @@ -13,19 +13,43 @@ module.exports = { option.setName('server') .setDescription('Send the server name, ID or address here.') .setRequired(true) + ) + .addStringOption(option => + option.setName('credits') + .setDescription('Use your own credits to start a server that you have shared access to.') + .setRequired(false) + .addChoices( + {name:'No', value:'false'}, + {name:'Yes', value:'true'} + ) ), async run(bot, interaction) { try{ + let account = await exarotonClient.getAccount(); let name = interaction.options.getString('server'); let serverLists = await exarotonClient.getServers(); let server = serverLists.find(server => server.name === name || server.id === name || server.address === name); - await server.start(); - const startingServerEmbed = new MessageEmbed() - .setDescription(`${loadingEmoji} Starting server **${server.name}**.`) - .setColor(embedColor) - .setTimestamp() - .setFooter({text:interaction.user.tag, iconURL:interaction.user.displayAvatarURL()}) - return interaction.reply({ embeds:[startingServerEmbed], ephemeral:false}); + let ownCredits = interaction.options.getString('credits'); + if(ownCredits == "true"){ + console.log('Starting server with own credits.'); + await server.start(true); + const startingServerEmbedOwnCredits = new MessageEmbed() + .setDescription(`${loadingEmoji} Starting server **${server.name}** using **${account.name}**'s credits.`) + .setColor(embedColor) + .setTimestamp() + .setFooter({text:interaction.user.tag, iconURL:interaction.user.displayAvatarURL()}) + return interaction.reply({ embeds:[startingServerEmbedOwnCredits], ephemeral:false}); + } else { + console.log('Starting server with owner credits'); + await server.start(false); + const startingServerEmbed = new MessageEmbed() + .setDescription(`${loadingEmoji} Starting server **${server.name}**.`) + .setColor(embedColor) + .setTimestamp() + .setFooter({text:interaction.user.tag, iconURL:interaction.user.displayAvatarURL()}) + return interaction.reply({ embeds:[startingServerEmbed], ephemeral:false}); + + } } catch(e) { console.error(`An error ocurred while running the command 'start' executed by ${interaction.user.tag}(${interaction.user.id}): ${e}`) if(e.message == "Server is not offline"){ @@ -46,6 +70,15 @@ module.exports = { .setTimestamp() .setFooter({text:interaction.user.tag, iconURL:interaction.user.displayAvatarURL()}) return interaction.reply({embeds:[serverNotFoundEmbed], ephemeral:true}); + } + if(e.message.includes("Not enough credits")){ + const notEnoughCredits = new MessageEmbed() + .setTitle('Error!') + .setDescription('The owner of that server does not have enough credits to start the server.') + .setColor(errorColor) + .setTimestamp() + .setFooter({text:interaction.user.tag, iconURL:interaction.user.displayAvatarURL()}) + return interaction.reply({embeds:[notEnoughCredits], ephemeral:true}); } else { const errorEmbed = new MessageEmbed() .setTitle('Error!')