From caf43aac4e6768c1d706df7f2dea8576aa2f73eb Mon Sep 17 00:00:00 2001 From: SowinskiBraeden Date: Fri, 8 Nov 2024 13:49:54 -0800 Subject: [PATCH] update/add commands to check+reply nitrado credentials status --- commands/server.js | 37 ++++++++++++++++++++++++++++++++++++- package.json | 2 +- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/commands/server.js b/commands/server.js index c8e5396..f4dead6 100644 --- a/commands/server.js +++ b/commands/server.js @@ -26,6 +26,18 @@ module.exports = { value: "disconnect", type: CommandOptions.SubCommand, }, + { + name: "credentials-status", + description: "Check the status of your Nitrado Credentials", + value: "credentials-status", + type: CommandOptions.SubCommand, + }, + { + name: "retry-credentials", + description: "If your credentials are marked as FAILED, try retreiving Nitrado logs again.", + value: "retry-credentials", + type: CommandOptions.SubCommand, + }, { name: "ban-player", description: "Ban a player from the DayZ server", @@ -180,7 +192,30 @@ module.exports = { if (!client.exists(GuildDB.Nitrado) || !client.exists(GuildDB.Nitrado.ServerID)) return interaction.send({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Red).setDescription(`**Notice:**\nThis Discord guild has not been configured with a Nitrado DayZ server. To configure your guild, use `)] }); - if (args[0].name == 'ban-player') { + if (args[0].name == 'credentials-status') { + + const notice = GuildDB.Nitrado.Status == NitradoCredentialStatus.OK ? "Your provided Nitrado Credentials are working correctly, logs are being checked." : "Your provided Nitrado Credentials are not working. They may be incorrect, or your server may be down. Ensure your DayZ server is online, and try to initialize your server again and verify your credentials are correct." + const statusEmbed = new EmbedBuilder() + .setColor(client.config.Colors.Green) + .setTitle("Nitrado Credentials Status") + .setDescription(`**Status**\n> \`${GuildDB.Nitrado.Status}\`\n> ${notice}`); + + return interaction.send({ embeds: [statusEmbed] }); + + } else if (args[0].name == 'retry-credentials') { + + client.dbo.collection("guilds").updateOne({"server.serverID": GuildDB.serverID}, {$set:{"Nitrado.Status": NitradoCredentialStatus.OK}}, (err, _) => { + if (err) return client.sendInternalError(interaction, err); + }); + + const updatedEmbed = new EmbedBuilder() + .setColor(client.config.Colors.Green) + .setTitle("Updated Nitrado Credentials Status") + .setDescription(`**Success**\n> Successfully retrying your existing Nitrado Credentials to check DayZ logs.`); + + return interaction.send({ embeds: [updatedEmbed] }); + + } else if (args[0].name == 'ban-player') { let data = await BanPlayer(GuildDB.Nitrado, client, args[0].options[0].value); diff --git a/package.json b/package.json index 746ae6f..1aa8f0c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dayzr-bot", - "version": "13.3.3", + "version": "13.3.4", "description": "A General Purpose Discord Bot for DayZ Nitrado Servers.", "main": "index.js", "nodemonConfig": {