From 9c4a57a098ba1050c22134574910abf7d46619f7 Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Tue, 24 Jun 2025 03:35:54 +0200 Subject: [PATCH 1/5] Assign sliced string --- commands/admin/update.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/admin/update.js b/commands/admin/update.js index 7de9db0..ad79b11 100644 --- a/commands/admin/update.js +++ b/commands/admin/update.js @@ -27,7 +27,7 @@ module.exports = { let commitCount = stdout.split(/\r\n|\r|\n/).length - 1 sendText = `${sendText}\n\nLatest commits (${commitCount}):\n${stdout}` if(sendText.length >= 2000){ - sendText.slice(1955) + sendText = sendText.slice(1955) sendText = `${sendText}\n... Message is too long to show everything` } message.channel.send(sendText) From 24e019e34f34520a2a2a099cfcba20aeaf4294ae Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Tue, 24 Jun 2025 03:38:24 +0200 Subject: [PATCH 2/5] Add latest git hash to botinfo command --- commands/admin/update.js | 2 ++ commands/info/botinfo.js | 3 ++- server.js | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/commands/admin/update.js b/commands/admin/update.js index ad79b11..797944a 100644 --- a/commands/admin/update.js +++ b/commands/admin/update.js @@ -1,4 +1,5 @@ const calculateReloaded = require("../../util/calculateReloaded"); +const executeCommand = require("../../util/executeCommand"); const reloadCommands = require("../../util/reloadCommands"); module.exports = { @@ -31,6 +32,7 @@ module.exports = { sendText = `${sendText}\n... Message is too long to show everything` } message.channel.send(sendText) + client.githash = executeCommand(`git`, ["rev-parse", "--short", "HEAD"]) if (err) console.log(stderr) }) } diff --git a/commands/info/botinfo.js b/commands/info/botinfo.js index 843b465..f1ebebe 100644 --- a/commands/info/botinfo.js +++ b/commands/info/botinfo.js @@ -15,7 +15,8 @@ module.exports = { `Total Members: ${guildInfo.totalMembers}`, `Total Commands: ${client.commands.size}`, `Creation Date: ${getCreationDate(client)}`, - `Source: [Click Here](https://github.com/SileNce5k/discord_bot)` + `Source: [Click Here](https://github.com/SileNce5k/discord_bot)`, + `Current Version: ${client.githash}` ] let description = ""; diff --git a/server.js b/server.js index 871dc93..c8f5d8b 100644 --- a/server.js +++ b/server.js @@ -1,6 +1,7 @@ const fs = require('fs'); const createInitialConfig = require("./util/createInitialConfig") const convertJSONToSQL = require('./util/timer/convertJSONToSQL'); +const executeCommand = require('./util/executeCommand.js'); const sqlite3 = require('sqlite3').verbose(); if(!fs.existsSync("./data/config.json")) { createInitialConfig(); @@ -55,6 +56,7 @@ createAndLoadWhitelistTable(client.whitelist); client.settings.set("presenceType", presenceType); client.settings.set("presenceText", presenceText); client.settings.set("globalPrefix", globalPrefix); +client.githash = executeCommand(`git`, ["rev-parse", "--short", "HEAD"]) const reloadCommands = require("./util/reloadCommands.js"); const onMessage = require('./server/message'); From e79d2a7a7eeff321a7535e522c775ef271267a0f Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Tue, 24 Jun 2025 03:40:44 +0200 Subject: [PATCH 3/5] Add output to executeCommand return --- util/executeCommand.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/util/executeCommand.js b/util/executeCommand.js index ee4cce6..05985c5 100644 --- a/util/executeCommand.js +++ b/util/executeCommand.js @@ -2,13 +2,14 @@ const { execFileSync } = require('child_process'); module.exports = function(command, commandArgs, verbose=false) { if (typeof command !== 'string' || !Array.isArray(commandArgs)) return { error: true }; console.log("Executing:", command, commandArgs.join(" ")); + let output; try { - const output = execFileSync(command, commandArgs, {encoding: 'utf8'}) + output = execFileSync(command, commandArgs, {encoding: 'utf8'}) if (output.length !== 0 && verbose) console.log(output) } catch (error) { console.error(`Error executing ${command} command:`, error); return { error: true }; } - return { error: false }; + return { error: false, output}; } \ No newline at end of file From a891b37a316af69ea608af9a2fec3bb87f5f1c4f Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Tue, 24 Jun 2025 03:46:17 +0200 Subject: [PATCH 4/5] Update githash properly --- commands/admin/update.js | 3 ++- server.js | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/commands/admin/update.js b/commands/admin/update.js index 797944a..7c9a75f 100644 --- a/commands/admin/update.js +++ b/commands/admin/update.js @@ -32,7 +32,8 @@ module.exports = { sendText = `${sendText}\n... Message is too long to show everything` } message.channel.send(sendText) - client.githash = executeCommand(`git`, ["rev-parse", "--short", "HEAD"]) + const githash = executeCommand(`git`, ["rev-parse", "--short", "HEAD"]); + client.githash = githash.error ? "N/A" : githash.output; if (err) console.log(stderr) }) } diff --git a/server.js b/server.js index c8f5d8b..30ed3a3 100644 --- a/server.js +++ b/server.js @@ -56,7 +56,9 @@ createAndLoadWhitelistTable(client.whitelist); client.settings.set("presenceType", presenceType); client.settings.set("presenceText", presenceText); client.settings.set("globalPrefix", globalPrefix); -client.githash = executeCommand(`git`, ["rev-parse", "--short", "HEAD"]) + +const githash = executeCommand(`git`, ["rev-parse", "--short", "HEAD"]); +client.githash = githash.error ? "N/A" : githash.output; const reloadCommands = require("./util/reloadCommands.js"); const onMessage = require('./server/message'); From 6ce4ca6fb8f809380e00c3dc644fcb100c024df5 Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Tue, 24 Jun 2025 03:47:30 +0200 Subject: [PATCH 5/5] Add unique member count to botinfo --- commands/info/botinfo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/info/botinfo.js b/commands/info/botinfo.js index f1ebebe..b806459 100644 --- a/commands/info/botinfo.js +++ b/commands/info/botinfo.js @@ -12,7 +12,7 @@ module.exports = { let descriptionArr = [`Name: ${client.user.username}`, `Prefix: ${prefix}`, `Total Servers: ${guildInfo.guildCount}`, - `Total Members: ${guildInfo.totalMembers}`, + `Total Members: ${guildInfo.totalMembers} (${guildInfo.uniqueMemberCount} unique)`, `Total Commands: ${client.commands.size}`, `Creation Date: ${getCreationDate(client)}`, `Source: [Click Here](https://github.com/SileNce5k/discord_bot)`,