From 177f4e2b529c8e1c4c4a13e8142b624fa8e5a8fb Mon Sep 17 00:00:00 2001 From: mudkipscience Date: Thu, 26 Mar 2020 18:26:22 +1100 Subject: [PATCH] 1.2.2 --- configTemplate.js | 6 ++++++ index.js | 5 ++++- src/commands/prefix.js | 6 ------ src/commands/zalgo.js | 2 +- src/events/ready.js | 44 +++++++++++++++++++++++++++++++----------- src/modules/Logger.js | 37 +++++++++++++++++++++++------------ version.json | 2 +- 7 files changed, 70 insertions(+), 32 deletions(-) diff --git a/configTemplate.js b/configTemplate.js index 3828ed8..b6e96c3 100644 --- a/configTemplate.js +++ b/configTemplate.js @@ -2,6 +2,12 @@ const config = { // ID's "owners": [], // Adding your ID here will give you access to dangerous commands like eval. Please be careful with who you add here! Eval can be used to modify the host machine. + // Host options + "devmodeEnabled": false, // true or false + "loggingServer": "", // server ID, or blank to disable + "startupLogs": "", // Channel ID, or blank to disable + "consoleLogs": "", // Channel ID, or blank to disable + // Tokens "token": "", // Your bot's token. "devtoken": "", // (optional) another token, meant for a bot used for development diff --git a/index.js b/index.js index 395e910..49d5326 100644 --- a/index.js +++ b/index.js @@ -15,18 +15,21 @@ try { console.log('Failed to load config.js:', err); process.exit(); }; + try{ client.version = require('./version.json'); } catch (err) { console.log('Failed to load version.json:', err); process.exit(); }; + try{ client.logger = require('./src/modules/Logger'); } catch (err) { console.log('Failed to load Logger.js:', err); process.exit(); }; + client.logger.setClient(client); try{ @@ -36,7 +39,7 @@ try{ process.exit(); }; -if(process.env['USER'] != 'container') { +if(client.config.devmodeEnabled == true && process.env['USER'] != 'container') { client.devmode = true; } else { client.devmode = false; diff --git a/src/commands/prefix.js b/src/commands/prefix.js index 774a22b..1d72e74 100644 --- a/src/commands/prefix.js +++ b/src/commands/prefix.js @@ -1,10 +1,4 @@ exports.run = async (client, message, args) => { - if(client.devmode === true) { - return message.channel.send( - "<:error:466995152976871434> This command has been disabled because Woomy is in development mode." - ); - }; - const settings = message.settings; if (!client.settings.has(message.guild.id)) client.settings.set(message.guild.id, {}); diff --git a/src/commands/zalgo.js b/src/commands/zalgo.js index bf2e082..e34d404 100644 --- a/src/commands/zalgo.js +++ b/src/commands/zalgo.js @@ -14,7 +14,7 @@ exports.run = async (client, message, args) => { }; exports.conf = { - enabled: true, + enabled: false, guildOnly: false, aliases: [], permLevel: "User", diff --git a/src/events/ready.js b/src/events/ready.js index f37a7d9..be5792e 100644 --- a/src/events/ready.js +++ b/src/events/ready.js @@ -6,25 +6,45 @@ module.exports = client => { client.lockActivity = false; - client.logger.log(`Connected to Discord as ${client.user.tag} | v${client.version.number}`, 'ready'); + let guild, channel, channel1; + + if(client.config.loggingServer.length > 0) { + try { + guild = client.guilds.cache.get(client.config.loggingServer) + } catch(err) { + client.logger.error("Could not find loggingServer server (is the ID valid?):\n" + err); + process.exit(1); + }; + + if(client.config.consoleLogs.length > 0) { + try { + channel1 = client.guilds.cache.get(client.config.consoleLogs) + } catch(err) { + client.logger.error("Could not find consoleLogs channel (is the ID valid?):\n" + err); + process.exit(1); + }; + }; + + if(client.config.startupLogs.length > 0) { + try { + channel = guild.channels.cache.get(client.config.startupLogs) + } catch(err) { + client.logger.error("Could not find startupLogs channel (is the ID valid?):\n" + err); + process.exit(1); + }; + }; + }; - let channel, channel1; - try { - channel = client.guilds.cache.get('410990517841690625').channels.cache.get('570963998342643732'); - } catch(err) {}; - - try { - channel1 = client.guilds.cache.get('410990517841690625').channels.cache.get('570963481189154822'); - } catch(err) {}; if(client.devmode == true) { client.logger.warn("Running in development mode.") prefix = client.config.defaultSettings.devprefix; } else { prefix = client.config.defaultSettings.prefix; - channel.send(`\`${timestamp}\`: Ready event fired! Connected to ${client.users.cache.size} users in ${client.guilds.cache.size} guilds.`); - channel1.send(`\`${timestamp}\`: **Ready event fired**`); + if(channel1) { + channel1.send(`Bot started at \`${timestamp}\``); + }; }; let randomActivity = activityArray.random(); @@ -37,4 +57,6 @@ module.exports = client => { client.user.setActivity(`${prefix + randomActivity} | v${client.version.number}`, {type: "PLAYING"}); }; }, 30000); + + client.logger.log(`Connected to Discord as ${client.user.tag} | v${client.version.number}`, 'ready'); }; diff --git a/src/modules/Logger.js b/src/modules/Logger.js index 0c8614f..c1fed4b 100644 --- a/src/modules/Logger.js +++ b/src/modules/Logger.js @@ -2,17 +2,25 @@ const chalk = require("chalk"); const moment = require("moment"); exports.log = (content, type = "log") => { - const timestamp = chalk.grey(`[${moment().format("YYYY-MM-DD HH:mm:ss")}]`); + const timestamp = `[${moment().format("YYYY-MM-DD HH:mm:ss")}]`; let channel; + + try { + channel = client.guilds.cache.get(client.config.loggingServer).channels.cache.get(client.config.consoleLogs); + } catch(err) {}; - try { channel = client.guilds.cache.get('410990517841690625').channels.cache.get('570963481189154822'); } catch(err) {} + var logToServer = false; + + if(client.devmode === false && channel && guild.available) { + logToServer = true; + }; switch (type) { case "info": { try { - if (client.devmode == false) { - channel.send(`\`${timestamp}\`: ` + content); + if (logToServer == true) { + channel.send(`\`${timestamp}\` \`[${type.toUpperCase()}]\` ` + content); }; } catch(err) {}; return console.log(`${timestamp} ${chalk.cyanBright(`[${type.toUpperCase()}]`)} ${content} `); @@ -20,8 +28,8 @@ exports.log = (content, type = "log") => { case "warn": { try { - if (client.devmode == false) { - channel.send(`\`${timestamp}\`: ` + content); + if (logToServer == true) { + channel.send(`\`${timestamp}\` \`[${type.toUpperCase()}]\` ` + content); }; } catch(err) {}; return console.log(`${timestamp} ${chalk.yellowBright(`[${type.toUpperCase()}]`)} ${content} `); @@ -29,8 +37,8 @@ exports.log = (content, type = "log") => { case "error": { try { - if (client.devmode == false) { - channel.send(`\`${timestamp}\`: ` + content); + if (logToServer == true) { + channel.send(`\`${timestamp}\` \`[${type.toUpperCase()}]\` ` + content); }; } catch(err) {} return console.log(`${timestamp} ${chalk.redBright(`[${type.toUpperCase()}]`)} ${content} `); @@ -38,8 +46,8 @@ exports.log = (content, type = "log") => { case "debug": { try { - if (client.devmode == false) { - channel.send(`\`${timestamp}\`: ` + content); + if (logToServer == true) { + channel.send(`\`${timestamp}\` \`[${type.toUpperCase()}]\` ` + content); }; } catch(err) {}; return console.log(`${timestamp} ${chalk.magentaBright(`[${type.toUpperCase()}]`)} ${content} `); @@ -47,14 +55,19 @@ exports.log = (content, type = "log") => { case "cmd": { try { - if (client.devmode == false) { - channel.send(`\`${timestamp}\` ` + content); + if (logToServer == true) { + channel.send(`\`${timestamp}\` \`[${type.toUpperCase()}]\` ` + content); }; } catch(err) {}; return console.log(`${timestamp} ${chalk.whiteBright(`[${type.toUpperCase()}]`)} ${content}`); }; case "ready": { + try { + if (logToServer == true) { + channel.send(`\`${timestamp}\` \`[${type.toUpperCase()}]\` ` + content); + }; + } catch(err) {}; return console.log(`${timestamp} ${chalk.greenBright (`[${type.toUpperCase()}]`)} ${content}`); }; diff --git a/version.json b/version.json index 92c7223..19b07db 100644 --- a/version.json +++ b/version.json @@ -1,4 +1,4 @@ { - "number": "1.2.1", + "number": "1.2.2", "changelog": "**1.2.0 CHANGELOG:**\n> • Added action commands! (`cuddle`, `feed`, `hug`, `kiss`, `pat`, `poke`, `slap`, `smug`, `tickle`)\n> • Added `fact`\n> • Added `catfact`\n> • Added `dogfact`\n> • Added `yoda`\n> • Added `dice`\n> • Added `spoilerise`\n> • Added `zalgo`\n> • Added `dog`\n> • Added `cat`\n> • Added `lizard`\n> • Added `neko`\n> • Added `nekogif`\n> • Added `kemonomimi`\n> • Added `foxgirl`\n> • Added `identity`\n> • Added `pronouns`\n> • Added `sexuality`\n> • Added `ship`\n> • Renamed `flip to `coinflip` (flip remains as an alias)\n> • Renamed `math` to `calculate` (math is an alias)\n> • @Woomy is now a prefix\n> • Added the `inspire` alias to `inspirobot`\n> • Help now displays the amount of commands in each category\n> • Bots now get a badge in `userinfo`\n> • `roleinfo` now displays what permissions a role has\n> • small changes to `weather`\n> • Woomy now has clear logging of issues that prevent her from starting\n> • request npm module has been swapped out for node-fetch\n**NOTES:**\n> Thank you to Terryiscool160 for creating multiple commands used in this update" }