Compare commits
5 commits
723f14405a
...
6ce4ca6fb8
Author | SHA1 | Date | |
---|---|---|---|
6ce4ca6fb8 | |||
a891b37a31 | |||
e79d2a7a7e | |||
24e019e34f | |||
9c4a57a098 |
4 changed files with 14 additions and 5 deletions
|
@ -1,4 +1,5 @@
|
||||||
const calculateReloaded = require("../../util/calculateReloaded");
|
const calculateReloaded = require("../../util/calculateReloaded");
|
||||||
|
const executeCommand = require("../../util/executeCommand");
|
||||||
const reloadCommands = require("../../util/reloadCommands");
|
const reloadCommands = require("../../util/reloadCommands");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -27,10 +28,12 @@ module.exports = {
|
||||||
let commitCount = stdout.split(/\r\n|\r|\n/).length - 1
|
let commitCount = stdout.split(/\r\n|\r|\n/).length - 1
|
||||||
sendText = `${sendText}\n\nLatest commits (${commitCount}):\n${stdout}`
|
sendText = `${sendText}\n\nLatest commits (${commitCount}):\n${stdout}`
|
||||||
if(sendText.length >= 2000){
|
if(sendText.length >= 2000){
|
||||||
sendText.slice(1955)
|
sendText = sendText.slice(1955)
|
||||||
sendText = `${sendText}\n... Message is too long to show everything`
|
sendText = `${sendText}\n... Message is too long to show everything`
|
||||||
}
|
}
|
||||||
message.channel.send(sendText)
|
message.channel.send(sendText)
|
||||||
|
const githash = executeCommand(`git`, ["rev-parse", "--short", "HEAD"]);
|
||||||
|
client.githash = githash.error ? "N/A" : githash.output;
|
||||||
if (err) console.log(stderr)
|
if (err) console.log(stderr)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,10 +12,11 @@ module.exports = {
|
||||||
let descriptionArr = [`Name: ${client.user.username}`,
|
let descriptionArr = [`Name: ${client.user.username}`,
|
||||||
`Prefix: ${prefix}`,
|
`Prefix: ${prefix}`,
|
||||||
`Total Servers: ${guildInfo.guildCount}`,
|
`Total Servers: ${guildInfo.guildCount}`,
|
||||||
`Total Members: ${guildInfo.totalMembers}`,
|
`Total Members: ${guildInfo.totalMembers} (${guildInfo.uniqueMemberCount} unique)`,
|
||||||
`Total Commands: ${client.commands.size}`,
|
`Total Commands: ${client.commands.size}`,
|
||||||
`Creation Date: ${getCreationDate(client)}`,
|
`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 = "";
|
let description = "";
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const createInitialConfig = require("./util/createInitialConfig")
|
const createInitialConfig = require("./util/createInitialConfig")
|
||||||
const convertJSONToSQL = require('./util/timer/convertJSONToSQL');
|
const convertJSONToSQL = require('./util/timer/convertJSONToSQL');
|
||||||
|
const executeCommand = require('./util/executeCommand.js');
|
||||||
const sqlite3 = require('sqlite3').verbose();
|
const sqlite3 = require('sqlite3').verbose();
|
||||||
if(!fs.existsSync("./data/config.json")) {
|
if(!fs.existsSync("./data/config.json")) {
|
||||||
createInitialConfig();
|
createInitialConfig();
|
||||||
|
@ -56,6 +57,9 @@ client.settings.set("presenceType", presenceType);
|
||||||
client.settings.set("presenceText", presenceText);
|
client.settings.set("presenceText", presenceText);
|
||||||
client.settings.set("globalPrefix", globalPrefix);
|
client.settings.set("globalPrefix", globalPrefix);
|
||||||
|
|
||||||
|
const githash = executeCommand(`git`, ["rev-parse", "--short", "HEAD"]);
|
||||||
|
client.githash = githash.error ? "N/A" : githash.output;
|
||||||
|
|
||||||
const reloadCommands = require("./util/reloadCommands.js");
|
const reloadCommands = require("./util/reloadCommands.js");
|
||||||
const onMessage = require('./server/message');
|
const onMessage = require('./server/message');
|
||||||
const onReady = require('./server/ready');
|
const onReady = require('./server/ready');
|
||||||
|
|
|
@ -2,13 +2,14 @@ const { execFileSync } = require('child_process');
|
||||||
module.exports = function(command, commandArgs, verbose=false) {
|
module.exports = function(command, commandArgs, verbose=false) {
|
||||||
if (typeof command !== 'string' || !Array.isArray(commandArgs)) return { error: true };
|
if (typeof command !== 'string' || !Array.isArray(commandArgs)) return { error: true };
|
||||||
console.log("Executing:", command, commandArgs.join(" "));
|
console.log("Executing:", command, commandArgs.join(" "));
|
||||||
|
let output;
|
||||||
try {
|
try {
|
||||||
const output = execFileSync(command, commandArgs, {encoding: 'utf8'})
|
output = execFileSync(command, commandArgs, {encoding: 'utf8'})
|
||||||
if (output.length !== 0 && verbose)
|
if (output.length !== 0 && verbose)
|
||||||
console.log(output)
|
console.log(output)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error executing ${command} command:`, error);
|
console.error(`Error executing ${command} command:`, error);
|
||||||
return { error: true };
|
return { error: true };
|
||||||
}
|
}
|
||||||
return { error: false };
|
return { error: false, output};
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue