diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-08-17 12:31:09 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-08-17 12:31:09 -0400 |
commit | d40527d0a2d9f209905750258f71bedff1cdf089 (patch) | |
tree | e017fd844c2135bfc85228d00ef2617d24ce0a3f /src/listeners/message | |
parent | d431ad00754f3f250103deedea495b9bcee73fc0 (diff) | |
download | tanzanite-d40527d0a2d9f209905750258f71bedff1cdf089.tar.gz tanzanite-d40527d0a2d9f209905750258f71bedff1cdf089.tar.bz2 tanzanite-d40527d0a2d9f209905750258f71bedff1cdf089.zip |
turned on ts strict option
Diffstat (limited to 'src/listeners/message')
-rw-r--r-- | src/listeners/message/automodCreate.ts | 16 | ||||
-rw-r--r-- | src/listeners/message/blacklistedFile.ts | 9 | ||||
-rw-r--r-- | src/listeners/message/booster.ts | 2 | ||||
-rw-r--r-- | src/listeners/message/directMessage.ts | 6 | ||||
-rw-r--r-- | src/listeners/message/level.ts | 2 | ||||
-rw-r--r-- | src/listeners/message/verbose.ts | 4 |
6 files changed, 20 insertions, 19 deletions
diff --git a/src/listeners/message/automodCreate.ts b/src/listeners/message/automodCreate.ts index b447ac8..cd22a16 100644 --- a/src/listeners/message/automodCreate.ts +++ b/src/listeners/message/automodCreate.ts @@ -21,7 +21,7 @@ export default class AutomodMessageCreateListener extends BushListener { public static async automod(message: BushMessage): Promise<unknown> { if (message.guild?.id !== client.consts.mappings.guilds.bush) return; // just temporary /* await message.guild.getSetting('autoModPhases'); */ - const badLinks = {}; + const badLinks: { [key: string]: number } = {}; let temp = _badLinks; if (_badLinksSecret) temp = temp.concat(_badLinksSecret); @@ -39,7 +39,7 @@ export default class AutomodMessageCreateListener extends BushListener { if (cleanMessageContent.includes(cleanWord)) { if (cleanWord === 'whore' && !message.content?.toLowerCase().includes(cleanWord)) return; - if (!offences[word]) offences[word] = wordMap[word]; + if (!offences[word]) offences[word] = wordMap[word as keyof typeof wordMap]; } }); if (!Object.keys(offences)?.length) return; @@ -53,8 +53,8 @@ export default class AutomodMessageCreateListener extends BushListener { } case 1: { void message.delete().catch(() => {}); - void message.member.warn({ - moderator: message.guild.me, + void message.member?.warn({ + moderator: message.guild.me!, reason: 'Saying a blacklisted word.' }); @@ -62,8 +62,8 @@ export default class AutomodMessageCreateListener extends BushListener { } case 2: { void message.delete().catch(() => {}); - void message.member.mute({ - moderator: message.guild.me, + void message.member?.mute({ + moderator: message.guild.me!, reason: 'Saying a blacklisted word.', duration: 900_000 // 15 minutes }); @@ -71,8 +71,8 @@ export default class AutomodMessageCreateListener extends BushListener { } case 3: { void message.delete().catch(() => {}); - void message.member.mute({ - moderator: message.guild.me, + void message.member?.mute({ + moderator: message.guild.me!, reason: 'Saying a blacklisted word.', duration: 0 // perm }); diff --git a/src/listeners/message/blacklistedFile.ts b/src/listeners/message/blacklistedFile.ts index 36bf2e9..a9c5c46 100644 --- a/src/listeners/message/blacklistedFile.ts +++ b/src/listeners/message/blacklistedFile.ts @@ -66,12 +66,13 @@ export default class BlacklistedFileListener extends BushListener { } public override async exec(...[message]: BushClientEvents['messageCreate']): Promise<void> { + if (!message.guild) return; const guildWhitelist = [ client.consts.mappings.guilds.bush, client.consts.mappings.guilds.tree, client.consts.mappings.guilds.space_ship ]; - if (!guildWhitelist.includes(message.guild?.id)) return; + if (!guildWhitelist.includes(message.guild!.id)) return; const embedAttachments = message.embeds.filter((e) => ['image', 'video', 'gifv'].includes(e.type)); const foundEmojis = [...message.content.matchAll(/<(?<animated>a?):\w+:(?<id>\d+)>/g)]; if (message.attachments.size + embedAttachments.length + foundEmojis.length < 1) return; @@ -96,7 +97,7 @@ export default class BlacklistedFileListener extends BushListener { } for (const attachment of embedAttachments) { try { - const req = await got.get(attachment.url); + const req = await got.get(attachment.url!); const rawHash = crypto.createHash('md5'); rawHash.update(req.rawBody.toString('binary')); const hash = rawHash.digest('hex'); @@ -111,7 +112,7 @@ export default class BlacklistedFileListener extends BushListener { for (const attachment of foundEmojis) { try { const req = await got.get( - `https://cdn.discordapp.com/emojis/${attachment.groups.id}.${attachment.groups.animated === 'a' ? 'gif' : 'png'}` + `https://cdn.discordapp.com/emojis/${attachment.groups?.id}.${attachment.groups?.animated === 'a' ? 'gif' : 'png'}` ); const rawHash = crypto.createHash('md5'); rawHash.update(req.rawBody.toString('binary')); @@ -128,7 +129,7 @@ export default class BlacklistedFileListener extends BushListener { try { for (let i = 0; i < foundFiles.length; i++) { if (foundFiles[i].name === 'Discord crash video' && !this.client.ownerID.includes(message.author.id)) { - await message.member.roles.add('748912426581229690'); + await message.member?.roles.add('748912426581229690'); } } await message.delete(); diff --git a/src/listeners/message/booster.ts b/src/listeners/message/booster.ts index e57b8ea..603e535 100644 --- a/src/listeners/message/booster.ts +++ b/src/listeners/message/booster.ts @@ -11,7 +11,7 @@ export default class BoosterMessageListener extends BushListener { } public override async exec(...[message]: BushClientEvents['messageCreate']): Promise<unknown> { - if (message.type === 'USER_PREMIUM_GUILD_SUBSCRIPTION' && message.guild.id === this.client.consts.mappings.guilds.bush) { + if (message.type === 'USER_PREMIUM_GUILD_SUBSCRIPTION' && message.guild!.id === this.client.consts.mappings.guilds.bush) { return await message.react('<:nitroboost:785160348885975062>').catch(() => { void this.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 55180b1..a434010 100644 --- a/src/listeners/message/directMessage.ts +++ b/src/listeners/message/directMessage.ts @@ -13,10 +13,10 @@ 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 == this.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 != this.client.user!.id) { dmLogEmbed .setAuthor(`From: ${message.author.username}`, `${message.author.displayAvatarURL({ dynamic: true })}`) .setDescription(`**DM:**\n${message}`) @@ -33,7 +33,7 @@ export default class DirectMessageListener extends BushListener { .setFooter(`ID • ${message.author.id}`); } if (message.attachments.filter((a) => typeof a.size == 'number').size == 1) { - dmLogEmbed.setImage(message.attachments.filter((a) => typeof a.size == 'number').first().proxyURL); + dmLogEmbed.setImage(message.attachments.filter((a) => typeof a.size == 'number').first()!.proxyURL); } else if (message.attachments.size > 0) { dmLogEmbed.addField('Attachments', message.attachments.map((a) => a.proxyURL).join('\n')); } diff --git a/src/listeners/message/level.ts b/src/listeners/message/level.ts index f5fb932..0077276 100644 --- a/src/listeners/message/level.ts +++ b/src/listeners/message/level.ts @@ -42,6 +42,6 @@ export default class LevelListener extends BushListener { `Gave <<${xpToGive}>> XP to <<${message.author.tag}>> in <<${message.guild}>>.` ); this.#levelCooldowns.add(`${message.guild.id}-${message.author.id}`); - setTimeout(() => this.#levelCooldowns.delete(`${message.guild.id}-${message.author.id}`), 60_000); + setTimeout(() => this.#levelCooldowns.delete(`${message.guild!.id}-${message.author.id}`), 60_000); } } diff --git a/src/listeners/message/verbose.ts b/src/listeners/message/verbose.ts index 632a22f..f1530ce 100644 --- a/src/listeners/message/verbose.ts +++ b/src/listeners/message/verbose.ts @@ -10,11 +10,11 @@ export default class MessageVerboseListener extends BushListener { }); } - public override exec(...[message]: BushClientEvents['messageCreate']): Promise<void> { + public override exec(...[message]: BushClientEvents['messageCreate']): Promise<void> | undefined { if (message.channel?.type === 'DM') return; void this.client.console.verbose( 'Message', - `A message was sent by <<${message.author.tag}>> in <<${message.channel.name}>> in <<${message.guild.name}>>.` + `A message was sent by <<${message.author.tag}>> in <<${message.channel.name}>> in <<${message.guild!.name}>>.` ); } } |