diff options
Diffstat (limited to 'src/commands')
-rw-r--r-- | src/commands/config/config.ts | 1 | ||||
-rw-r--r-- | src/commands/dev/reload.ts | 4 | ||||
-rw-r--r-- | src/commands/dev/sh.ts | 8 | ||||
-rw-r--r-- | src/commands/dev/superUser.ts | 39 | ||||
-rw-r--r-- | src/commands/info/botInfo.ts | 28 | ||||
-rw-r--r-- | src/commands/moderation/evidence.ts | 10 | ||||
-rw-r--r-- | src/commands/moulberry-bush/report.ts | 23 | ||||
-rw-r--r-- | src/commands/utilities/price.ts | 1 | ||||
-rw-r--r-- | src/commands/utilities/whoHasRole.ts | 9 |
9 files changed, 71 insertions, 52 deletions
diff --git a/src/commands/config/config.ts b/src/commands/config/config.ts index 8362144..0c466e6 100644 --- a/src/commands/config/config.ts +++ b/src/commands/config/config.ts @@ -94,7 +94,6 @@ export default class SettingsCommand extends BushCommand { ] }; }), - slashGuilds: ['516977525906341928', '812400566235430912'], channel: 'guild', clientPermissions: ['SEND_MESSAGES'], userPermissions: ['SEND_MESSAGES', 'MANAGE_GUILD'], diff --git a/src/commands/dev/reload.ts b/src/commands/dev/reload.ts index 91cabfb..f7afbca 100644 --- a/src/commands/dev/reload.ts +++ b/src/commands/dev/reload.ts @@ -45,7 +45,9 @@ export default class ReloadCommand extends BushCommand { return message.util.send(`🔁 Successfully reloaded! (${new Date().getTime() - s.getTime()}ms)`); } catch (e) { if (output!) void client.logger.error('reloadCommand', output); - return message.util.send(`An error occurred while reloading:\n${await util.codeblock(e?.stack || e, 2048 - 34, 'js')}`); + return message.util.send( + `An error occurred while reloading:\n${await util.codeblock(e?.stack || e, 2048 - 34, 'js', true)}` + ); } } } diff --git a/src/commands/dev/sh.ts b/src/commands/dev/sh.ts index 93f0d40..067a0e6 100644 --- a/src/commands/dev/sh.ts +++ b/src/commands/dev/sh.ts @@ -47,7 +47,7 @@ export default class ShCommand extends BushCommand { .setFooter(message.author.tag, message.author.avatarURL({ dynamic: true }) ?? undefined) .setTimestamp() .setTitle('Shell Command') - .addField('📥 Input', await util.codeblock(input, 1024, 'sh')) + .addField('📥 Input', await util.codeblock(input, 1024, 'sh', true)) .addField('Running', util.emojis.loading); await message.util.reply({ embeds: [embed] }); @@ -69,15 +69,15 @@ export default class ShCommand extends BushCommand { .setColor(util.colors.success) .spliceFields(1, 1); - if (stdout) embed.addField('📤 stdout', await util.codeblock(stdout, 1024, 'json')); - if (stderr) embed.addField('📤 stderr', await util.codeblock(stderr, 1024, 'json')); + if (stdout) embed.addField('📤 stdout', await util.codeblock(stdout, 1024, 'json', true)); + if (stderr) embed.addField('📤 stderr', await util.codeblock(stderr, 1024, 'json', true)); } catch (e) { embed .setTitle(`${util.emojis.errorFull} An error occurred while executing.`) .setColor(util.colors.error) .spliceFields(1, 1); - embed.addField('📤 Output', await util.codeblock(e?.stack, 1024, 'js')); + embed.addField('📤 Output', await util.codeblock(e?.stack, 1024, 'js', true)); } await message.util.edit({ embeds: [embed] }); } diff --git a/src/commands/dev/superUser.ts b/src/commands/dev/superUser.ts index 4bab8a1..a36972b 100644 --- a/src/commands/dev/superUser.ts +++ b/src/commands/dev/superUser.ts @@ -42,36 +42,29 @@ export default class SuperUserCommand extends BushCommand { public override async exec( message: BushMessage | BushSlashMessage, - args: { action: 'add' | 'remove'; user: User } + { action, user }: { action: 'add' | 'remove'; user: User } ): Promise<unknown> { if (!message.author.isOwner()) return await message.util.reply(`${util.emojis.error} Only my developers can run this command.`); - if (!args.user?.id) - return await message.util.reply( - `${util.emojis.error} I fucked up here is args ${await util.inspectCleanRedactCodeblock(args, 'ts')}` - ); - const superUsers: string[] = (await Global.findByPk(client.config.environment))?.superUsers ?? []; - let success; - if (args.action === 'add') { - if (superUsers.includes(args.user.id)) { - return message.util.reply(`${util.emojis.warn} \`${args.user.tag}\` is already a superuser.`); - } - success = await util.insertOrRemoveFromGlobal('add', 'superUsers', args.user.id).catch(() => false); - } else { - if (!superUsers.includes(args.user.id)) { - return message.util.reply(`${util.emojis.warn} \`${args.user.tag}\` is not superuser.`); - } - success = await util.insertOrRemoveFromGlobal('remove', 'superUsers', args.user.id).catch(() => false); - } + + if (action === 'add' ? superUsers.includes(user.id) : !superUsers.includes(user.id)) + return message.util.reply(`${util.emojis.warn} \`${user.tag}\` is ${action === 'add' ? 'already' : 'not'} a superuser.`); + + const success = await util.insertOrRemoveFromGlobal(action, 'superUsers', user.id).catch(() => false); + if (success) { - const responses = [args.action == 'remove' ? '' : 'made', args.action == 'remove' ? 'is no longer' : '']; - return message.util.reply(`${util.emojis.success} ${responses[0]} \`${args.user.tag}\` ${responses[1]} a superuser.`); + return await message.util.reply( + `${util.emojis.success} ${action == 'remove' ? '' : 'made'} \`${user.tag}\` ${ + action == 'remove' ? 'is no longer ' : '' + }a superuser.` + ); } else { - const response = [args.action == 'remove' ? `removing` : 'making', args.action == 'remove' ? `from` : 'to']; - return message.util.reply( - `${util.emojis.error} There was an error ${response[0]} \`${args.user.tag}\` ${response[1]} the superuser list.` + return await message.util.reply( + `${util.emojis.error} There was an error ${action == 'remove' ? `removing` : 'making'} \`${user.tag}\` ${ + action == 'remove' ? `from` : 'to' + } the superuser list.` ); } } diff --git a/src/commands/info/botInfo.ts b/src/commands/info/botInfo.ts index 37a63ce..45c3dd8 100644 --- a/src/commands/info/botInfo.ts +++ b/src/commands/info/botInfo.ts @@ -1,5 +1,7 @@ import { BushCommand, BushMessage, BushSlashMessage } from '@lib'; import { MessageEmbed, version as discordJSVersion } from 'discord.js'; +import * as os from 'os'; +import prettyBytes from 'pretty-bytes'; export default class BotInfoCommand extends BushCommand { public constructor() { @@ -18,6 +20,19 @@ export default class BotInfoCommand extends BushCommand { } public override async exec(message: BushMessage | BushSlashMessage): Promise<void> { + enum Platform { + aix = 'AIX', + android = 'Android', + darwin = 'MacOS', + freebsd = 'FreeBSD', + linux = 'Linux', + openbsd = 'OpenBSD', + sunos = 'SunOS', + win32 = 'Windows', + cygwin = 'Cygwin', + netbsd = 'NetBSD' + } + const developers = (await util.mapIDs(client.config.owners)).map((u) => u?.tag).join('\n'); const currentCommit = (await util.shell('git rev-parse HEAD')).stdout.replace('\n', ''); let repoUrl = (await util.shell('git remote get-url origin')).stdout.replace('\n', ''); @@ -25,6 +40,19 @@ export default class BotInfoCommand extends BushCommand { const embed = new MessageEmbed() .setTitle('Bot Info:') .addField('**Uptime**', util.humanizeDuration(client.uptime!), true) + .addField( + '**Memory Usage**', + `System: ${prettyBytes(os.totalmem() - os.freemem(), { binary: true })}/${prettyBytes(os.totalmem(), { + binary: true + })}\nHeap: ${prettyBytes(process.memoryUsage().heapUsed, { binary: true })}/${prettyBytes( + process.memoryUsage().heapTotal, + { binary: true } + )}`, + true + ) + .addField('**CPU Usage**', `${client.stats.cpu}%`, true) + .addField('**Platform**', Platform[process.platform], true) + .addField('**Commands Used**', `${client.stats.commandsUsed}`, true) .addField('**Servers**', client.guilds.cache.size.toLocaleString(), true) .addField('**Users**', client.users.cache.size.toLocaleString(), true) .addField('**Discord.js Version**', discordJSVersion, true) diff --git a/src/commands/moderation/evidence.ts b/src/commands/moderation/evidence.ts index 96c3944..ae0a128 100644 --- a/src/commands/moderation/evidence.ts +++ b/src/commands/moderation/evidence.ts @@ -12,7 +12,7 @@ export default class EvidenceCommand extends BushCommand { }, args: [ { - id: 'required_argument', + id: 'case', type: 'string', prompt: { start: 'What would you like to set your first argument to be?', @@ -21,7 +21,7 @@ export default class EvidenceCommand extends BushCommand { } }, { - id: 'optional_argument', + id: 'evidence', type: 'string', prompt: { start: 'What would you like to set your second argument to be?', @@ -33,13 +33,13 @@ export default class EvidenceCommand extends BushCommand { slash: true, slashOptions: [ { - name: 'required_argument', + name: 'case', description: 'What would you like to set your first argument to be?', type: 'STRING', required: true }, { - name: 'optional_argument', + name: 'evidence', description: 'What would you like to set your second argument to be?', type: 'STRING', required: false @@ -55,6 +55,6 @@ export default class EvidenceCommand extends BushCommand { } public override async exec(message: BushMessage | BushSlashMessage): Promise<unknown> { - return await message.util.reply(`${util.emojis.error} Do not use the template command.`); + return await message.util.reply(`${util.emojis.error} Soon:tm:.`); } } diff --git a/src/commands/moulberry-bush/report.ts b/src/commands/moulberry-bush/report.ts index 878337b..e387e7d 100644 --- a/src/commands/moulberry-bush/report.ts +++ b/src/commands/moulberry-bush/report.ts @@ -35,7 +35,6 @@ export default class ReportCommand extends BushCommand { ], clientPermissions: ['EMBED_LINKS', 'SEND_MESSAGES'], channel: 'guild', - restrictedGuilds: ['516977525906341928'], slash: true, slashOptions: [ { @@ -50,8 +49,7 @@ export default class ReportCommand extends BushCommand { type: 'STRING', required: false } - ], - slashGuilds: ['516977525906341928'] + ] }); } @@ -59,8 +57,11 @@ export default class ReportCommand extends BushCommand { message: BushMessage, { member, evidence }: { member: GuildMember; evidence: string } ): Promise<unknown> { - if (message.guild!.id != client.consts.mappings.guilds.bush) - return await message.util.reply(`${util.emojis.error} This command can only be run in Moulberry's bush.`); + if (!message.guild || !(await message.guild.hasFeature('reporting'))) + return await message.util.reply( + `${util.emojis.error} This command can only be used in servers where reporting is enabled.` + ); + if (!member) return await message.util.reply(`${util.emojis.error} Choose someone to report`); if (member.user.id === '322862723090219008') return await message.util.reply({ @@ -70,8 +71,10 @@ export default class ReportCommand extends BushCommand { if (member.user.bot) return await message.util.reply(`${util.emojis.error} You cannot report a bot <:WeirdChamp:756283321301860382>.`); - //// if (!evidence) evidence = 'No Evidence.'; - //todo: Add channel id to db instead of hard coding it & allow in any guild + const reportChannelId = (await message.guild.getSetting('logChannels')).report; + if (!reportChannelId) + return await message.util.reply(`${util.emojis.error} This server has not setup a report logging channel.`); + //The formatting of the report is mostly copied from carl since it is pretty good when it actually works const reportEmbed = new MessageEmbed() .setFooter(`Reporter ID: ${message.author.id} Reported ID: ${member.user.id}`) @@ -106,11 +109,11 @@ export default class ReportCommand extends BushCommand { reportEmbed.addField('Attachment', message.attachments.first()!.url); } } - const reportChannel = client.channels.cache.get('782972723654688848') as unknown as BushTextChannel; + const reportChannel = client.channels.cache.get(reportChannelId) as unknown as BushTextChannel; await reportChannel.send({ embeds: [reportEmbed] }).then(async (ReportMessage) => { try { - await ReportMessage.react(util.emojis.success); - await ReportMessage.react(util.emojis.error); + await ReportMessage.react(util.emojis.check); + await ReportMessage.react(util.emojis.cross); } catch { void client.console.warn('ReportCommand', 'Could not react to report message.'); } diff --git a/src/commands/utilities/price.ts b/src/commands/utilities/price.ts index 64d335d..9ef997a 100644 --- a/src/commands/utilities/price.ts +++ b/src/commands/utilities/price.ts @@ -137,7 +137,6 @@ export default class PriceCommand extends BushCommand { threshold: 0.7, ignoreLocation: true })?.search(parsedItem); - client.console.debug(_, 4); parsedItem = _[0]?.item; } diff --git a/src/commands/utilities/whoHasRole.ts b/src/commands/utilities/whoHasRole.ts index 73a9920..f096cee 100644 --- a/src/commands/utilities/whoHasRole.ts +++ b/src/commands/utilities/whoHasRole.ts @@ -1,5 +1,5 @@ import { BushCommand, BushMessage, BushSlashMessage } from '@lib'; -import { Role, Util } from 'discord.js'; +import { CommandInteraction, Role, Util } from 'discord.js'; export default class WhoHasRoleCommand extends BushCommand { public constructor() { @@ -38,15 +38,11 @@ export default class WhoHasRoleCommand extends BushCommand { }); } public override async exec(message: BushMessage | BushSlashMessage, args: { role: Role }): Promise<unknown> { - // console.time('whohasrole1'); + if (message.util.isSlash) await (message.interaction as CommandInteraction).deferReply(); const roleMembers = args.role.members.map((member) => `${member.user} (${Util.escapeMarkdown(member.user.tag)})`); - // console.timeEnd('whohasrole1'); - // console.time('whohasrole2'); const chunkedRoleMembers = util.chunk(roleMembers, 30); - // console.timeEnd('whohasrole2'); - // console.time('whohasrole3'); const title = `${args.role.name}'s Members [\`${args.role.members.size.toLocaleString()}\`]`; const color = util.colors.default; const embedPages = chunkedRoleMembers.map((chunk) => ({ @@ -54,7 +50,6 @@ export default class WhoHasRoleCommand extends BushCommand { description: chunk.join('\n'), color })); - // console.timeEnd('whohasrole3'); return await util.buttonPaginate(message, embedPages, null, true); } |