diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-09-04 12:39:08 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-09-04 12:39:08 -0400 |
commit | bb774bbe0cfedd77be852f73448df061252b7c0a (patch) | |
tree | 579c2f11717dd5aa3a0d6ea990479368b338cd66 | |
parent | 939f19c1a8a7efea00fc3df3504a41fc58a3b286 (diff) | |
download | tanzanite-bb774bbe0cfedd77be852f73448df061252b7c0a.tar.gz tanzanite-bb774bbe0cfedd77be852f73448df061252b7c0a.tar.bz2 tanzanite-bb774bbe0cfedd77be852f73448df061252b7c0a.zip |
I sure do love when one line causes 400 errors
-rw-r--r-- | src/commands/admin/roleAll.ts | 18 | ||||
-rw-r--r-- | src/commands/moulberry-bush/moulHammer.ts | 2 | ||||
-rw-r--r-- | src/commands/utilities/wolframAlpha.ts | 2 | ||||
-rw-r--r-- | src/lib/extensions/discord-akairo/BushClient.ts | 4 | ||||
-rw-r--r-- | src/lib/extensions/discord-akairo/BushCommandHandler.ts | 14 | ||||
-rw-r--r-- | src/lib/extensions/discord-akairo/BushCommandUtil.ts | 9 | ||||
-rw-r--r-- | src/lib/extensions/discord-akairo/BushListener.ts | 7 | ||||
-rw-r--r-- | src/lib/extensions/discord-akairo/BushSlashMessage.ts | 2 | ||||
-rw-r--r-- | src/listeners/guild/guildMemberAdd.ts | 32 | ||||
-rw-r--r-- | src/listeners/guild/guildMemberRemove.ts | 8 | ||||
-rw-r--r-- | src/listeners/message/blacklistedFile.ts | 6 | ||||
-rw-r--r-- | src/listeners/message/boosterMessage.ts | 2 | ||||
-rw-r--r-- | src/listeners/message/directMessage.ts | 8 | ||||
-rw-r--r-- | src/listeners/message/verbose.ts | 2 | ||||
-rw-r--r-- | tsconfig.json | 27 | ||||
-rw-r--r-- | yarn.lock | 4 |
16 files changed, 70 insertions, 77 deletions
diff --git a/src/commands/admin/roleAll.ts b/src/commands/admin/roleAll.ts index 7e60f40..5e891ee 100644 --- a/src/commands/admin/roleAll.ts +++ b/src/commands/admin/roleAll.ts @@ -37,12 +37,10 @@ export default class RoleAllCommand extends BushCommand { public override async exec(message: BushMessage, args: { role: Role; bot?: boolean }): Promise<unknown> { if (!message.guild) return await message.util.reply(`${util.emojis.error} This command can only be run in a server.`); if (!message.member!.permissions.has('ADMINISTRATOR')) - return await message.util.reply(`${this.client.util.emojis.error} You must have admin perms to use this command.`); + return await message.util.reply(`${util.emojis.error} You must have admin perms to use this command.`); if (args.role.comparePositionTo(message.guild.me!.roles.highest) >= 0 && !args.role) { - return await message.util.reply( - `${this.client.util.emojis.error} I cannot assign a role higher or equal to my highest role.` - ); + return await message.util.reply(`${util.emojis.error} I cannot assign a role higher or equal to my highest role.`); } let members = await message.guild.members.fetch(); @@ -57,7 +55,7 @@ export default class RoleAllCommand extends BushCommand { return true; }); - await message.util.reply(`${this.client.util.emojis.loading} adding roles to ${members.size} members`); + await message.util.reply(`${util.emojis.loading} adding roles to ${members.size} members`); console.timeEnd('roleAll3'); const promises = members.map((member: GuildMember) => { @@ -68,7 +66,7 @@ export default class RoleAllCommand extends BushCommand { if (!failed.length) { await message.util.reply({ - content: `${this.client.util.emojis.success} Finished adding <@&${args.role.id}> to **${members.size}** member${ + content: `${util.emojis.success} Finished adding <@&${args.role.id}> to **${members.size}** member${ members.size ? 's' : '' }.`, allowedMentions: AllowedMentions.none() @@ -76,11 +74,9 @@ export default class RoleAllCommand extends BushCommand { } else { const array = [...members.values()]; await message.util.reply({ - content: `${this.client.util.emojis.warn} Finished adding <@&${args.role.id}> to **${ - members.size - failed.length - }** member${members.size - failed.length ? 's' : ''}! Failed members:\n${failed - .map((_, index) => `<@${array[index].id}>`) - .join(' ')}`, + content: `${util.emojis.warn} Finished adding <@&${args.role.id}> to **${members.size - failed.length}** member${ + members.size - failed.length ? 's' : '' + }! Failed members:\n${failed.map((_, index) => `<@${array[index].id}>`).join(' ')}`, allowedMentions: AllowedMentions.none() }); } diff --git a/src/commands/moulberry-bush/moulHammer.ts b/src/commands/moulberry-bush/moulHammer.ts index bc60372..8e78031 100644 --- a/src/commands/moulberry-bush/moulHammer.ts +++ b/src/commands/moulberry-bush/moulHammer.ts @@ -32,7 +32,7 @@ export default class MoulHammerCommand extends BushCommand { const embed = new MessageEmbed() .setTitle('L') .setDescription(`${user.username} got moul'ed <:wideberry1:756223352598691942><:wideberry2:756223336832303154>`) - .setColor(this.client.util.colors.purple); + .setColor(util.colors.purple); await message.util.send({ embeds: [embed] }); } } diff --git a/src/commands/utilities/wolframAlpha.ts b/src/commands/utilities/wolframAlpha.ts index c18646c..88dc65a 100644 --- a/src/commands/utilities/wolframAlpha.ts +++ b/src/commands/utilities/wolframAlpha.ts @@ -39,7 +39,7 @@ export default class WolframAlphaCommand extends BushCommand { }); } public override async exec(message: BushMessage | BushSlashMessage, args: { expression: string }): Promise<unknown> { - const waApi = WolframAlphaAPI(this.client.config.credentials.wolframAlphaAppId); + const waApi = WolframAlphaAPI(client.config.credentials.wolframAlphaAppId); const decodedEmbed = new MessageEmbed().addField('📥 Input', await util.inspectCleanRedactCodeblock(args.expression)); try { diff --git a/src/lib/extensions/discord-akairo/BushClient.ts b/src/lib/extensions/discord-akairo/BushClient.ts index ab66f60..4cc8712 100644 --- a/src/lib/extensions/discord-akairo/BushClient.ts +++ b/src/lib/extensions/discord-akairo/BushClient.ts @@ -338,7 +338,9 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re } } - /** Logs out, terminates the connection to Discord, and destroys the client. */ + /** + * Logs out, terminates the connection to Discord, and destroys the client. + */ public override destroy(relogin = false): void | Promise<string> { super.destroy(); if (relogin) { diff --git a/src/lib/extensions/discord-akairo/BushCommandHandler.ts b/src/lib/extensions/discord-akairo/BushCommandHandler.ts index 44a0966..c533832 100644 --- a/src/lib/extensions/discord-akairo/BushCommandHandler.ts +++ b/src/lib/extensions/discord-akairo/BushCommandHandler.ts @@ -32,18 +32,4 @@ export class BushCommandHandler extends CommandHandler { public constructor(client: BushClient, options: CommandHandlerOptions) { super(client, options); } - - public override async runPostTypeInhibitors(message: BushMessage, command: BushCommand, slash = false): Promise<boolean> { - const reason = this.inhibitorHandler ? await this.inhibitorHandler.test('post', message, command) : null; - if (reason != null) { - this.emit(slash ? commandHandlerEvents.SLASH_BLOCKED : commandHandlerEvents.COMMAND_BLOCKED, message, command, reason); - return true; - } - - if (await this.runPermissionChecks(message, command)) { - return true; - } - - return !!this.runCooldowns(message, command); - } } diff --git a/src/lib/extensions/discord-akairo/BushCommandUtil.ts b/src/lib/extensions/discord-akairo/BushCommandUtil.ts index 1e86401..bda0e74 100644 --- a/src/lib/extensions/discord-akairo/BushCommandUtil.ts +++ b/src/lib/extensions/discord-akairo/BushCommandUtil.ts @@ -1,5 +1,6 @@ import { CommandUtil, ParsedComponentData } from 'discord-akairo'; -import { Collection, Snowflake } from 'discord.js'; +import { Snowflake } from 'discord-api-types'; +import { Collection } from 'discord.js'; import { BushMessage } from '../discord.js/BushMessage'; import { BushCommand } from './BushCommand'; import { BushCommandHandler } from './BushCommandHandler'; @@ -9,14 +10,12 @@ export interface BushParsedComponentData extends ParsedComponentData { } export class BushCommandUtil extends CommandUtil { - public declare parsed?: BushParsedComponentData; + public declare parsed: BushParsedComponentData | null; public declare handler: BushCommandHandler; public declare message: BushMessage; - public declare messages?: Collection<Snowflake, BushMessage>; - // public test: string; + public declare messages: Collection<Snowflake, BushMessage> | null; public constructor(handler: BushCommandHandler, message: BushMessage) { super(handler, message); - // this.test = 'abc'; } } diff --git a/src/lib/extensions/discord-akairo/BushListener.ts b/src/lib/extensions/discord-akairo/BushListener.ts index b98bb02..82e874f 100644 --- a/src/lib/extensions/discord-akairo/BushListener.ts +++ b/src/lib/extensions/discord-akairo/BushListener.ts @@ -5,7 +5,12 @@ export class BushListener extends Listener { public declare client: BushClient; public constructor( id: string, - options: { emitter: string | EventEmitter; event: string; type?: 'on' | 'once'; category?: string } + options: { + emitter: string | EventEmitter; + event: string; + type?: 'on' | 'once' | 'prependListener' | 'prependOnceListener'; + category?: string; + } ) { super(id, options); } diff --git a/src/lib/extensions/discord-akairo/BushSlashMessage.ts b/src/lib/extensions/discord-akairo/BushSlashMessage.ts index d10a024..442b0d4 100644 --- a/src/lib/extensions/discord-akairo/BushSlashMessage.ts +++ b/src/lib/extensions/discord-akairo/BushSlashMessage.ts @@ -11,7 +11,7 @@ export class BushSlashMessage extends AkairoMessage { public declare client: BushClient; public declare util: BushCommandUtil; public declare author: BushUser; - public declare member: BushGuildMember; + public declare member: BushGuildMember | null; public constructor(client: BushClient, interaction: CommandInteraction, command: BushCommand) { super(client, interaction, command); } diff --git a/src/listeners/guild/guildMemberAdd.ts b/src/listeners/guild/guildMemberAdd.ts index ca10cd7..631eb5d 100644 --- a/src/listeners/guild/guildMemberAdd.ts +++ b/src/listeners/guild/guildMemberAdd.ts @@ -20,26 +20,23 @@ export default class GuildMemberAddListener extends BushListener { if (client.config.isDevelopment) return; const welcomeChannel = await member.guild.getSetting('welcomeChannel'); if (!welcomeChannel) return; - const welcome = this.client.channels.cache.get(welcomeChannel) as BushTextChannel | undefined; + const welcome = client.channels.cache.get(welcomeChannel) as BushTextChannel | undefined; if (!welcome) return; if (member.guild.id !== welcome?.guild.id) throw new Error('Welcome channel must be in the guild.'); const embed = new MessageEmbed() .setDescription( - `${this.client.util.emojis.join} **${Util.escapeMarkdown( + `${util.emojis.join} **${Util.escapeMarkdown( member.user.tag )}** joined the server. There are now ${member.guild.memberCount.toLocaleString()} members.` ) - .setColor(this.client.util.colors.green); + .setColor(util.colors.green); await welcome .send({ embeds: [embed] }) .then(() => - this.client.console.info('guildMemberAdd', `Sent a message for <<${member.user.tag}>> in <<${member.guild.name}>>.`) + client.console.info('guildMemberAdd', `Sent a message for <<${member.user.tag}>> in <<${member.guild.name}>>.`) ) .catch(() => - this.client.console.warn( - 'guildMemberAdd', - `Failed to send message for <<${member.user.tag}>> in <<${member.guild.name}>>.` - ) + client.console.warn('guildMemberAdd', `Failed to send message for <<${member.user.tag}>> in <<${member.guild.name}>>.`) ); } @@ -63,11 +60,10 @@ export default class GuildMemberAddListener extends BushListener { const addedRoles = await member.roles .add(rolesArray, "Returning member's previous roles.") .catch( - () => - void this.client.console.warn('guildMemberAdd', `There was an error returning <<${member.user.tag}>>'s roles.`) + () => void client.console.warn('guildMemberAdd', `There was an error returning <<${member.user.tag}>>'s roles.`) ); if (addedRoles) { - void this.client.console.info( + void client.console.info( 'guildMemberAdd', `Assigned sticky roles to <<${member.user.tag}>> in <<${member.guild.name}>>.` ); @@ -79,12 +75,9 @@ export default class GuildMemberAddListener extends BushListener { .catch(() => failedRoles.push(rolesArray[i])); } if (failedRoles.length) { - void this.client.console.warn( - 'guildMemberAdd', - `Failed assigning the following roles on Fallback:${failedRoles}` - ); + void client.console.warn('guildMemberAdd', `Failed assigning the following roles on Fallback:${failedRoles}`); } else { - void this.client.console.info( + void client.console.info( 'guildMemberAdd', `[Fallback] Assigned sticky roles to <<${member.user.tag}>> in <<${member.guild.name}>>.` ); @@ -98,14 +91,11 @@ export default class GuildMemberAddListener extends BushListener { await member.roles .add(joinRoles, 'Join roles.') .then(() => - this.client.console.info( - 'guildMemberAdd', - `Assigned join roles to <<${member.user.tag}>> in <<${member.guild.name}>>.` - ) + client.console.info('guildMemberAdd', `Assigned join roles to <<${member.user.tag}>> in <<${member.guild.name}>>.`) ) .catch( () => - void this.client.console.warn( + void client.console.warn( 'guildMemberAdd', `Failed to assign join roles to <<${member.user.tag}>>, in <<${member.guild.name}>>.` ) diff --git a/src/listeners/guild/guildMemberRemove.ts b/src/listeners/guild/guildMemberRemove.ts index f72f061..74404a3 100644 --- a/src/listeners/guild/guildMemberRemove.ts +++ b/src/listeners/guild/guildMemberRemove.ts @@ -23,11 +23,11 @@ export default class GuildMemberRemoveListener extends BushListener { const isBan = member.guild.bans.cache.has(member.id); const welcomeChannel = await member.guild.getSetting('welcomeChannel'); if (!welcomeChannel) return; - const welcome = this.client.channels.cache.get(welcomeChannel) as BushTextChannel | undefined; + const welcome = client.channels.cache.get(welcomeChannel) as BushTextChannel | undefined; if (member.guild.id !== welcome?.guild.id) throw new Error('Welcome channel must be in the guild.'); const embed: MessageEmbed = new MessageEmbed() .setDescription( - `${this.client.util.emojis.leave} **${Util.escapeBold(user.tag)}** ${ + `${util.emojis.leave} **${Util.escapeBold(user.tag)}** ${ isBan ? 'banned from' : 'left' } the server. There are now ${welcome.guild.memberCount.toLocaleString()} members.` ) @@ -36,7 +36,7 @@ export default class GuildMemberRemoveListener extends BushListener { .send({ embeds: [embed] }) .then(() => client.console.info('guildMemberRemove', `Sent a message for <<${user.tag}>> in <<${member.guild.name}>>.`)) .catch(() => - this.client.console.warn('guildMemberRemove', `Failed to send message for <<${user.tag}>> in <<${member.guild.name}>>.`) + client.console.warn('guildMemberRemove', `Failed to send message for <<${user.tag}>> in <<${member.guild.name}>>.`) ); } @@ -62,7 +62,7 @@ export default class GuildMemberRemoveListener extends BushListener { await row .save() .then(() => - this.client.console.info('guildMemberRemove', `${isNew ? 'Created' : 'Updated'} info for <<${member.user.tag}>>.`) + client.console.info('guildMemberRemove', `${isNew ? 'Created' : 'Updated'} info for <<${member.user.tag}>>.`) ); } } diff --git a/src/listeners/message/blacklistedFile.ts b/src/listeners/message/blacklistedFile.ts index 733ab73..e0e3d19 100644 --- a/src/listeners/message/blacklistedFile.ts +++ b/src/listeners/message/blacklistedFile.ts @@ -122,7 +122,7 @@ export default class BlacklistedFileListener extends BushListener { if (foundFiles.length > 0) { try { for (let i = 0; i < foundFiles.length; i++) { - if (foundFiles[i].name === 'Discord crash video' && !this.client.ownerID.includes(message.author.id)) { + if (foundFiles[i].name === 'Discord crash video' && !client.ownerID.includes(message.author.id)) { await message.member?.roles.add('748912426581229690'); } } @@ -132,7 +132,7 @@ export default class BlacklistedFileListener extends BushListener { `<@!${message.author.id}>, please do not send ${foundFiles.map((f) => f.description).join(' or ')}.` ); if (message.channel.type === 'DM') return; - void this.client.console.info( + void client.console.info( 'blacklistedFile', `Deleted <<${foundFiles.map((f) => f.description).join(' and ')}>> sent by <<${message.author.tag}>> in ${ message.channel.name @@ -142,7 +142,7 @@ export default class BlacklistedFileListener extends BushListener { void message.util.send( `<@!${message.author.id}>, please do not send ${foundFiles.map((f) => f.description).join(' or ')}.` ); - void this.client.console.warn( + void client.console.warn( 'blacklistedFile', `Failed to delete <<${foundFiles.map((f) => f.description).join(' and ')}>> sent by <<${message.author.tag}>> in <<${ message.channel.type === 'DM' ? `${message.channel.recipient.tag}'s DMs` : message.channel.name diff --git a/src/listeners/message/boosterMessage.ts b/src/listeners/message/boosterMessage.ts index 122fa39..6ab12d5 100644 --- a/src/listeners/message/boosterMessage.ts +++ b/src/listeners/message/boosterMessage.ts @@ -14,7 +14,7 @@ export default class BoosterMessageListener extends BushListener { if (!message.guild || !(await message.guild?.hasFeature('boosterMessageReact'))) return; if (message.type === 'USER_PREMIUM_GUILD_SUBSCRIPTION') { return await message.react('<:nitroboost:785160348885975062>').catch(() => { - void this.client.console.warn('boosterMessage', `Failed to react to <<${message.id}>>.`); + void client.console.warn('boosterMessage', `Failed to react to <<${message.id}>>.`); }); } } diff --git a/src/listeners/message/directMessage.ts b/src/listeners/message/directMessage.ts index a434010..93ab662 100644 --- a/src/listeners/message/directMessage.ts +++ b/src/listeners/message/directMessage.ts @@ -13,14 +13,14 @@ export default class DirectMessageListener extends BushListener { public override async exec(...[message]: BushClientEvents['messageCreate']): Promise<void> { if (message.channel.type === 'DM') { - if (!(message.author.id == this.client.user!.id) && message.author.bot) return; + if (!(message.author.id == client.user!.id) && message.author.bot) return; const dmLogEmbed = new MessageEmbed().setTimestamp().setFooter(`User ID • ${message.author.id}`); - if (message.author.id != this.client.user!.id) { + if (message.author.id != client.user!.id) { dmLogEmbed .setAuthor(`From: ${message.author.username}`, `${message.author.displayAvatarURL({ dynamic: true })}`) .setDescription(`**DM:**\n${message}`) - .setColor(this.client.util.colors.blue); + .setColor(util.colors.blue); } else { dmLogEmbed .setAuthor( @@ -28,7 +28,7 @@ export default class DirectMessageListener extends BushListener { `${message.channel.recipient.displayAvatarURL({ dynamic: true })}` ) .setDescription(`**DM:**\n${message}`) - .setColor(this.client.util.colors.red) + .setColor(util.colors.red) .setTimestamp() .setFooter(`ID • ${message.author.id}`); } diff --git a/src/listeners/message/verbose.ts b/src/listeners/message/verbose.ts index 8177529..517771e 100644 --- a/src/listeners/message/verbose.ts +++ b/src/listeners/message/verbose.ts @@ -13,7 +13,7 @@ export default class MessageVerboseListener extends BushListener { public override exec(...[message]: BushClientEvents['messageCreate']): void { if (client.isReady()) { if (message.channel?.type === 'DM') return; - void this.client.console.verbose( + void client.console.verbose( 'messageVerbose', `A message was sent by <<${message.author.tag}>> in <<${message.channel.name}>> in <<${message.guild!.name}>>.` ); diff --git a/tsconfig.json b/tsconfig.json index 34ef008..c3316fc 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,14 @@ "module": "commonjs", "target": "esnext", "outDir": "dist", - "lib": ["esnext", "esnext.array", "esnext.asyncIterable", "esnext.intl", "esnext.symbol", "DOM"], + "lib": [ + "esnext", + "esnext.array", + "esnext.asyncIterable", + "esnext.intl", + "esnext.symbol", + "DOM" + ], "sourceMap": false, "inlineSourceMap": true, "inlineSources": true, @@ -19,11 +26,19 @@ "baseUrl": "./", "useUnknownInCatchVariables": false, "paths": { - "src/*": ["./src/*"], - "@lib": ["./src/lib"], - "@root": ["."] + "src/*": [ + "./src/*" + ], + "@lib": [ + "./src/lib" + ], + "@root": [ + "." + ] } }, - "include": ["src/**/*.ts"], + "include": [ + "src/**/*.ts" + ], "exclude": [] -} +}
\ No newline at end of file @@ -1126,12 +1126,12 @@ discord-akairo-message-util@NotEnoughUpdates/discord-akairo-message-util: discord-akairo@NotEnoughUpdates/discord-akairo: version: 8.2.2 - resolution: "discord-akairo@https://github.com/NotEnoughUpdates/discord-akairo.git#commit=18ffe7e4616cec7322b78991751d71194b8373a2" + resolution: "discord-akairo@https://github.com/NotEnoughUpdates/discord-akairo.git#commit=ec9ff7894fad9cae557c12f18579c73fc004be9f" dependencies: discord-akairo-message-util: NotEnoughUpdates/discord-akairo-message-util lodash: ^4.17.21 source-map-support: ^0.5.19 - checksum: fdddd67bede8943cbe847c209290c11edfa87e18d80b0575c0030bb2768e286186888525b5b80d516aa6376e4d1b17a512973fcba2908c16ebf433689f4ea637 + checksum: fc4a08925050741263dbcf95105a3527d856bce0326449fbe85fb191158f702d566bfe4e7056bb9c524f343ffbdda572fcd0ddd94fcb109c1804475e544f46a8 languageName: node linkType: hard |