diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-09-01 22:19:41 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-09-01 22:19:41 -0400 |
commit | 560ed31860a420dcc43571d2e12dd2f51bcee7a8 (patch) | |
tree | 855e0cb50c550bbff63ab675e1102b7608573668 /src | |
parent | 855aa36c46e250fd3063eb200d784903a8c388d3 (diff) | |
download | tanzanite-560ed31860a420dcc43571d2e12dd2f51bcee7a8.tar.gz tanzanite-560ed31860a420dcc43571d2e12dd2f51bcee7a8.tar.bz2 tanzanite-560ed31860a420dcc43571d2e12dd2f51bcee7a8.zip |
cleanup
Diffstat (limited to 'src')
-rw-r--r-- | src/bot.ts | 2 | ||||
-rw-r--r-- | src/commands/admin/channelPermissions.ts | 2 | ||||
-rw-r--r-- | src/commands/admin/roleAll.ts | 11 | ||||
-rw-r--r-- | src/commands/dev/__template.ts | 2 | ||||
-rw-r--r-- | src/commands/dev/test.ts | 39 | ||||
-rw-r--r-- | src/commands/info/color.ts | 9 | ||||
-rw-r--r-- | src/commands/leveling/level.ts | 6 | ||||
-rw-r--r-- | src/commands/leveling/setLevel.ts (renamed from src/commands/dev/setLevel.ts) | 7 | ||||
-rw-r--r-- | src/commands/moderation/_lockdown.ts | 3 | ||||
-rw-r--r-- | src/commands/moulberry-bush/capes.ts | 12 | ||||
-rw-r--r-- | src/commands/moulberry-bush/moulHammer.ts (renamed from src/commands/moulberry-bush/moulHammerCommand.ts) | 0 | ||||
-rw-r--r-- | src/lib/utils/BushConstants.ts | 18 | ||||
-rw-r--r-- | src/tasks/removeExpiredPunishements.ts | 10 |
13 files changed, 56 insertions, 65 deletions
@@ -4,5 +4,5 @@ import config from './config/options'; import { BushClient } from './lib/'; BushClient.preStart(); -const client: BushClient = new BushClient(config); +const client = new BushClient(config); void client.start(); diff --git a/src/commands/admin/channelPermissions.ts b/src/commands/admin/channelPermissions.ts index ea97343..3b8c157 100644 --- a/src/commands/admin/channelPermissions.ts +++ b/src/commands/admin/channelPermissions.ts @@ -71,7 +71,7 @@ export default class ChannelPermissionsCommand extends BushCommand { await channel.permissionOverwrites.create( target.id, { [permission]: permissionState }, - { reason: 'Changing overwrites for mass channel channel perms command' } + { reason: 'Changing overwrites for mass channel perms command' } ); } catch (e) { client.console.debug(e.stack); diff --git a/src/commands/admin/roleAll.ts b/src/commands/admin/roleAll.ts index 2382a4b..7e60f40 100644 --- a/src/commands/admin/roleAll.ts +++ b/src/commands/admin/roleAll.ts @@ -5,7 +5,7 @@ export default class RoleAllCommand extends BushCommand { public constructor() { super('roleAll', { aliases: ['roleall', 'rall'], - category: 'Server Admin', + category: 'admin', description: { content: 'Give a role to every member on the server.', usage: 'roleAll <role> [another role]... [--bots]', @@ -45,11 +45,8 @@ export default class RoleAllCommand extends BushCommand { ); } - console.time('roleAll1'); let members = await message.guild.members.fetch(); - console.timeEnd('roleAll1'); - console.time('roleAll2'); members = members.filter((member: GuildMember) => { try { if (member.user.bot && !args.bot) return false; @@ -59,21 +56,15 @@ export default class RoleAllCommand extends BushCommand { } return true; }); - console.timeEnd('roleAll2'); - console.time('roleAll3'); await message.util.reply(`${this.client.util.emojis.loading} adding roles to ${members.size} members`); console.timeEnd('roleAll3'); - console.time('roleAll4'); const promises = members.map((member: GuildMember) => { return member.roles.add(args.role, `RoleAll Command - triggered by ${message.author.tag} (${message.author.id})`); }); - console.timeEnd('roleAll4'); - console.time('roleAll5'); const failed = (await Promise.allSettled(promises)).filter((val) => val.status === 'rejected'); - console.timeEnd('roleAll5'); if (!failed.length) { await message.util.reply({ diff --git a/src/commands/dev/__template.ts b/src/commands/dev/__template.ts index 4cf407c..49549af 100644 --- a/src/commands/dev/__template.ts +++ b/src/commands/dev/__template.ts @@ -56,7 +56,7 @@ export default class TemplateCommand extends BushCommand { public override async exec( message: BushMessage | BushSlashMessage, - args: { required_argument: string; optional_argumen: string } + args: { required_argument: string; optional_argument: string } ): Promise<unknown> { return await message.util.reply(`${util.emojis.error} Do not use the template command.`); args; diff --git a/src/commands/dev/test.ts b/src/commands/dev/test.ts index bb0807b..104861f 100644 --- a/src/commands/dev/test.ts +++ b/src/commands/dev/test.ts @@ -1,5 +1,12 @@ import { BushCommand, BushMessage } from '@lib'; -import { Constants as jsConstants, MessageActionRow, MessageButton, MessageEmbed } from 'discord.js'; +import { + ApplicationCommand, + Collection, + Constants as jsConstants, + MessageActionRow, + MessageButton, + MessageEmbed +} from 'discord.js'; export default class TestCommand extends BushCommand { public constructor() { @@ -126,28 +133,18 @@ export default class TestCommand extends BushCommand { } return await message.util.reply({ content: 'this is content', components: ButtonRows, embeds }); } else if (['delete slash commands'].includes(args?.feature?.toLowerCase())) { - // let guildCommandCount = 0; - // client.guilds.cache.forEach(guild => - // guild.commands.fetch().then(commands => { - // commands.forEach(async command => { - // await command.delete(); - // guildCommandCount++; - // }); - // }) - // ); if (!message.guild) return await message.util.reply(`${util.emojis.error} This test can only be run in a guild.`); - const guildCommands = await message.guild.commands.fetch(); - // eslint-disable-next-line @typescript-eslint/no-misused-promises - guildCommands.forEach(async (command) => await command.delete()); - const globalCommands = await client.application!.commands.fetch(); - // eslint-disable-next-line @typescript-eslint/no-misused-promises - globalCommands.forEach(async (command) => await command.delete()); + await client.guilds.fetch(); + const promises: Promise<Collection<string, ApplicationCommand>>[] = []; + client.guilds.cache.each((guild) => { + promises.push(guild.commands.set([])); + }); + await Promise.all(promises); - return await message.util.reply( - `${util.emojis.success} Removed **${/* guildCommandCount */ guildCommands.size}** guild commands and **${ - globalCommands.size - }** global commands.` - ); + await client.application!.commands.fetch(); + await client.application!.commands.set([]); + + return await message.util.reply(`${util.emojis.success} Removed guild commands and global commands.`); } else if (['drop down', 'drop downs', 'select menu', 'select menus'].includes(args?.feature?.toLowerCase())) { } return await message.util.reply(responses[Math.floor(Math.random() * responses.length)]); diff --git a/src/commands/info/color.ts b/src/commands/info/color.ts index 350c23d..5268516 100644 --- a/src/commands/info/color.ts +++ b/src/commands/info/color.ts @@ -1,13 +1,13 @@ import { AllowedMentions, BushCommand, BushGuildMember, BushMessage, BushRole, BushSlashMessage } from '@lib'; import { Argument } from 'discord-akairo'; import { Message, MessageEmbed, Role } from 'discord.js'; -import { Constructor } from 'tinycolor2'; +import tinycolor from 'tinycolor2'; // this is the only way I got it to work consistently -// eslint-disable-next-line @typescript-eslint/no-var-requires -const tinycolor: Constructor = require('tinycolor2'); // this is the only way I got it to work consistently const isValidTinyColor = (_message: Message, phase: string) => { + console.dir(phase); // if the phase is a number it converts it to hex incase it could be representing a color in decimal - const newPhase = Number.isNaN(phase) ? phase : `#${Number(phase).toString(16)}`; + const newPhase = isNaN(phase as any) ? phase : `#${Number(phase).toString(16)}`; + console.dir(newPhase); return tinycolor(newPhase).isValid() ? newPhase : null; }; @@ -25,6 +25,7 @@ export default class ColorCommand extends BushCommand { { id: 'color', customType: Argument.union(isValidTinyColor, 'role', 'member'), + match: 'restContent', prompt: { start: 'What color code, role, or user would you like to find the color of?', retry: '{error} Choose a valid color, role, or member.' diff --git a/src/commands/leveling/level.ts b/src/commands/leveling/level.ts index f22ed8d..223a590 100644 --- a/src/commands/leveling/level.ts +++ b/src/commands/leveling/level.ts @@ -35,6 +35,7 @@ export default class LevelCommand extends BushCommand { } } ], + slash: true, slashOptions: [ { name: 'user', @@ -43,8 +44,9 @@ export default class LevelCommand extends BushCommand { required: false } ], - slash: true, - channel: 'guild' + channel: 'guild', + clientPermissions: ['SEND_MESSAGES'], + userPermissions: ['SEND_MESSAGES'] }); } diff --git a/src/commands/dev/setLevel.ts b/src/commands/leveling/setLevel.ts index 777ef60..be3700a 100644 --- a/src/commands/dev/setLevel.ts +++ b/src/commands/leveling/setLevel.ts @@ -5,7 +5,7 @@ export default class SetLevelCommand extends BushCommand { public constructor() { super('setlevel', { aliases: ['setlevel'], - category: 'dev', + category: 'leveling', description: { content: 'Sets the level of a user', usage: 'setlevel <user> <level>', @@ -43,9 +43,10 @@ export default class SetLevelCommand extends BushCommand { required: true } ], - ownerOnly: true, slash: true, - channel: 'guild' + channel: 'guild', + clientPermissions: ['SEND_MESSAGES'], + userPermissions: ['SEND_MESSAGES', 'ADMINISTRATOR'] }); } diff --git a/src/commands/moderation/_lockdown.ts b/src/commands/moderation/_lockdown.ts index b7bf4b2..68197df 100644 --- a/src/commands/moderation/_lockdown.ts +++ b/src/commands/moderation/_lockdown.ts @@ -28,7 +28,8 @@ export default class LockdownCommand extends BushCommand { ], channel: 'guild', clientPermissions: ['SEND_MESSAGES'], - userPermissions: ['SEND_MESSAGES'] + userPermissions: ['SEND_MESSAGES'], + hidden: true }); } diff --git a/src/commands/moulberry-bush/capes.ts b/src/commands/moulberry-bush/capes.ts index c8d1a05..447d604 100644 --- a/src/commands/moulberry-bush/capes.ts +++ b/src/commands/moulberry-bush/capes.ts @@ -49,7 +49,6 @@ export default class CapesCommand extends BushCommand { default: null } ], - clientPermissions: ['EMBED_LINKS', 'SEND_MESSAGES'], slash: true, slashOptions: [ { @@ -58,7 +57,9 @@ export default class CapesCommand extends BushCommand { type: 'STRING', required: false } - ] + ], + clientPermissions: ['EMBED_LINKS', 'SEND_MESSAGES'], + userPermissions: ['SEND_MESSAGES'] }); } @@ -73,17 +74,17 @@ export default class CapesCommand extends BushCommand { })) .filter((f) => f.match !== null); - const capes1: { name: string; url: string; index: number }[] = []; + const capes1: { name: string; url: string; index: number; purchasable?: boolean }[] = []; client.consts.mappings.capes.forEach((mapCape) => { if (!capes.some((gitCape) => gitCape.match!.groups!.name === mapCape.name) && mapCape.custom) { - capes1.push({ name: mapCape.name, url: mapCape.custom, index: mapCape.index }); + capes1.push({ name: mapCape.name, url: mapCape.custom, index: mapCape.index, purchasable: mapCape.purchasable }); } }); capes.forEach((gitCape) => { const mapCape = client.consts.mappings.capes.find((a) => a.name === gitCape.match!.groups!.name); const url = mapCape?.custom ?? `https://github.com/Moulberry/NotEnoughUpdates/raw/master/${gitCape.f.path}`; const index = mapCape?.index !== undefined ? mapCape.index : null; - capes1.push({ name: gitCape.match!.groups!.name, url, index: index! }); + capes1.push({ name: gitCape.match!.groups!.name, url, index: index!, purchasable: mapCape?.purchasable }); }); const sortedCapes = capes1.sort((a, b) => { @@ -123,6 +124,7 @@ export default class CapesCommand extends BushCommand { color: util.colors.default }).setTimestamp(); embed.setImage(capeObj.url); + if (capeObj.purchasable) embed.setDescription(':money_with_wings: **purchasable** :money_with_wings:'); embeds.push(embed); } await util.buttonPaginate(message, embeds, null); diff --git a/src/commands/moulberry-bush/moulHammerCommand.ts b/src/commands/moulberry-bush/moulHammer.ts index bc60372..bc60372 100644 --- a/src/commands/moulberry-bush/moulHammerCommand.ts +++ b/src/commands/moulberry-bush/moulHammer.ts diff --git a/src/lib/utils/BushConstants.ts b/src/lib/utils/BushConstants.ts index 17880cb..9eb96b3 100644 --- a/src/lib/utils/BushConstants.ts +++ b/src/lib/utils/BushConstants.ts @@ -333,15 +333,15 @@ export class BushConstants { // prettier-ignore capes: [ /* supporter capes */ - { name: 'patreon1', index: 0 }, - { name: 'patreon2', index: 1 }, - { name: 'fade', custom: 'https://raw.githubusercontent.com/NotEnoughUpdates/capes/master/fade.gif', index: 2 }, - { name: 'lava', custom: 'https://raw.githubusercontent.com/NotEnoughUpdates/capes/master/lava.gif', index: 3 }, - { name: 'mcworld', custom: 'https://raw.githubusercontent.com/NotEnoughUpdates/capes/master/mcworld_compressed.gif', index: 4 }, - { name: 'negative', custom: 'https://raw.githubusercontent.com/NotEnoughUpdates/capes/master/negative_compressed.gif', index: 5 }, - { name: 'space', custom: 'https://raw.githubusercontent.com/NotEnoughUpdates/capes/master/space_compressed.gif', index: 6 }, - { name: 'void', custom: 'https://raw.githubusercontent.com/NotEnoughUpdates/capes/master/void.gif', index: 7 }, - { name: 'tunnel', custom: 'https://raw.githubusercontent.com/NotEnoughUpdates/capes/master/tunnel.gif', index: 8 }, + { name: 'patreon1', index: 0, purchasable: true }, + { name: 'patreon2', index: 1, purchasable: true }, + { name: 'fade', custom: 'https://raw.githubusercontent.com/NotEnoughUpdates/capes/master/fade.gif', index: 2, purchasable: true }, + { name: 'lava', custom: 'https://raw.githubusercontent.com/NotEnoughUpdates/capes/master/lava.gif', index: 3, purchasable: true }, + { name: 'mcworld', custom: 'https://raw.githubusercontent.com/NotEnoughUpdates/capes/master/mcworld_compressed.gif', index: 4, purchasable: true }, + { name: 'negative', custom: 'https://raw.githubusercontent.com/NotEnoughUpdates/capes/master/negative_compressed.gif', index: 5, purchasable: true }, + { name: 'space', custom: 'https://raw.githubusercontent.com/NotEnoughUpdates/capes/master/space_compressed.gif', index: 6, purchasable: true }, + { name: 'void', custom: 'https://raw.githubusercontent.com/NotEnoughUpdates/capes/master/void.gif', index: 7, purchasable: true }, + { name: 'tunnel', custom: 'https://raw.githubusercontent.com/NotEnoughUpdates/capes/master/tunnel.gif', index: 8, purchasable: true }, /* Staff capes */ { name: 'contrib', index: 9 }, { name: 'mbstaff', index: 10 }, diff --git a/src/tasks/removeExpiredPunishements.ts b/src/tasks/removeExpiredPunishements.ts index 69130ee..49267f5 100644 --- a/src/tasks/removeExpiredPunishements.ts +++ b/src/tasks/removeExpiredPunishements.ts @@ -12,13 +12,9 @@ export default class RemoveExpiredPunishmentsTask extends BushTask { public override async exec(): Promise<void> { const expiredEntries = await ActivePunishment.findAll({ where: { - [Op.and]: [ - { - expires: { - [Op.lt]: new Date() // Find all rows with an expiry date before now - } - } - ] + expires: { + [Op.lt]: new Date() // Find all rows with an expiry date before now + } } }); |