diff --git a/.gitignore b/.gitignore index c392902..1e652ab 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ node_modules/* # Testing/dev related *_test.js dev-*.js -commands/debug.js # Logs logs/* diff --git a/commands/debug.js b/commands/debug.js new file mode 100644 index 0000000..58c53d5 --- /dev/null +++ b/commands/debug.js @@ -0,0 +1,39 @@ +const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js'); +const CommandOptions = require('../util/CommandOptionTypes').CommandOptionTypes; + +module.exports = { + name: "debug", + debug: true, + global: false, + description: "debugging...", + usage: "", + permissions: { + channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"], + member: [], + }, + options: [{ + name: 'sync-logs', + description: 'download the Nitrado logs and run checks now', + value: 'sync-logs', + type: CommandOptions.SubCommand, + }], + SlashCommand: { + /** + * + * @param {require("../structures/QuarksBot")} client + * @param {import("discord.js").Message} message + * @param {string[]} args + * @param {*} param3 + */ + run: async (client, interaction, args, { GuildDB }) => { + if (!client.config.Admins.includes(interaction.member.user.id)) return interaction.send({ content: 'Only developers can access this command.', flags: (1 << 6) }) + + if (args[0].name == 'sync-logs') { + if (client.processingLogs) return interaction.send({ content: 'The Nitrado logs are already being processed at the moment...', flags: (1 << 6) }); + interaction.send({ content: 'Downloading and processing Nitrado logs now...', flags: (1 << 6) }); + return client.logsUpdateTimer(client); + } + }, + }, + Interactions: {} +} \ No newline at end of file diff --git a/structures/DayzRBot.js b/structures/DayzRBot.js index 95e6a55..ca6e5f2 100644 --- a/structures/DayzRBot.js +++ b/structures/DayzRBot.js @@ -42,6 +42,7 @@ class DayzRBot extends Client { this.arIntervalId; // Interval for auto-restart functions this.playerSessions = new Map(); this.alarmPingQueue = {}; + this.processingLogs = false; this.autoRestartInit(); this.LoadCommandsAndInteractionHandlers(); this.LoadEvents(); @@ -236,6 +237,8 @@ class DayzRBot extends Client { } async logsUpdateTimer(c) { + if (this.processingLogs) return; // Process is already running, wait till next scheduled time. + this.processingLogs = true; let t = new Date(); // c.log(`...Logs Tick - ${t.getHours()}:${t.getMinutes()}:${t.getSeconds()}...`); c.activePlayersTick++; @@ -250,6 +253,7 @@ class DayzRBot extends Client { if (c.activePlayersTick == 12) await HandleActivePlayersList(c, c.config.GuildID); }) }); + this.processingLogs = false; } async connectMongo(mongoURI, dbo) {