From 5ee9d4106d5ad0ef02ae9026d1f528dbcd8c8a1e Mon Sep 17 00:00:00 2001 From: ry Date: Sun, 5 Jan 2020 21:07:57 +0100 Subject: [PATCH] added changelog command --- DiscordModules/General/changelog.js | 48 +++++++++++++++++++++++++++++ utils/src/logs.js | 6 ++-- vars.js | 2 +- 3 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 DiscordModules/General/changelog.js diff --git a/DiscordModules/General/changelog.js b/DiscordModules/General/changelog.js new file mode 100644 index 0000000..088a256 --- /dev/null +++ b/DiscordModules/General/changelog.js @@ -0,0 +1,48 @@ +const Command = require('../../src/structures/Command'); + +module.exports = class Changelog extends Command { + constructor() { + super({ + name: 'changelog', + description: 'View the latest changes of the bot', + aliases: ['chl', 'c'], + module: 'General', + cooldown: 5, + guildOnly: false, + developerOnly: false, + nsfw: false + }); + } + + + async command(ctx) { + let isDev; + if (ctx.vars.developers.find((dev) => ctx.author.id == dev.id)) isDev = true + + const ValidActions = /(set|view)/g + + let action = ctx.args[0] + ctx.args.shift() + + if (!action.match(ValidActions)) return ctx.send(`You can only ${isDev ? ctx.utils.format.code('view/set'): ctx.utils.format.code('view')} a Changelog`) + + // ctx.db.backend.get() + + let Changelog = ctx.args.join(' ').split('|') + let version = Changelog[0].replace(/\./g, '_') + let text = Changelog[1] + // console.log(action, version, text) + + if (action === 'set') { + if (!isDev) return; + await ctx.db.backend.set(version.trim(), text) + ctx.send('Changelog set, posting...') + ctx.client.channels.find(c => c.id == '572515873156235307').send(`**__Version ${version.replace(/\_/g, '.')}__**\n\n${text.trim()}`) + return ctx.send('Sent.') + } else if (action === 'view') { + let Change = ctx.db.backend.get(version) + if (Change === null) return ctx.send(`That is not a valid Version (or it's not in my Database).\nMy latest version is ${ctx.utils.format.bold(ctx.vars.version)}.`) + ctx.send(`**__Version ${version.replace(/\_/g, '.')}__**\n\n${Change}`) + } + } +} \ No newline at end of file diff --git a/utils/src/logs.js b/utils/src/logs.js index 8eb5bd6..266f684 100755 --- a/utils/src/logs.js +++ b/utils/src/logs.js @@ -1,5 +1,5 @@ const ora = require("ora"); -const config = require("../../vars"); +const vars = require("../../vars"); const chalk = require("chalk"); const BotSpinner = new ora({ discardStdin: false @@ -13,7 +13,7 @@ const ServerSpinner = new ora({ module.exports = async = { starting: async function () { - BotSpinner.text = `${config.name} - v${config.version} is starting`; + BotSpinner.text = `${vars.name} - v${vars.version} is starting`; BotSpinner.spinner = "moon"; BotSpinner.start(); return BotSpinner; @@ -22,7 +22,7 @@ module.exports = async = { return BotSpinner.stop(); }, hasStarted: async function () { - BotSpinner.succeed(`${config.name} - v${config.version} has started`); + BotSpinner.succeed(`${vars.name} - v${vars.version} has started`); return; }, shardReady: async function (text) { diff --git a/vars.js b/vars.js index 9f47f6f..5c0a995 100644 --- a/vars.js +++ b/vars.js @@ -1,6 +1,6 @@ module.exports = { name: 'Thaldrin', - version: '3.6.2', + version: '3.6.4', color: '#ff995d', hostname: '127.2.11.1', //hostname: 'localhost',