From 80d64295ee44047141e787b1f2c326d8ec2988dd Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 20:05:20 -0400 Subject: [PATCH 01/71] add sysinfo cmd and dataConversion func --- src/commands/sysinfo.ts | 34 +++++++++++++++++++++++++++++++++ src/functions/dataConversion.ts | 5 +++++ 2 files changed, 39 insertions(+) create mode 100644 src/commands/sysinfo.ts create mode 100644 src/functions/dataConversion.ts diff --git a/src/commands/sysinfo.ts b/src/commands/sysinfo.ts new file mode 100644 index 0000000..35185eb --- /dev/null +++ b/src/commands/sysinfo.ts @@ -0,0 +1,34 @@ +import moment from 'moment'; +import { Message } from 'eris'; +import os, { totalmem } from 'os'; +import { Command, RichEmbed } from '../class'; +import { dataConversion } from '../functions'; +import { Client } from '..'; + +export default class SysInfo extends Command { + constructor(client: Client) { + super(client); + this.name = 'sysinfo'; + this.description = 'Provides system information.'; + this.enabled = true; + } + + public async run(message: Message) { + const availableMemory: string = await this.client.util.exec('free -b'); + const usedMemory = dataConversion(totalmem() - Number(availableMemory.split('\n')[1].split(' ').slice(-1)[0])); + const date = new Date(); + date.setMilliseconds(-(moment.duration(os.uptime(), 's').asMilliseconds())); + + const embed = new RichEmbed(); + embed.setTitle('System Information & Statistics'); + embed.addField('Hostname', os.hostname(), true); + embed.addField('Uptime', `${moment.duration(os.uptime(), 's').humanize()} | Last restart was on ${moment(date).format('dddd, MMMM Do YYYY, h:mm:ss A')} EST`, true); + embed.addField('CPU', `${os.cpus()[0].model} ${os.cpus()[0].speed / 1000}GHz | ${os.cpus().length} Cores | ${os.arch()}`, true); + embed.addField('Load Average (last 15 minutes)', os.loadavg()[2].toFixed(3), true); + embed.addField('Memory/RAM', `${usedMemory} / ${dataConversion(totalmem())}`, true); + embed.addField('Network Interfaces (IPv4)', os.networkInterfaces().eth0.filter((r) => r.family === 'IPv4')[0].address, true); + embed.addField('Network Interfaces (IPv6)', os.networkInterfaces().eth0.filter((r) => r.family === 'IPv6')[0].address, true); + // @ts-ignore + message.channel.createMessage({ embed }); + } +} diff --git a/src/functions/dataConversion.ts b/src/functions/dataConversion.ts new file mode 100644 index 0000000..e38337d --- /dev/null +++ b/src/functions/dataConversion.ts @@ -0,0 +1,5 @@ +export default function dataConversion(bytes: number) { + const i = Math.floor(Math.log(bytes) / Math.log(1024)); + const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; + return `${(bytes / 1024 ** i).toFixed(2)} ${sizes[i]}`; +} From a633aeda9bd781cd1df0da287e7871ed5a36a742 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 20:05:32 -0400 Subject: [PATCH 02/71] add functions index --- src/functions/index.ts | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 src/functions/index.ts diff --git a/src/functions/index.ts b/src/functions/index.ts new file mode 100644 index 0000000..b4047fb --- /dev/null +++ b/src/functions/index.ts @@ -0,0 +1,2 @@ +export { default as checkLock } from './checkLock'; +export { default as dataConversion } from './dataConversion'; From d9c1c635e7d78664327838fc77dd0016214a3dec Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 20:09:31 -0400 Subject: [PATCH 03/71] connect to mongo --- src/Client.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Client.ts b/src/Client.ts index bfd8fe2..8be5a2f 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -78,6 +78,7 @@ export default class Client extends Eris.Client { delete require.cache[require.resolve(`./events/${file}`)]; }); + await mongoose.connect(config.mongoURL); this.connect(); } } From 700a14685645d00fac67c32317688d0c2826f2eb Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 20:10:23 -0400 Subject: [PATCH 04/71] connect success log --- src/Client.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Client.ts b/src/Client.ts index 8be5a2f..294f506 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -79,6 +79,7 @@ export default class Client extends Eris.Client { }); await mongoose.connect(config.mongoURL); - this.connect(); + await this.connect(); + this.signale.success(`Successfully connected to Discord | ${this.user.username}#${this.user.discriminator}`); } } From 52050f41f37eb5bef59d8d53469a204d151354d5 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 20:17:15 -0400 Subject: [PATCH 05/71] should be .org, not .us --- src/commands/modlogs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/modlogs.ts b/src/commands/modlogs.ts index 1a66f15..b21a36e 100644 --- a/src/commands/modlogs.ts +++ b/src/commands/modlogs.ts @@ -45,7 +45,7 @@ export default class Modlogs extends Command { const embeds = logs.map((l) => { const embed = new RichEmbed(); embed.setDescription(`List of Cloud moderation logs for ${users.join(', ')}`); - embed.setAuthor('Library of Code | Cloud Services', this.client.user.avatarURL, 'https://libraryofcode.us'); + embed.setAuthor('Library of Code | Cloud Services', this.client.user.avatarURL, 'https://libraryofcode.org/'); embed.setTitle('Cloud Modlogs/Infractions'); embed.setFooter(`Requested by ${message.author.username}#${message.author.discriminator}`, message.author.avatarURL); l.forEach((f) => embed.addField(f.name, f.value, f.inline)); From f83b62e3c0f0c16511a87af96220c1716df38d3b Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 20:17:29 -0400 Subject: [PATCH 06/71] set process title on constructor --- src/Client.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Client.ts b/src/Client.ts index 294f506..4d66bad 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -27,6 +27,7 @@ export default class Client extends Eris.Client { constructor() { super(config.token, { getAllUsers: true, restMode: true, defaultImageFormat: 'png' }); + process.title = 'cloudservices'; this.config = config; this.util = new Util(this); this.commands = new Map(); From 38a840e5e5caaa97f6e50b3f4102d478910d5081 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 20:19:55 -0400 Subject: [PATCH 07/71] get prefix from client, not directly --- src/events/messageCreate.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index 5d225e6..93cb6a3 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -1,9 +1,7 @@ import { Message, TextChannel } from 'eris'; -import { Client, config } from '..'; +import { Client } from '..'; import Command from '../class/Command'; -const { prefix } = config; - export default class { public client: Client @@ -13,7 +11,7 @@ export default class { public async run(message: Message) { try { - const noPrefix: string[] = message.content.slice(prefix.length).trim().split(/ +/g); + const noPrefix: string[] = message.content.slice(this.client.config.prefix.length).trim().split(/ +/g); const command: string = noPrefix[0].toLowerCase(); const resolved: Command = this.client.util.resolveCommand(command); if (!resolved) return; From 9eda0e9b4c344d0bc28bd827571eb04b1bc6ed99 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 20:23:01 -0400 Subject: [PATCH 08/71] would help if we'd actually inst the client --- src/Client.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Client.ts b/src/Client.ts index 4d66bad..f6cf26c 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -84,3 +84,6 @@ export default class Client extends Eris.Client { this.signale.success(`Successfully connected to Discord | ${this.user.username}#${this.user.discriminator}`); } } + +// eslint-disable-next-line +new Client(); From 798b770d08cd4edb0a99f47427985950d61bbbec Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 20:30:03 -0400 Subject: [PATCH 09/71] would help if we'd actually inst the client --- src/Client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Client.ts b/src/Client.ts index f6cf26c..667402e 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -3,7 +3,7 @@ import mongoose from 'mongoose'; import signale from 'signale'; import fs from 'fs-extra'; import path from 'path'; -import { config } from '.'; +import config from './config.json'; import { Account, AccountInterface, Moderation, ModerationInterface, Domain, DomainInterface } from './models'; import { emojis } from './stores'; import { Command, Util } from './class'; From 308320e28e02fa97440c7477f19017b16f3e6ed1 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 20:43:48 -0400 Subject: [PATCH 10/71] would help if we'd actually inst the client --- src/Client.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Client.ts b/src/Client.ts index 667402e..499240a 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -68,6 +68,7 @@ export default class Client extends Eris.Client { const evtFiles = await fs.readdir('./events/'); const commands = await fs.readdir(path.join(__dirname, './commands/')); commands.forEach((command) => { + if (command === 'index.js') return; this.loadCommand(`./commands/${command}`); }); From 72e9750d2d198c9f1ef049233154357e7fee6546 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 20:47:45 -0400 Subject: [PATCH 11/71] would help if we'd actually inst the client --- src/Client.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Client.ts b/src/Client.ts index 499240a..2bba305 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -58,7 +58,8 @@ export default class Client extends Eris.Client { public loadCommand(commandPath: string) { // eslint-disable-next-line no-useless-catch try { - const command = new (require(commandPath))(this); + // eslint-disable-next-line + const command = new (require(commandPath).default)(this); this.commands.set(command.name, command); this.signale.complete(`Loaded command ${command.name}`); } catch (err) { throw err; } @@ -74,7 +75,9 @@ export default class Client extends Eris.Client { evtFiles.forEach((file) => { const eventName = file.split('.')[0]; - const event = new (require(`./events/${file}`))(this); + if (file === 'index.js') return; + // eslint-disable-next-line + const event = new (require(`./events/${file}`).default)(this); this.signale.complete(`Loaded event ${eventName}`); this.on(eventName, (...args) => event.run(...args)); delete require.cache[require.resolve(`./events/${file}`)]; From fae3eab310c2483e716c18b8542675dcb857de65 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 20:51:02 -0400 Subject: [PATCH 12/71] prefix should come from client, not directly --- src/commands/announce.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/announce.ts b/src/commands/announce.ts index f825536..7050077 100644 --- a/src/commands/announce.ts +++ b/src/commands/announce.ts @@ -1,5 +1,5 @@ import { Message } from 'eris'; -import { Client, config } from '..'; +import { Client } from '..'; import { Command } from '../class'; export default class Announce extends Command { @@ -7,7 +7,7 @@ export default class Announce extends Command { super(client); this.name = 'announce'; this.description = 'Sends an announcement to all active terminals'; - this.usage = `${config.prefix}announce Hi there! | ${config.prefix}announce -e EMERGENCY!`; + this.usage = `${this.client.config.prefix}announce Hi there! | ${this.client.config.prefix}announce -e EMERGENCY!`; this.aliases = ['ann']; this.permissions = { roles: ['608095934399643649', '521312697896271873'] }; this.enabled = true; From aaeb35719f13319d4ba23dcb0c000e8729f1ed86 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 20:54:48 -0400 Subject: [PATCH 13/71] add event listeners on process in client --- src/Client.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Client.ts b/src/Client.ts index 2bba305..152c1ad 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -40,10 +40,17 @@ export default class Client extends Eris.Client { displayTimestamp: true, displayFilename: true, }); + this.events(); this.loadFunctions(); this.init(); } + private async events() { + process.on('unhandledRejection', (error) => { + this.signale.error(error); + }); + } + private async loadFunctions() { const functions = await fs.readdir('./functions'); functions.forEach(async (func) => { From c4fd0c000bb357152237339cd3af9e6108792eb8 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 21:09:40 -0400 Subject: [PATCH 14/71] rm prompt --- src/Client.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Client.ts b/src/Client.ts index 152c1ad..59bd6ff 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -92,7 +92,6 @@ export default class Client extends Eris.Client { await mongoose.connect(config.mongoURL); await this.connect(); - this.signale.success(`Successfully connected to Discord | ${this.user.username}#${this.user.discriminator}`); } } From e9ae7c3ee875a8545413eaad6da186fc55139fe7 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 21:14:28 -0400 Subject: [PATCH 15/71] a --- src/class/Util.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/class/Util.ts b/src/class/Util.ts index 569897a..d6408ab 100644 --- a/src/class/Util.ts +++ b/src/class/Util.ts @@ -45,6 +45,8 @@ export default class Util { } public async handleError(error: Error, message?: Message, command?: Command): Promise { + this.client.signale.error(error); + /* const info = { content: `\`\`\`js\n${error.stack}\n\`\`\``, embed: null }; if (message) { const embed = new RichEmbed(); @@ -65,6 +67,7 @@ export default class Util { if (message) this.client.createMessage('595788220764127272', 'Message content for above error'); if (command) this.client.commands.get(command.name).enabled = false; if (message) message.channel.createMessage(`***${this.client.stores.emojis.error} An unexpected error has occured - please contact a member of the Engineering Team.${command ? ' This command has been disabled.' : ''}***`); + */ } public splitFields(fields: {name: string, value: string, inline?: boolean}[]): {name: string, value: string, inline?: boolean}[][] { From 0633564e6afd7313794ac469763f884440981782 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 21:18:20 -0400 Subject: [PATCH 16/71] perms is declared but never used --- src/class/Command.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/class/Command.ts b/src/class/Command.ts index 16177ac..ba3ee3f 100644 --- a/src/class/Command.ts +++ b/src/class/Command.ts @@ -28,5 +28,6 @@ export default class Command { this.aliases = []; this.guildOnly = true; this.client = client; + this.permissions = {}; } } From 9e5c9da6e2761cf5a18c01afbfb04ac666571cc0 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 21:21:26 -0400 Subject: [PATCH 17/71] add checks for presence of user/role perms before checking --- src/events/messageCreate.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index 93cb6a3..86d8625 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -16,12 +16,21 @@ export default class { const resolved: Command = this.client.util.resolveCommand(command); if (!resolved) return; if (resolved.guildOnly && !(message.channel instanceof TextChannel)) return; - const hasUserPerms: boolean = resolved.permissions.users.includes(message.author.id); + let hasUserPerms: boolean; + if (resolved.permissions.users) { + hasUserPerms = resolved.permissions.users.includes(message.author.id); + } else { + hasUserPerms = true; + } let hasRolePerms: boolean = false; - for (const role of resolved.permissions.roles) { - if (message.member && message.member.roles.includes(role)) { - hasRolePerms = true; break; + if (resolved.permissions.roles) { + for (const role of resolved.permissions.roles) { + if (message.member && message.member.roles.includes(role)) { + hasRolePerms = true; break; + } } + } else { + hasRolePerms = true; } if (!hasRolePerms && !hasUserPerms) return; if (!resolved.enabled) { message.channel.createMessage(`***${this.client.stores.emojis.error} This command has been disabled***`); return; } From 6312fa243e345a872da0d07a5dd1e17734a46faf Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 21:23:56 -0400 Subject: [PATCH 18/71] get config from client, also remove weird evalMessage thing --- src/commands/eval.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/commands/eval.ts b/src/commands/eval.ts index 44efeab..23a40cc 100644 --- a/src/commands/eval.ts +++ b/src/commands/eval.ts @@ -2,7 +2,7 @@ import { Message } from 'eris'; import { inspect } from 'util'; import axios from 'axios'; -import { Client, config } from '..'; +import { Client } from '..'; import { Command } from '../class'; export default class Eval extends Command { @@ -17,21 +17,21 @@ export default class Eval extends Command { public async run(message: Message) { try { - const evalMessage = message.content.slice(config.prefix.length).split(' ').slice(1).join(' '); + // const evalMessage = message.content.slice(this.client.config.prefix.length).split(' ').slice(1).join(' '); let evaled: any; let output: string; try { - evaled = await eval(evalMessage); + evaled = await eval(message.content); if (typeof evaled !== 'string') output = output && inspect(evaled, { depth: 1 }); } catch (error) { output = error.stack; } if (output) { - output = output.replace(RegExp(config.prefix, 'gi'), 'juul'); - output = output.replace(RegExp(config.emailPass, 'gi'), 'juul'); - output = output.replace(RegExp(config.cloudflare, 'gi'), 'juul'); + output = output.replace(RegExp(this.client.config.prefix, 'gi'), 'juul'); + output = output.replace(RegExp(this.client.config.emailPass, 'gi'), 'juul'); + output = output.replace(RegExp(this.client.config.cloudflare, 'gi'), 'juul'); } const display = this.client.util.splitString(output, 1975); From c1975d6a915be5a89bb5f3480116a79644d39ba7 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 21:31:06 -0400 Subject: [PATCH 19/71] attempt to fix RichEmbed --- src/class/RichEmbed.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/class/RichEmbed.ts b/src/class/RichEmbed.ts index 38dbfec..e88e3e0 100644 --- a/src/class/RichEmbed.ts +++ b/src/class/RichEmbed.ts @@ -33,16 +33,24 @@ export default class RichEmbed { thumbnail?: { url?: string, proxy_url?: string, height?: number, width?: number }, video?: { url?: string, height?: number, width?: number }, provider?: { name?: string, url?: string}, author?: { name?: string, url?: string, proxy_icon_url?: string, icon_url?: string}, } = {}) { + /* let types: { title?: string, type?: string, description?: string, url?: string, timestamp?: Date, color?: number, fields?: {name: string, value: string, inline?: boolean}[] footer?: { text: string, icon_url?: string, proxy_icon_url?: string}, image?: { url?: string, proxy_url?: string, height?: number, width?: number }, thumbnail?: { url?: string, proxy_url?: string, height?: number, width?: number }, video?: { url?: string, height?: number, width?: number }, provider?: { name?: string, url?: string}, author?: { name?: string, url?: string, proxy_icon_url?: string, icon_url?: string} }; - this.fields = []; - for (const key of Object.keys(types)) { - if (data[key]) this[key] = data[key]; - } + */ + this.title = data.title; + this.description = data.description; + this.url = data.url; + this.color = data.color; + this.author = data.author; + this.timestamp = data.timestamp; + this.fields = data.fields || []; + this.thumbnail = data.thumbnail; + this.image = data.image; + this.footer = data.footer; } /** From a859352f39e89aeeff1ef870fe53c7e064f0eca1 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 21:34:22 -0400 Subject: [PATCH 20/71] attempt to fix RichEmbed --- src/class/RichEmbed.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/class/RichEmbed.ts b/src/class/RichEmbed.ts index e88e3e0..d47660a 100644 --- a/src/class/RichEmbed.ts +++ b/src/class/RichEmbed.ts @@ -105,8 +105,8 @@ export default class RichEmbed { */ setAuthor(name: string, icon_url?: string, url?: string) { if (typeof name !== 'string') throw new TypeError('RichEmbed Author names must be a string.'); - if (typeof url !== 'string') throw new TypeError('RichEmbed Author URLs must be a string.'); - if (typeof icon_url !== 'string') throw new TypeError('RichEmbed Author icons must be a string.'); + if (url && typeof url !== 'string') throw new TypeError('RichEmbed Author URLs must be a string.'); + if (icon_url && typeof icon_url !== 'string') throw new TypeError('RichEmbed Author icons must be a string.'); if (!url.startsWith('http://') || !url.startsWith('https://')) url = `https://${url}`; if (!icon_url.startsWith('http://') || !icon_url.startsWith('https://')) icon_url = `https://${icon_url}`; this.author = { name, icon_url, url }; From 995c5c58aa307bce99448d0d7204148ec96f2a93 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 21:36:10 -0400 Subject: [PATCH 21/71] attempt to fix RichEmbed --- src/class/RichEmbed.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/class/RichEmbed.ts b/src/class/RichEmbed.ts index d47660a..25504ac 100644 --- a/src/class/RichEmbed.ts +++ b/src/class/RichEmbed.ts @@ -107,8 +107,6 @@ export default class RichEmbed { if (typeof name !== 'string') throw new TypeError('RichEmbed Author names must be a string.'); if (url && typeof url !== 'string') throw new TypeError('RichEmbed Author URLs must be a string.'); if (icon_url && typeof icon_url !== 'string') throw new TypeError('RichEmbed Author icons must be a string.'); - if (!url.startsWith('http://') || !url.startsWith('https://')) url = `https://${url}`; - if (!icon_url.startsWith('http://') || !icon_url.startsWith('https://')) icon_url = `https://${icon_url}`; this.author = { name, icon_url, url }; return this; } From baf65952f6ea75e613fb2281ff061afbda1dc699 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 21:40:39 -0400 Subject: [PATCH 22/71] comment shit out of eval --- src/commands/eval.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/commands/eval.ts b/src/commands/eval.ts index 23a40cc..e6b05db 100644 --- a/src/commands/eval.ts +++ b/src/commands/eval.ts @@ -28,11 +28,13 @@ export default class Eval extends Command { output = error.stack; } + /* if (output) { output = output.replace(RegExp(this.client.config.prefix, 'gi'), 'juul'); output = output.replace(RegExp(this.client.config.emailPass, 'gi'), 'juul'); output = output.replace(RegExp(this.client.config.cloudflare, 'gi'), 'juul'); } + */ const display = this.client.util.splitString(output, 1975); if (display[5]) { From 1ed93f3b5f6bcea7c190cca2b089a54e1c541075 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 21:42:39 -0400 Subject: [PATCH 23/71] another fix attempt on eval --- src/commands/eval.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/eval.ts b/src/commands/eval.ts index e6b05db..49b2c20 100644 --- a/src/commands/eval.ts +++ b/src/commands/eval.ts @@ -15,14 +15,14 @@ export default class Eval extends Command { this.permissions = { users: ['253600545972027394', '278620217221971968'] }; } - public async run(message: Message) { + public async run(message: Message, args: string[]) { try { // const evalMessage = message.content.slice(this.client.config.prefix.length).split(' ').slice(1).join(' '); let evaled: any; let output: string; try { - evaled = await eval(message.content); + evaled = await eval(args.join(' ').trim()); if (typeof evaled !== 'string') output = output && inspect(evaled, { depth: 1 }); } catch (error) { output = error.stack; From e83fc9865dfb98b21c31fa55a625964f2deeaf63 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 21:46:29 -0400 Subject: [PATCH 24/71] another fix attempt on eval --- src/commands/eval.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/commands/eval.ts b/src/commands/eval.ts index 49b2c20..68f61ce 100644 --- a/src/commands/eval.ts +++ b/src/commands/eval.ts @@ -23,7 +23,9 @@ export default class Eval extends Command { try { evaled = await eval(args.join(' ').trim()); - if (typeof evaled !== 'string') output = output && inspect(evaled, { depth: 1 }); + if (typeof evaled === 'object') { + evaled = inspect(evaled, { depth: 0 }); + } } catch (error) { output = error.stack; } From 1ca97d4627c38f3d1f6730f771eb897811da4a27 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 21:47:43 -0400 Subject: [PATCH 25/71] another fix attempt on eval --- src/commands/eval.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/commands/eval.ts b/src/commands/eval.ts index 68f61ce..5bfd0bd 100644 --- a/src/commands/eval.ts +++ b/src/commands/eval.ts @@ -39,6 +39,7 @@ export default class Eval extends Command { */ const display = this.client.util.splitString(output, 1975); + this.client.signale.debug(display); if (display[5]) { try { const { data } = await axios.post('https://snippets.cloud.libraryofcode.org/documents', display.join('')); From d8049997a21b0ce321ba030490eea38b009e0b9f Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 21:50:11 -0400 Subject: [PATCH 26/71] another fix attempt on eval --- src/commands/eval.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/commands/eval.ts b/src/commands/eval.ts index 5bfd0bd..f10df56 100644 --- a/src/commands/eval.ts +++ b/src/commands/eval.ts @@ -38,6 +38,7 @@ export default class Eval extends Command { } */ + this.client.signale.debug(output); const display = this.client.util.splitString(output, 1975); this.client.signale.debug(display); if (display[5]) { From 5ce5b7f64dc91d10c4c01ec368ffcc02272407cf Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 21:53:16 -0400 Subject: [PATCH 27/71] another fix attempt on eval --- src/commands/eval.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/commands/eval.ts b/src/commands/eval.ts index f10df56..ea46f62 100644 --- a/src/commands/eval.ts +++ b/src/commands/eval.ts @@ -19,7 +19,6 @@ export default class Eval extends Command { try { // const evalMessage = message.content.slice(this.client.config.prefix.length).split(' ').slice(1).join(' '); let evaled: any; - let output: string; try { evaled = await eval(args.join(' ').trim()); @@ -27,7 +26,7 @@ export default class Eval extends Command { evaled = inspect(evaled, { depth: 0 }); } } catch (error) { - output = error.stack; + evaled = error.stack; } /* @@ -38,9 +37,7 @@ export default class Eval extends Command { } */ - this.client.signale.debug(output); - const display = this.client.util.splitString(output, 1975); - this.client.signale.debug(display); + const display = this.client.util.splitString(evaled, 1975); if (display[5]) { try { const { data } = await axios.post('https://snippets.cloud.libraryofcode.org/documents', display.join('')); From c177fb88ee9e0f1e925f5c601f0c897e03eeaf8a Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 21:54:22 -0400 Subject: [PATCH 28/71] another fix attempt on eval --- src/commands/eval.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/commands/eval.ts b/src/commands/eval.ts index ea46f62..5a348c5 100644 --- a/src/commands/eval.ts +++ b/src/commands/eval.ts @@ -25,6 +25,9 @@ export default class Eval extends Command { if (typeof evaled === 'object') { evaled = inspect(evaled, { depth: 0 }); } + if (evaled === undefined) { + evaled = 'undefined'; + } } catch (error) { evaled = error.stack; } From ec5717d0a7f1728bd1991e53be213390f3ddae08 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 22:03:05 -0400 Subject: [PATCH 29/71] fix command handler again --- src/events/messageCreate.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index 86d8625..f857158 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -11,6 +11,8 @@ export default class { public async run(message: Message) { try { + if (message.author.bot) return; + if (message.content.indexOf(this.client.config.prefix) !== 0) return; const noPrefix: string[] = message.content.slice(this.client.config.prefix.length).trim().split(/ +/g); const command: string = noPrefix[0].toLowerCase(); const resolved: Command = this.client.util.resolveCommand(command); From bfde851211e820b883c40699dee719b7b7d19a33 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 22:11:57 -0400 Subject: [PATCH 30/71] fix richembed shit again --- src/class/RichEmbed.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/class/RichEmbed.ts b/src/class/RichEmbed.ts index 25504ac..9ebc0e4 100644 --- a/src/class/RichEmbed.ts +++ b/src/class/RichEmbed.ts @@ -170,7 +170,6 @@ export default class RichEmbed { setFooter(text: string, icon_url?: string) { if (typeof text !== 'string') throw new TypeError('RichEmbed Footers must be a string.'); if (icon_url && typeof icon_url !== 'string') throw new TypeError('RichEmbed Footer icon URLs must be a string.'); - if (!icon_url.startsWith('http://') || !icon_url.startsWith('https://')) icon_url = `https://${icon_url}`; if (text.length > 2048) throw new RangeError('RichEmbed footer text may not exceed 2048 characters.'); this.footer = { text, icon_url }; return this; From 9297b4774e1c2a0cd144c48c5da645f17a454ab4 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 22:14:10 -0400 Subject: [PATCH 31/71] remove inline --- src/commands/help.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/help.ts b/src/commands/help.ts index 02b20a5..59c40c4 100644 --- a/src/commands/help.ts +++ b/src/commands/help.ts @@ -28,7 +28,7 @@ export default class Help extends Command { let allowedUsers = c.permissions && c.permissions.users && c.permissions.users.map((u) => `<@${u}>`).join(', '); if (allowedUsers) { allowedUsers = `**Users:** ${allowedUsers}`; perms.push(allowedUsers); } const displayedPerms = perms.length ? `**Permissions:**\n${perms.join('\n')}` : ''; - return { name: `${this.client.config.prefix}${c.name}`, value: `**Description:** ${c.description}\n**Aliases:** ${aliases}\n**Usage:** ${c.usage}\n${displayedPerms}`, inline: true }; + return { name: `${this.client.config.prefix}${c.name}`, value: `**Description:** ${c.description}\n**Aliases:** ${aliases}\n**Usage:** ${c.usage}\n${displayedPerms}`, inline: false }; }); const splitCommands = this.client.util.splitFields(commands); From 2a473b65b7d14323109dbee9c08396c4c3a4d740 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 22:16:27 -0400 Subject: [PATCH 32/71] sysinfo cmd embed updates --- src/commands/sysinfo.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/commands/sysinfo.ts b/src/commands/sysinfo.ts index 35185eb..be7601c 100644 --- a/src/commands/sysinfo.ts +++ b/src/commands/sysinfo.ts @@ -28,6 +28,8 @@ export default class SysInfo extends Command { embed.addField('Memory/RAM', `${usedMemory} / ${dataConversion(totalmem())}`, true); embed.addField('Network Interfaces (IPv4)', os.networkInterfaces().eth0.filter((r) => r.family === 'IPv4')[0].address, true); embed.addField('Network Interfaces (IPv6)', os.networkInterfaces().eth0.filter((r) => r.family === 'IPv6')[0].address, true); + embed.setFooter(this.client.user.username, this.client.user.avatarURL); + embed.setTimestamp(); // @ts-ignore message.channel.createMessage({ embed }); } From 8bcd610462adf3326826629fd84d1e5493fdbc48 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 22:21:16 -0400 Subject: [PATCH 33/71] please --- src/events/messageCreate.ts | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index f857158..60b9f92 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -21,18 +21,12 @@ export default class { let hasUserPerms: boolean; if (resolved.permissions.users) { hasUserPerms = resolved.permissions.users.includes(message.author.id); - } else { - hasUserPerms = true; } let hasRolePerms: boolean = false; - if (resolved.permissions.roles) { - for (const role of resolved.permissions.roles) { - if (message.member && message.member.roles.includes(role)) { - hasRolePerms = true; break; - } + for (const role of resolved.permissions.roles) { + if (message.member && message.member.roles.includes(role)) { + hasRolePerms = true; break; } - } else { - hasRolePerms = true; } if (!hasRolePerms && !hasUserPerms) return; if (!resolved.enabled) { message.channel.createMessage(`***${this.client.stores.emojis.error} This command has been disabled***`); return; } From 301f9ff9a24ced3f84138f309dbce0d27f746f0b Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 22:22:40 -0400 Subject: [PATCH 34/71] please --- src/events/messageCreate.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index 60b9f92..3266587 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -16,6 +16,7 @@ export default class { const noPrefix: string[] = message.content.slice(this.client.config.prefix.length).trim().split(/ +/g); const command: string = noPrefix[0].toLowerCase(); const resolved: Command = this.client.util.resolveCommand(command); + this.client.signale.debug(resolved); if (!resolved) return; if (resolved.guildOnly && !(message.channel instanceof TextChannel)) return; let hasUserPerms: boolean; From 2274959f8a3830ce770548f9208199593d5d759f Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 22:25:39 -0400 Subject: [PATCH 35/71] please --- src/events/messageCreate.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index 3266587..f73098c 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -24,9 +24,11 @@ export default class { hasUserPerms = resolved.permissions.users.includes(message.author.id); } let hasRolePerms: boolean = false; - for (const role of resolved.permissions.roles) { - if (message.member && message.member.roles.includes(role)) { - hasRolePerms = true; break; + if (resolved.permissions.roles) { + for (const role of resolved.permissions.roles) { + if (message.member && message.member.roles.includes(role)) { + hasRolePerms = true; break; + } } } if (!hasRolePerms && !hasUserPerms) return; From 98fdd4f8abd3a97a4c9e4dfde3fde667943ee83f Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 22:26:50 -0400 Subject: [PATCH 36/71] fix emoji in store --- src/stores/emojis.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stores/emojis.ts b/src/stores/emojis.ts index ffe301b..7e46d8c 100644 --- a/src/stores/emojis.ts +++ b/src/stores/emojis.ts @@ -1,5 +1,5 @@ export default { success: '<:modSuccess:578750988907970567>', loading: '', - error: '<:modError:578750737920688128', + error: '<:modError:578750737920688128>', }; From 8a6b6de78fbe3f442cc11c9fa5024df1bd51bb08 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 22:27:03 -0400 Subject: [PATCH 37/71] fix command handler issue --- src/events/messageCreate.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index f73098c..a9669d2 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -16,7 +16,6 @@ export default class { const noPrefix: string[] = message.content.slice(this.client.config.prefix.length).trim().split(/ +/g); const command: string = noPrefix[0].toLowerCase(); const resolved: Command = this.client.util.resolveCommand(command); - this.client.signale.debug(resolved); if (!resolved) return; if (resolved.guildOnly && !(message.channel instanceof TextChannel)) return; let hasUserPerms: boolean; From b87f1c112bedd136529f9cb2e85703ac779073ec Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 22:30:10 -0400 Subject: [PATCH 38/71] fix command handler issue --- src/events/messageCreate.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index a9669d2..bfa775a 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -19,7 +19,7 @@ export default class { if (!resolved) return; if (resolved.guildOnly && !(message.channel instanceof TextChannel)) return; let hasUserPerms: boolean; - if (resolved.permissions.users) { + if (resolved.permissions.users.length > 0) { hasUserPerms = resolved.permissions.users.includes(message.author.id); } let hasRolePerms: boolean = false; From 5ae041c1c7e51d4693babb4f642b9c430aedbe67 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 22:31:14 -0400 Subject: [PATCH 39/71] fix command handler issue --- src/events/messageCreate.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index bfa775a..3459c26 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -19,8 +19,10 @@ export default class { if (!resolved) return; if (resolved.guildOnly && !(message.channel instanceof TextChannel)) return; let hasUserPerms: boolean; - if (resolved.permissions.users.length > 0) { + if (resolved.permissions.users) { hasUserPerms = resolved.permissions.users.includes(message.author.id); + } else { + hasUserPerms = true; } let hasRolePerms: boolean = false; if (resolved.permissions.roles) { From 663f87debd9c130db66045d6f6a781827b662cfc Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 22:35:43 -0400 Subject: [PATCH 40/71] fix command handler issue --- src/events/messageCreate.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index 3459c26..fc18b79 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -28,6 +28,7 @@ export default class { if (resolved.permissions.roles) { for (const role of resolved.permissions.roles) { if (message.member && message.member.roles.includes(role)) { + this.client.signale.debug(message.member.roles.includes(role)); hasRolePerms = true; break; } } From e0750f7787e826f0233b170bc825dc8879728f26 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 22:38:02 -0400 Subject: [PATCH 41/71] fix command handler issue --- src/events/messageCreate.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index fc18b79..5f5e4e1 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -28,12 +28,12 @@ export default class { if (resolved.permissions.roles) { for (const role of resolved.permissions.roles) { if (message.member && message.member.roles.includes(role)) { - this.client.signale.debug(message.member.roles.includes(role)); + // this.client.signale.debug(message.member.roles.includes(role)); hasRolePerms = true; break; } } } - if (!hasRolePerms && !hasUserPerms) return; + if (!hasRolePerms || !hasUserPerms) return; if (!resolved.enabled) { message.channel.createMessage(`***${this.client.stores.emojis.error} This command has been disabled***`); return; } const args: string[] = noPrefix.slice(1); resolved.run(message, args); From 51c8b12e840af82db23709171685e97c8a178d18 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 22:41:34 -0400 Subject: [PATCH 42/71] fix command handler issue --- src/events/messageCreate.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index 5f5e4e1..fe5cc23 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -19,6 +19,7 @@ export default class { if (!resolved) return; if (resolved.guildOnly && !(message.channel instanceof TextChannel)) return; let hasUserPerms: boolean; + this.client.signale.debug(hasUserPerms); if (resolved.permissions.users) { hasUserPerms = resolved.permissions.users.includes(message.author.id); } else { @@ -27,13 +28,17 @@ export default class { let hasRolePerms: boolean = false; if (resolved.permissions.roles) { for (const role of resolved.permissions.roles) { + this.client.signale.debug(message.member.roles.includes(role)); if (message.member && message.member.roles.includes(role)) { // this.client.signale.debug(message.member.roles.includes(role)); hasRolePerms = true; break; } } } - if (!hasRolePerms || !hasUserPerms) return; + this.client.signale.debug('---'); + this.client.signale.debug(hasUserPerms); + this.client.signale.debug(hasRolePerms); + if (!hasRolePerms && !hasUserPerms) return; if (!resolved.enabled) { message.channel.createMessage(`***${this.client.stores.emojis.error} This command has been disabled***`); return; } const args: string[] = noPrefix.slice(1); resolved.run(message, args); From 0f38580f1dcf42354b3da258392b58011ae373eb Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 22:50:41 -0400 Subject: [PATCH 43/71] fix command handler issue --- src/events/messageCreate.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index fe5cc23..c55a82a 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -19,11 +19,8 @@ export default class { if (!resolved) return; if (resolved.guildOnly && !(message.channel instanceof TextChannel)) return; let hasUserPerms: boolean; - this.client.signale.debug(hasUserPerms); if (resolved.permissions.users) { hasUserPerms = resolved.permissions.users.includes(message.author.id); - } else { - hasUserPerms = true; } let hasRolePerms: boolean = false; if (resolved.permissions.roles) { @@ -35,6 +32,10 @@ export default class { } } } + if (!resolved.permissions.users && !resolved.permissions.roles) { + hasUserPerms = true; + hasRolePerms = true; + } this.client.signale.debug('---'); this.client.signale.debug(hasUserPerms); this.client.signale.debug(hasRolePerms); From 9bf9440f684925424991417309a4a37236ea4298 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 22:52:22 -0400 Subject: [PATCH 44/71] fix command handler issue --- src/events/messageCreate.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index c55a82a..743d7b5 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -36,9 +36,6 @@ export default class { hasUserPerms = true; hasRolePerms = true; } - this.client.signale.debug('---'); - this.client.signale.debug(hasUserPerms); - this.client.signale.debug(hasRolePerms); if (!hasRolePerms && !hasUserPerms) return; if (!resolved.enabled) { message.channel.createMessage(`***${this.client.stores.emojis.error} This command has been disabled***`); return; } const args: string[] = noPrefix.slice(1); From 62be202a2e203fa6c0e97e4d45dd22d367f2d032 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 23:04:35 -0400 Subject: [PATCH 45/71] trim whitespace from args --- src/commands/announce.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/announce.ts b/src/commands/announce.ts index 7050077..de33fb3 100644 --- a/src/commands/announce.ts +++ b/src/commands/announce.ts @@ -17,8 +17,8 @@ export default class Announce extends Command { try { if (!args.length) return this.client.commands.get('help').run(message, [this.name]); const notification = await message.channel.createMessage(`${this.client.stores.emojis.loading} ***Sending announcement, please wait...***`); - if (args[0] === '-e') await this.client.util.exec(`echo "\n\n**************************************************************************\nEMERGENCY SYSTEM BROADCAST MESSAGE | Library of Code sp-us (root enforced)\n--------------------------------------------------------------------------\n\n\n${args.slice(1).join(' ')}\n\n\n\n\n\n\n\n\n\n\n\n\n" | wall -n`); - else await this.client.util.exec(`echo "\nSYSTEM BROADCAST MESSAGE | Library of Code sp-us (root enforced)\n\n\n${args.join(' ')}" | wall -n`); + if (args[0] === '-e') await this.client.util.exec(`echo "\n\n**************************************************************************\nEMERGENCY SYSTEM BROADCAST MESSAGE | Library of Code sp-us (root enforced)\n--------------------------------------------------------------------------\n\n\n${args.slice(1).join(' ').trim()}\n\n\n\n\n\n\n\n\n\n\n\n\n" | wall -n`); + else await this.client.util.exec(`echo "\nSYSTEM BROADCAST MESSAGE | Library of Code sp-us (root enforced)\n\n\n${args.join(' ').trim()}" | wall -n`); message.delete(); return notification.edit(`${this.client.stores.emojis.success} ***Sent${args[0] === '-e' ? ' emergency' : ''} announcement to all active terminals***`); } catch (error) { From 8c887192e981bac0e7b7d50c08746ec2535d03c0 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 23:04:49 -0400 Subject: [PATCH 46/71] commands that req arguments w/o produce help cmd --- src/commands/cwg.ts | 1 + src/commands/lock.ts | 1 + src/commands/modlogs.ts | 1 + src/commands/sysinfo.ts | 2 +- src/commands/unlock.ts | 1 + 5 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/commands/cwg.ts b/src/commands/cwg.ts index 593f531..5b2df4f 100644 --- a/src/commands/cwg.ts +++ b/src/commands/cwg.ts @@ -16,6 +16,7 @@ export default class CWG extends Command { } public async run(message: Message, args?: string[]) { + if (!args.length) return this.client.commands.get('help').run(message, [this.name]); /* args[1] should be the user's ID OR account username; required args[2] should be the domain; required diff --git a/src/commands/lock.ts b/src/commands/lock.ts index f1ad4e7..e9b7d89 100644 --- a/src/commands/lock.ts +++ b/src/commands/lock.ts @@ -16,6 +16,7 @@ export default class Lock extends Command { public async run(message: Message, args: string[]) { // eslint-disable-line try { + if (!args.length) return this.client.commands.get('help').run(message, [this.name]); const account = await this.client.db.Account.findOne({ $or: [{ account: args[0] }, { userID: args[0].replace(/[<@!>]/gi, '') }] }); if (!account) return message.channel.createMessage(`***${this.client.stores.emojis.error} Cannot find user.***`); if (account.locked) return message.channel.createMessage(`***${this.client.stores.emojis.error} This account is already locked.***`); diff --git a/src/commands/modlogs.ts b/src/commands/modlogs.ts index b21a36e..d62e46e 100644 --- a/src/commands/modlogs.ts +++ b/src/commands/modlogs.ts @@ -16,6 +16,7 @@ export default class Modlogs extends Command { public async run(message: Message, args: string[]) { try { + if (!args.length) return this.client.commands.get('help').run(message, [this.name]); const msg: Message = await message.channel.createMessage(`***${this.client.stores.emojis.loading} Locating modlogs...***`); const query = await this.client.db.Moderation.find({ $or: [{ username: args.join(' ') }, { userID: args.filter((a) => a)[0].replace(/[<@!>]/g, '') }] }); if (!query.length) return msg.edit(`***${this.client.stores.emojis.error} Cannot locate modlogs for ${args.join(' ')}***`); diff --git a/src/commands/sysinfo.ts b/src/commands/sysinfo.ts index be7601c..3f880a2 100644 --- a/src/commands/sysinfo.ts +++ b/src/commands/sysinfo.ts @@ -27,7 +27,7 @@ export default class SysInfo extends Command { embed.addField('Load Average (last 15 minutes)', os.loadavg()[2].toFixed(3), true); embed.addField('Memory/RAM', `${usedMemory} / ${dataConversion(totalmem())}`, true); embed.addField('Network Interfaces (IPv4)', os.networkInterfaces().eth0.filter((r) => r.family === 'IPv4')[0].address, true); - embed.addField('Network Interfaces (IPv6)', os.networkInterfaces().eth0.filter((r) => r.family === 'IPv6')[0].address, true); + embed.addField('Network Interfaces (IPv6)', os.networkInterfaces().eth0.filter((r) => r.family === 'IPv6')[0].address.replace(/:/gi, '\:'), true); // eslint-disable-line embed.setFooter(this.client.user.username, this.client.user.avatarURL); embed.setTimestamp(); // @ts-ignore diff --git a/src/commands/unlock.ts b/src/commands/unlock.ts index b16a9d8..5174282 100644 --- a/src/commands/unlock.ts +++ b/src/commands/unlock.ts @@ -14,6 +14,7 @@ export default class Unlock extends Command { public async run(message: Message, args: string[]) { // eslint-disable-line try { + if (!args.length) return this.client.commands.get('help').run(message, [this.name]); const account = await this.client.db.Account.findOne({ $or: [{ account: args[0] }, { userID: args[0].replace(/[<@!>]/gi, '') }] }); if (!account) return message.channel.createMessage(`***${this.client.stores.emojis.error} Cannot find user.***`); if (!account.locked) return message.channel.createMessage(`***${this.client.stores.emojis.error} This account is already unlocked.***`); From 3addb4e71ab6da45206065ac3161e15fc1d75db8 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 23:05:24 -0400 Subject: [PATCH 47/71] fix mongoose deprecation warnings --- src/Client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Client.ts b/src/Client.ts index 59bd6ff..1adade3 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -90,7 +90,7 @@ export default class Client extends Eris.Client { delete require.cache[require.resolve(`./events/${file}`)]; }); - await mongoose.connect(config.mongoURL); + await mongoose.connect(config.mongoURL, { useNewUrlParser: true, useUnifiedTopology: true }); await this.connect(); } } From f59aa9dc1e297dda4d291071c666ff924fc8aa16 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 23:07:55 -0400 Subject: [PATCH 48/71] rm messageCreate issue --- src/events/messageCreate.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index 743d7b5..a263db7 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -25,7 +25,6 @@ export default class { let hasRolePerms: boolean = false; if (resolved.permissions.roles) { for (const role of resolved.permissions.roles) { - this.client.signale.debug(message.member.roles.includes(role)); if (message.member && message.member.roles.includes(role)) { // this.client.signale.debug(message.member.roles.includes(role)); hasRolePerms = true; break; From 353a4d813702f279e18cde55337503a9ca98324c Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 23:08:45 -0400 Subject: [PATCH 49/71] fix issue in loadFunctions func --- src/Client.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Client.ts b/src/Client.ts index 1adade3..5e813e0 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -54,6 +54,7 @@ export default class Client extends Eris.Client { private async loadFunctions() { const functions = await fs.readdir('./functions'); functions.forEach(async (func) => { + if (func === 'index.ts') return; try { require(`./functions/${func}`).default(this); } catch (error) { From a263b91551eddf1d27720e456fc0bc1e384fe71e Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 23:38:23 -0400 Subject: [PATCH 50/71] push changes to fix query in lock/unlock --- src/commands/lock.ts | 2 +- src/commands/unlock.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/lock.ts b/src/commands/lock.ts index e9b7d89..544f2e6 100644 --- a/src/commands/lock.ts +++ b/src/commands/lock.ts @@ -17,7 +17,7 @@ export default class Lock extends Command { public async run(message: Message, args: string[]) { // eslint-disable-line try { if (!args.length) return this.client.commands.get('help').run(message, [this.name]); - const account = await this.client.db.Account.findOne({ $or: [{ account: args[0] }, { userID: args[0].replace(/[<@!>]/gi, '') }] }); + const account = await this.client.db.Account.findOne({ $or: [{ username: args[0] }, { userID: args[0].replace(/[<@!>]/gi, '') }] }); if (!account) return message.channel.createMessage(`***${this.client.stores.emojis.error} Cannot find user.***`); if (account.locked) return message.channel.createMessage(`***${this.client.stores.emojis.error} This account is already locked.***`); const edit = await message.channel.createMessage(`***${this.client.stores.emojis.loading} Locking account...***`); diff --git a/src/commands/unlock.ts b/src/commands/unlock.ts index 5174282..09befc9 100644 --- a/src/commands/unlock.ts +++ b/src/commands/unlock.ts @@ -15,7 +15,7 @@ export default class Unlock extends Command { public async run(message: Message, args: string[]) { // eslint-disable-line try { if (!args.length) return this.client.commands.get('help').run(message, [this.name]); - const account = await this.client.db.Account.findOne({ $or: [{ account: args[0] }, { userID: args[0].replace(/[<@!>]/gi, '') }] }); + const account = await this.client.db.Account.findOne({ $or: [{ username: args[0] }, { userID: args[0].replace(/[<@!>]/gi, '') }] }); if (!account) return message.channel.createMessage(`***${this.client.stores.emojis.error} Cannot find user.***`); if (!account.locked) return message.channel.createMessage(`***${this.client.stores.emojis.error} This account is already unlocked.***`); const edit = await message.channel.createMessage(`***${this.client.stores.emojis.loading} Unlocking account...***`); From 661beb37b22213c3b307a1e2ea1ca02e3979cf3b Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 23:39:44 -0400 Subject: [PATCH 51/71] logID in schema should be string not number --- src/models/Moderation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/Moderation.ts b/src/models/Moderation.ts index 2bafd1f..9c15298 100644 --- a/src/models/Moderation.ts +++ b/src/models/Moderation.ts @@ -25,7 +25,7 @@ export interface ModerationInterface extends Document { const Moderation: Schema = new Schema({ username: String, userID: String, - logID: Number, + logID: String, moderatorID: String, reason: String, type: String, From 7def0455cfcde3ec1659391cb15659ade58c765f Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 23:42:08 -0400 Subject: [PATCH 52/71] fix typo --- src/commands/unlock.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/unlock.ts b/src/commands/unlock.ts index 09befc9..690e491 100644 --- a/src/commands/unlock.ts +++ b/src/commands/unlock.ts @@ -34,7 +34,7 @@ export default class Unlock extends Command { await moderation.save(); edit.edit(`***${this.client.stores.emojis.success} Account ${account.username} has been unlocked by Supervisor ${message.author.username}#${message.author.discriminator}.***`); const embed = new RichEmbed(); - embed.setTitle('Account Infraction | UnLock'); + embed.setTitle('Account Infraction | Unlock'); embed.setColor(15158332); embed.addField('User', `${account.username} | <@${account.userID}>`, true); embed.addField('Supervisor', `<@${message.author.id}>`, true); From d6f274d4a78222c6555b864ce59836c3a354a220 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 23:47:55 -0400 Subject: [PATCH 53/71] modlogs cmd fix --- src/commands/modlogs.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/commands/modlogs.ts b/src/commands/modlogs.ts index d62e46e..9a40fd4 100644 --- a/src/commands/modlogs.ts +++ b/src/commands/modlogs.ts @@ -49,6 +49,7 @@ export default class Modlogs extends Command { embed.setAuthor('Library of Code | Cloud Services', this.client.user.avatarURL, 'https://libraryofcode.org/'); embed.setTitle('Cloud Modlogs/Infractions'); embed.setFooter(`Requested by ${message.author.username}#${message.author.discriminator}`, message.author.avatarURL); + this.client.signale.debug(l); l.forEach((f) => embed.addField(f.name, f.value, f.inline)); embed.setTimestamp(); embed.setColor(3447003); From 2ec2c95d9cc1a688dc92c8b83a50a0d18c4e164a Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 23:51:26 -0400 Subject: [PATCH 54/71] modlogs cmd fix --- src/commands/modlogs.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/commands/modlogs.ts b/src/commands/modlogs.ts index 9a40fd4..e893aa0 100644 --- a/src/commands/modlogs.ts +++ b/src/commands/modlogs.ts @@ -37,6 +37,7 @@ export default class Modlogs extends Command { } const value = `**Account name:** ${username}\n**Moderator:** <@${moderatorID}>\n**Reason:** ${reason}\n**Date:** ${date.toLocaleString('en-us')} EST`; const inline = true; + this.client.signale.debug(name); return { name, value, inline }; }); const users = [...new Set(query.map((log) => log.userID))].map((u) => `<@${u}>`); From c1e10751e350419211bf8e7c8e7c2d22bec4c006 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 23:53:15 -0400 Subject: [PATCH 55/71] modlogs cmd fix --- src/commands/modlogs.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/commands/modlogs.ts b/src/commands/modlogs.ts index e893aa0..ae6e9f6 100644 --- a/src/commands/modlogs.ts +++ b/src/commands/modlogs.ts @@ -23,6 +23,8 @@ export default class Modlogs extends Command { const formatted = query.map((log) => { const { username, moderatorID, reason, type, date } = log; + this.client.signale.debug(log); + this.client.signale.debug(type); let name: string; if (type === 0) { name = 'Create'; From a87e108ee640bc1b991df2ea56599baa297027be Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 23:54:55 -0400 Subject: [PATCH 56/71] type should be number --- src/models/Moderation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/Moderation.ts b/src/models/Moderation.ts index 9c15298..67bd184 100644 --- a/src/models/Moderation.ts +++ b/src/models/Moderation.ts @@ -28,7 +28,7 @@ const Moderation: Schema = new Schema({ logID: String, moderatorID: String, reason: String, - type: String, + type: Number, date: Date, expiration: { date: Date, From 9e88f0f8fec2f0f6a5968460f281b67ea2084c4d Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 23:58:41 -0400 Subject: [PATCH 57/71] modlogs cmd fix --- src/commands/modlogs.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/commands/modlogs.ts b/src/commands/modlogs.ts index ae6e9f6..227b5c9 100644 --- a/src/commands/modlogs.ts +++ b/src/commands/modlogs.ts @@ -23,8 +23,6 @@ export default class Modlogs extends Command { const formatted = query.map((log) => { const { username, moderatorID, reason, type, date } = log; - this.client.signale.debug(log); - this.client.signale.debug(type); let name: string; if (type === 0) { name = 'Create'; @@ -39,7 +37,6 @@ export default class Modlogs extends Command { } const value = `**Account name:** ${username}\n**Moderator:** <@${moderatorID}>\n**Reason:** ${reason}\n**Date:** ${date.toLocaleString('en-us')} EST`; const inline = true; - this.client.signale.debug(name); return { name, value, inline }; }); const users = [...new Set(query.map((log) => log.userID))].map((u) => `<@${u}>`); @@ -59,7 +56,12 @@ export default class Modlogs extends Command { return embed; }); - createPaginationEmbed(message, this.client, embeds, {}, msg); + if (embeds.length === 1) { + // @ts-ignore + message.channel.createMessage({ embed: embeds[0] }); + } else { + createPaginationEmbed(message, this.client, embeds, {}, msg); + } return msg; } catch (error) { return this.client.util.handleError(error, message, this); From d95e4d8efe8d0dd8c1c42337337cac072431cfed Mon Sep 17 00:00:00 2001 From: Matthew R Date: Mon, 28 Oct 2019 00:00:07 -0400 Subject: [PATCH 58/71] should set locked to false --- src/commands/unlock.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/commands/unlock.ts b/src/commands/unlock.ts index 690e491..8e88998 100644 --- a/src/commands/unlock.ts +++ b/src/commands/unlock.ts @@ -21,6 +21,7 @@ export default class Unlock extends Command { const edit = await message.channel.createMessage(`***${this.client.stores.emojis.loading} Unlocking account...***`); if (account.username === 'matthew' || account.root) return edit.edit(`***${this.client.stores.emojis.error} Permission denied.***`); await this.client.util.exec(`unlock ${account.username}`); + await account.updateOne({ locked: false }); const moderation = new this.client.db.Moderation({ username: account.username, From 8d8fa5b10e736fb588ae3375082cf1f555e2ffe9 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Mon, 28 Oct 2019 00:00:54 -0400 Subject: [PATCH 59/71] fix deprecation warning --- src/commands/lock.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/lock.ts b/src/commands/lock.ts index 544f2e6..9281f69 100644 --- a/src/commands/lock.ts +++ b/src/commands/lock.ts @@ -23,7 +23,7 @@ export default class Lock extends Command { const edit = await message.channel.createMessage(`***${this.client.stores.emojis.loading} Locking account...***`); if (account.username === 'matthew' || account.root) return edit.edit(`***${this.client.stores.emojis.error} Permission denied.***`); await this.client.util.exec(`lock ${account.username}`); - await account.update({ locked: true }); + await account.updateOne({ locked: true }); const expiry = new Date(); const lockLength = args[1].match(/[a-z]+|[^a-z]+/gi); From 998229b4947ce43a46c8a30b58525722c41fbdcf Mon Sep 17 00:00:00 2001 From: Matthew R Date: Mon, 28 Oct 2019 00:01:05 -0400 Subject: [PATCH 60/71] should set locked to false --- src/functions/checkLock.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/functions/checkLock.ts b/src/functions/checkLock.ts index 791d561..be1b924 100644 --- a/src/functions/checkLock.ts +++ b/src/functions/checkLock.ts @@ -13,7 +13,8 @@ export default function checkLock(client: Client) { const account = await client.db.Account.findOne({ username: moderation.username }); if (!account) return; await client.util.exec(`unlock ${account.username}`); - await moderation.update({ 'expiration.processed': true }); + await moderation.updateOne({ 'expiration.processed': true }); + await account.updateOne({ locked: false }); const mod = new client.db.Moderation({ username: account.username, userID: account.userID, From 07001f5b6ee610f2272e35163bc72d11776e0722 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Mon, 28 Oct 2019 00:01:30 -0400 Subject: [PATCH 61/71] remove debug from modlogs --- src/commands/modlogs.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/commands/modlogs.ts b/src/commands/modlogs.ts index 227b5c9..ad3f03b 100644 --- a/src/commands/modlogs.ts +++ b/src/commands/modlogs.ts @@ -49,7 +49,6 @@ export default class Modlogs extends Command { embed.setAuthor('Library of Code | Cloud Services', this.client.user.avatarURL, 'https://libraryofcode.org/'); embed.setTitle('Cloud Modlogs/Infractions'); embed.setFooter(`Requested by ${message.author.username}#${message.author.discriminator}`, message.author.avatarURL); - this.client.signale.debug(l); l.forEach((f) => embed.addField(f.name, f.value, f.inline)); embed.setTimestamp(); embed.setColor(3447003); From 08039c6e9482ee1e230cee62c931f35530052837 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Mon, 28 Oct 2019 00:07:42 -0400 Subject: [PATCH 62/71] fix lock issue --- src/commands/lock.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/lock.ts b/src/commands/lock.ts index 9281f69..163cbc5 100644 --- a/src/commands/lock.ts +++ b/src/commands/lock.ts @@ -42,7 +42,7 @@ export default class Lock extends Command { type: 2, date: new Date(), expiration: { - expirationDate: momentMilliseconds ? expiry : null, + date: momentMilliseconds ? expiry : null, processed, }, }); From 8fea49959759b34e703b9bffed4413b2a6caa18a Mon Sep 17 00:00:00 2001 From: Matthew R Date: Mon, 28 Oct 2019 00:11:01 -0400 Subject: [PATCH 63/71] fix lock issue --- src/commands/lock.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/commands/lock.ts b/src/commands/lock.ts index 163cbc5..5ff2d29 100644 --- a/src/commands/lock.ts +++ b/src/commands/lock.ts @@ -33,6 +33,8 @@ export default class Lock extends Command { let processed: boolean = false; if (!momentMilliseconds) processed = true; + this.client.signale.debug(expiry); + this.client.signale.debug(momentMilliseconds); const moderation = new this.client.db.Moderation({ username: account.username, userID: account.userID, From 3f18050a275dbeccf8a6c9f8e30239df873968bf Mon Sep 17 00:00:00 2001 From: Matthew R Date: Mon, 28 Oct 2019 00:12:16 -0400 Subject: [PATCH 64/71] fix lock issue --- src/commands/lock.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/commands/lock.ts b/src/commands/lock.ts index 5ff2d29..af561ef 100644 --- a/src/commands/lock.ts +++ b/src/commands/lock.ts @@ -33,6 +33,7 @@ export default class Lock extends Command { let processed: boolean = false; if (!momentMilliseconds) processed = true; + this.client.signale.debug(lockLength); this.client.signale.debug(expiry); this.client.signale.debug(momentMilliseconds); const moderation = new this.client.db.Moderation({ From 63d40da837825e49e154630d3725ecae89f590cd Mon Sep 17 00:00:00 2001 From: Matthew R Date: Mon, 28 Oct 2019 00:17:25 -0400 Subject: [PATCH 65/71] fix lock --- src/commands/lock.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/lock.ts b/src/commands/lock.ts index af561ef..3a1c20c 100644 --- a/src/commands/lock.ts +++ b/src/commands/lock.ts @@ -28,7 +28,7 @@ export default class Lock extends Command { const expiry = new Date(); const lockLength = args[1].match(/[a-z]+|[^a-z]+/gi); // @ts-ignore - const momentMilliseconds = moment.duration(Number(lockLength[0]), lockLength[1]).asMilliseconds; + const momentMilliseconds = moment.duration(Number(lockLength[0]), lockLength[1]).asMilliseconds(); expiry.setMilliseconds(momentMilliseconds); let processed: boolean = false; if (!momentMilliseconds) processed = true; From 8ccd1cac1fa53892e330be78d7d994cc72c79ee7 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Mon, 28 Oct 2019 00:23:39 -0400 Subject: [PATCH 66/71] delete msg for lock/unlock --- src/commands/lock.ts | 1 + src/commands/unlock.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/commands/lock.ts b/src/commands/lock.ts index 3a1c20c..869443b 100644 --- a/src/commands/lock.ts +++ b/src/commands/lock.ts @@ -59,6 +59,7 @@ export default class Lock extends Command { if ((momentMilliseconds ? args.slice(2).join(' ') : args.slice(1).join(' ')).length > 0) embed.addField('Reason', momentMilliseconds ? args.slice(2).join(' ') : args.slice(1).join(' '), true); embed.setFooter(this.client.user.username, this.client.user.avatarURL); embed.setTimestamp(); + message.delete(); this.client.getDMChannel(account.userID).then((user) => { // @ts-ignore user.createMessage({ embed }).catch(); diff --git a/src/commands/unlock.ts b/src/commands/unlock.ts index 8e88998..c42ec21 100644 --- a/src/commands/unlock.ts +++ b/src/commands/unlock.ts @@ -42,6 +42,7 @@ export default class Unlock extends Command { if (args.slice(1).join(' ').length > 0) embed.addField('Reason', args.slice(1).join(' '), true); embed.setFooter(this.client.user.username, this.client.user.avatarURL); embed.setTimestamp(); + message.delete(); this.client.getDMChannel(account.userID).then((user) => { // @ts-ignore user.createMessage({ embed }).catch(); From a451f153bd4a0720a1c1b20d8d60dbaeefc39b5e Mon Sep 17 00:00:00 2001 From: Matthew R Date: Mon, 28 Oct 2019 00:26:14 -0400 Subject: [PATCH 67/71] Set interval time on checkLock --- src/functions/checkLock.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/functions/checkLock.ts b/src/functions/checkLock.ts index be1b924..5a2fdf7 100644 --- a/src/functions/checkLock.ts +++ b/src/functions/checkLock.ts @@ -39,10 +39,11 @@ export default function checkLock(client: Client) { }); // @ts-ignore client.createMessage('580950455581147146', { embed }); + client.signale.complete(`Unlocked account ${account.username} | Queue date at ${moderation.expiration.date.toLocaleString('en-us')}`); } }); } catch (error) { await client.util.handleError(error); } - }); + }, 10000); } From dcde1d685c2a0dd69099ae82f3926ee4c9a0e917 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Mon, 28 Oct 2019 00:27:43 -0400 Subject: [PATCH 68/71] add lock time in embed --- src/commands/lock.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/commands/lock.ts b/src/commands/lock.ts index 869443b..f67b268 100644 --- a/src/commands/lock.ts +++ b/src/commands/lock.ts @@ -57,6 +57,7 @@ export default class Lock extends Command { embed.addField('User', `${account.username} | <@${account.userID}>`, true); embed.addField('Supervisor', `<@${message.author.id}>`, true); if ((momentMilliseconds ? args.slice(2).join(' ') : args.slice(1).join(' ')).length > 0) embed.addField('Reason', momentMilliseconds ? args.slice(2).join(' ') : args.slice(1).join(' '), true); + embed.addField('Lock Expiration', `${momentMilliseconds ? moment(expiry).format('dddd, MMMM Do YYYY, h:mm:ss A') : 'N/A'}`, true); embed.setFooter(this.client.user.username, this.client.user.avatarURL); embed.setTimestamp(); message.delete(); From 239dd2469a81e023cd8ce8112c5676b26e848676 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Mon, 28 Oct 2019 00:28:20 -0400 Subject: [PATCH 69/71] add lock time in embed --- src/commands/lock.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/lock.ts b/src/commands/lock.ts index f67b268..17576b4 100644 --- a/src/commands/lock.ts +++ b/src/commands/lock.ts @@ -57,7 +57,7 @@ export default class Lock extends Command { embed.addField('User', `${account.username} | <@${account.userID}>`, true); embed.addField('Supervisor', `<@${message.author.id}>`, true); if ((momentMilliseconds ? args.slice(2).join(' ') : args.slice(1).join(' ')).length > 0) embed.addField('Reason', momentMilliseconds ? args.slice(2).join(' ') : args.slice(1).join(' '), true); - embed.addField('Lock Expiration', `${momentMilliseconds ? moment(expiry).format('dddd, MMMM Do YYYY, h:mm:ss A') : 'N/A'}`, true); + embed.addField('Lock Expiration', `${momentMilliseconds ? moment(expiry).format('dddd, MMMM Do YYYY, h:mm:ss A') : 'Indefinitely}`, true); embed.setFooter(this.client.user.username, this.client.user.avatarURL); embed.setTimestamp(); message.delete(); From 79dea2e413b7e8715a8a8cdd8ee355fe86a9f648 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Mon, 28 Oct 2019 00:30:09 -0400 Subject: [PATCH 70/71] add lock time in embed --- src/commands/lock.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/lock.ts b/src/commands/lock.ts index 17576b4..384cd52 100644 --- a/src/commands/lock.ts +++ b/src/commands/lock.ts @@ -57,7 +57,7 @@ export default class Lock extends Command { embed.addField('User', `${account.username} | <@${account.userID}>`, true); embed.addField('Supervisor', `<@${message.author.id}>`, true); if ((momentMilliseconds ? args.slice(2).join(' ') : args.slice(1).join(' ')).length > 0) embed.addField('Reason', momentMilliseconds ? args.slice(2).join(' ') : args.slice(1).join(' '), true); - embed.addField('Lock Expiration', `${momentMilliseconds ? moment(expiry).format('dddd, MMMM Do YYYY, h:mm:ss A') : 'Indefinitely}`, true); + embed.addField('Lock Expiration', `${momentMilliseconds ? moment(expiry).format('dddd, MMMM Do YYYY, h:mm:ss A') : 'Indefinitely'}`, true); embed.setFooter(this.client.user.username, this.client.user.avatarURL); embed.setTimestamp(); message.delete(); From 92f2ca71da3f3107f9ef0fbfbbbaead171452209 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Mon, 28 Oct 2019 00:34:42 -0400 Subject: [PATCH 71/71] should be setINterval not settimeout --- src/functions/checkLock.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/functions/checkLock.ts b/src/functions/checkLock.ts index 5a2fdf7..eb4e3f9 100644 --- a/src/functions/checkLock.ts +++ b/src/functions/checkLock.ts @@ -3,7 +3,7 @@ import { Client } from '..'; import { RichEmbed } from '../class'; export default function checkLock(client: Client) { - setTimeout(async () => { + setInterval(async () => { try { const moderations = await client.db.Moderation.find(); moderations.forEach(async (moderation) => {