aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-10-03 18:16:11 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-10-03 18:16:11 -0400
commit3b1311951638bc54efbbb245632e2b3ab460f741 (patch)
tree07fc42ba19a0ec4a2b3168faf96d284f726fb3da
parent4b4d05d9708bdaef2c93df1a83c4ce7ca4350f7a (diff)
downloadtanzanite-3b1311951638bc54efbbb245632e2b3ab460f741.tar.gz
tanzanite-3b1311951638bc54efbbb245632e2b3ab460f741.tar.bz2
tanzanite-3b1311951638bc54efbbb245632e2b3ab460f741.zip
new links, bug fixes, excape rtl charecters in welcome messages
-rw-r--r--lib/badlinks.json56
-rw-r--r--lib/badwords.json53
-rw-r--r--src/bot.ts5
-rw-r--r--src/commands/config/config.ts4
-rw-r--r--src/commands/config/features.ts2
-rw-r--r--src/commands/moderation/warn.ts1
-rw-r--r--src/commands/utilities/wolframAlpha.ts4
-rw-r--r--src/lib/extensions/discord-akairo/BushClientUtil.ts10
-rw-r--r--src/lib/models/Guild.ts8
-rw-r--r--src/lib/utils/BushConstants.ts3
-rw-r--r--src/listeners/custom/bushMute.ts2
-rw-r--r--src/listeners/guild/guildMemberAdd.ts37
-rw-r--r--src/listeners/guild/guildMemberRemove.ts21
-rw-r--r--src/listeners/message/automodCreate.ts5
-rw-r--r--yarn.lock40
15 files changed, 101 insertions, 50 deletions
diff --git a/lib/badlinks.json5 b/lib/badlinks.json5
index e21124a..32f28f9 100644
--- a/lib/badlinks.json5
+++ b/lib/badlinks.json5
@@ -112,6 +112,7 @@
"dicsord.net",
"dirscod.com",
"dirscod.gift",
+ "discocrd.gift",
"discod.gift",
"discod.info",
"discorb.co",
@@ -122,8 +123,10 @@
"discorclapp.com",
"discord-accept.com",
"discord-airdrop.com",
+ "discord-app.me",
"discord-app.net",
"discord-app.ru.com",
+ "discord-cpp.com",
"discord-gifts.com",
"discord-give.com",
"discord-halloween.ru",
@@ -140,6 +143,8 @@
"discordgift.ru.com",
"discordgivenitro.com",
"discordnitrogift.ru",
+ "discords-nitroapp.xyz",
+ "discordsteams.com",
"discrod.gift",
"discrod.gifts",
"discrodnitro.org",
@@ -199,6 +204,7 @@
"giftsdiscord.ru",
"giveavvay.com",
"giveawayskin.com",
+ "glets-nitro.com",
"global-skins.gq",
"globalcsskins.xyz",
"globalskins.tk",
diff --git a/lib/badwords.json5 b/lib/badwords.json5
index 8734432..e6a37d5 100644
--- a/lib/badwords.json5
+++ b/lib/badwords.json5
@@ -46,6 +46,9 @@
/* Misc Scams */
"found a cool software that improves the": 3,
+ /* Frequently Advertised Discord Severs */
+ "https://discord.gg/7CaCvDXs": 2,
+
// 'tm5LcYN': 3,
// '5gwLaOZ.png': 3,
// 'hYKoQoU4bss': 3,
diff --git a/src/bot.ts b/src/bot.ts
index 46b857d..1354c31 100644
--- a/src/bot.ts
+++ b/src/bot.ts
@@ -1,8 +1,7 @@
import 'module-alias/register';
import 'source-map-support/register';
import config from './config/options';
-import { BushClient } from './lib/';
+import { BushClient } from './lib';
BushClient.preStart();
-const client = new BushClient(config);
-void client.start();
+void new BushClient(config).start();
diff --git a/src/commands/config/config.ts b/src/commands/config/config.ts
index 4cab741..2075531 100644
--- a/src/commands/config/config.ts
+++ b/src/commands/config/config.ts
@@ -198,7 +198,7 @@ export default class SettingsCommand extends BushCommand {
const action = message.util.isSlash ? args.subcommand! : args.action!;
const value = args.value;
- let msg;
+ let msg: Message;
if (!setting || action === 'view') {
const messageOptions = await this.generateMessageOptions(message, setting ?? undefined);
@@ -241,7 +241,7 @@ export default class SettingsCommand extends BushCommand {
}
const collector = msg.createMessageComponentCollector({
time: 300_000,
- filter: (i) => i.guildId === message.guildId && i.message.id === message.id
+ filter: (i) => i.guildId === msg.guildId && i.message.id === msg.id
});
collector.on('collect', async (interaction: MessageComponentInteraction) => {
diff --git a/src/commands/config/features.ts b/src/commands/config/features.ts
index 743b243..076d469 100644
--- a/src/commands/config/features.ts
+++ b/src/commands/config/features.ts
@@ -30,7 +30,7 @@ export default class FeaturesCommand extends BushCommand {
const collector = msg.createMessageComponentCollector({
componentType: 'SELECT_MENU',
time: 300_000,
- filter: (i) => i.guildId === message.guildId && i.message.id === message.id
+ filter: (i) => i.guildId === msg.guildId && i.message.id === msg.id
});
collector.on('collect', async (interaction: SelectMenuInteraction) => {
diff --git a/src/commands/moderation/warn.ts b/src/commands/moderation/warn.ts
index 44f4f5a..b4bf74d 100644
--- a/src/commands/moderation/warn.ts
+++ b/src/commands/moderation/warn.ts
@@ -60,6 +60,7 @@ export default class WarnCommand extends BushCommand {
{ user, reason, force }: { user: BushUser; reason: string; force: boolean }
): Promise<unknown> {
const member = message.guild!.members.cache.get(user.id) as BushGuildMember;
+ if (!member) return message.util.reply(`${util.emojis.error} I cannot warn users that are not in the server.`);
const useForce = force && message.author.isOwner();
if (!message.member) throw new Error(`message.member is null`);
const canModerateResponse = await util.moderationPermissionCheck(message.member, member, 'warn', true, useForce);
diff --git a/src/commands/utilities/wolframAlpha.ts b/src/commands/utilities/wolframAlpha.ts
index 69e2ff4..2b64c9c 100644
--- a/src/commands/utilities/wolframAlpha.ts
+++ b/src/commands/utilities/wolframAlpha.ts
@@ -1,5 +1,5 @@
import { AllowedMentions, BushCommand, BushMessage, BushSlashMessage } from '@lib';
-import { MessageEmbed } from 'discord.js';
+import { CommandInteraction, MessageEmbed } from 'discord.js';
// @ts-expect-error: no types :(
import WolframAlphaAPI from 'wolfram-alpha-api';
@@ -39,6 +39,8 @@ export default class WolframAlphaCommand extends BushCommand {
});
}
public override async exec(message: BushMessage | BushSlashMessage, args: { expression: string }): Promise<unknown> {
+ if (message.util.isSlash) await (message.interaction as CommandInteraction).deferReply();
+
const waApi = WolframAlphaAPI(client.config.credentials.wolframAlphaAppId);
const decodedEmbed = new MessageEmbed().addField('📥 Input', await util.inspectCleanRedactCodeblock(args.expression));
diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts
index 64616f0..498b9cb 100644
--- a/src/lib/extensions/discord-akairo/BushClientUtil.ts
+++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts
@@ -1095,7 +1095,7 @@ export class BushClientUtil extends ClientUtil {
if (force) return true;
// If the victim is not in the guild anymore it will be undefined
- if (!victim.guild && ['ban', 'unban'].includes(type)) return true;
+ if ((!victim || !victim.guild) && !['ban', 'unban'].includes(type)) return true;
if (moderator.guild.id !== victim.guild.id) {
throw new Error('moderator and victim not in same guild');
@@ -1519,6 +1519,14 @@ export class BushClientUtil extends ClientUtil {
}
/**
+ * Removes all characters in a string that are either control characters or change the direction of text etc.
+ */
+ public sanitizeWtlAndControl(str: string) {
+ // eslint-disable-next-line no-control-regex
+ return str.replace(/[\u0000-\u001F\u007F-\u009F\u200B]/g, '');
+ }
+
+ /**
* Discord.js's Util class
*/
get discord() {
diff --git a/src/lib/models/Guild.ts b/src/lib/models/Guild.ts
index 1897068..ab18d05 100644
--- a/src/lib/models/Guild.ts
+++ b/src/lib/models/Guild.ts
@@ -92,10 +92,10 @@ export const guildFeaturesObj = {
name: 'Auto Publish',
description: 'Publishes messages in configured announcement channels.'
},
- autoThread: {
- name: 'Auto Thread',
- description: 'Creates a new thread for messages in configured channels.'
- },
+ // autoThread: {
+ // name: 'Auto Thread',
+ // description: 'Creates a new thread for messages in configured channels.'
+ // },
blacklistedFile: {
name: 'Blacklisted File',
description: 'Automatically deletes malicious files.'
diff --git a/src/lib/utils/BushConstants.ts b/src/lib/utils/BushConstants.ts
index 68c0951..0e1388e 100644
--- a/src/lib/utils/BushConstants.ts
+++ b/src/lib/utils/BushConstants.ts
@@ -228,8 +228,11 @@ export class BushConstants {
REQUEST_TO_SPEAK: { name: 'Request to Speak', important: false },
MANAGE_THREADS: { name: 'Manage Threads', important: true },
USE_PUBLIC_THREADS: { name: 'Use public Threads', important: false },
+ CREATE_PUBLIC_THREADS: { name: 'Create Public Threads', important: false },
USE_PRIVATE_THREADS: { name: 'Use Private Threads', important: false },
+ CREATE_PRIVATE_THREADS: { name: 'Create Private Threads', important: false },
USE_EXTERNAL_STICKERS: { name: 'Use External Stickers', important: false },
+ SEND_MESSAGES_IN_THREADS: { name: 'Send Messages In Threads', important: false },
START_EMBEDDED_ACTIVITIES: { name: 'Start Activities', important: false }
},
diff --git a/src/listeners/custom/bushMute.ts b/src/listeners/custom/bushMute.ts
index 615d698..d0f9e06 100644
--- a/src/listeners/custom/bushMute.ts
+++ b/src/listeners/custom/bushMute.ts
@@ -27,7 +27,7 @@ export default class BushMuteListener extends BushListener {
.addField('**User**', `${user} (${user.tag})`)
.addField('**Moderator**', `${moderator} (${moderator.tag})`)
.addField('**Reason**', `${reason ?? '[No Reason Provided]'}`);
- if (duration) logEmbed.addField('**Duration**', util.humanizeDuration(duration));
+ if (duration) logEmbed.addField('**Duration**', `${util.humanizeDuration(duration) || duration}`);
if (dmSuccess === false) logEmbed.addField('**Additional Info**', 'Could not dm user.');
return await logChannel.send({ embeds: [logEmbed] });
}
diff --git a/src/listeners/guild/guildMemberAdd.ts b/src/listeners/guild/guildMemberAdd.ts
index db014a8..cb8057f 100644
--- a/src/listeners/guild/guildMemberAdd.ts
+++ b/src/listeners/guild/guildMemberAdd.ts
@@ -25,18 +25,24 @@ export default class GuildMemberAddListener extends BushListener {
if (member.guild.id !== welcome?.guild.id) throw new Error('Welcome channel must be in the guild.');
const embed = new MessageEmbed()
.setDescription(
- `${util.emojis.join} **${Util.escapeMarkdown(
- member.user.tag
+ `${util.emojis.join} **${util.sanitizeWtlAndControl(
+ Util.escapeMarkdown(member.user.tag)
)}** joined the server. There are now ${member.guild.memberCount.toLocaleString()} members.`
)
.setColor(util.colors.green);
await welcome
.send({ embeds: [embed] })
.then(() =>
- client.console.info('guildMemberAdd', `Sent a message for <<${member.user.tag}>> in <<${member.guild.name}>>.`)
+ client.console.info(
+ 'guildMemberAdd',
+ `Sent a message for <<${util.sanitizeWtlAndControl(member.user.tag)}>> in <<${member.guild.name}>>.`
+ )
)
.catch(() =>
- 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 <<${util.sanitizeWtlAndControl(member.user.tag)}>> in <<${member.guild.name}>>.`
+ )
);
}
@@ -60,12 +66,16 @@ export default class GuildMemberAddListener extends BushListener {
const addedRoles = await member.roles
.add(rolesArray, "Returning member's previous roles.")
.catch(
- () => void client.console.warn('guildMemberAdd', `There was an error returning <<${member.user.tag}>>'s roles.`)
+ () =>
+ void client.console.warn(
+ 'guildMemberAdd',
+ `There was an error returning <<${util.sanitizeWtlAndControl(member.user.tag)}>>'s roles.`
+ )
);
if (addedRoles) {
void client.console.info(
'guildMemberAdd',
- `Assigned sticky roles to <<${member.user.tag}>> in <<${member.guild.name}>>.`
+ `Assigned sticky roles to <<${util.sanitizeWtlAndControl(member.user.tag)}>> in <<${member.guild.name}>>.`
);
} else if (!addedRoles) {
const failedRoles: string[] = [];
@@ -75,11 +85,13 @@ export default class GuildMemberAddListener extends BushListener {
.catch(() => failedRoles.push(rolesArray[i]));
}
if (failedRoles.length) {
- void 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 client.console.info(
'guildMemberAdd',
- `[Fallback] Assigned sticky roles to <<${member.user.tag}>> in <<${member.guild.name}>>.`
+ `[Fallback] Assigned sticky roles to <<${util.sanitizeWtlAndControl(member.user.tag)}>> in <<${
+ member.guild.name
+ }>>.`
);
}
}
@@ -90,13 +102,18 @@ export default class GuildMemberAddListener extends BushListener {
await member.roles
.add(joinRoles, 'Join roles.')
.then(() =>
- client.console.info('guildMemberAdd', `Assigned join roles to <<${member.user.tag}>> in <<${member.guild.name}>>.`)
+ client.console.info(
+ 'guildMemberAdd',
+ `Assigned join roles to <<${util.sanitizeWtlAndControl(member.user.tag)}>> in <<${member.guild.name}>>.`
+ )
)
.catch(
() =>
void client.console.warn(
'guildMemberAdd',
- `Failed to assign join roles to <<${member.user.tag}>>, in <<${member.guild.name}>>.`
+ `Failed to assign join roles to <<${util.sanitizeWtlAndControl(member.user.tag)}>>, in <<${
+ member.guild.name
+ }>>.`
)
);
}
diff --git a/src/listeners/guild/guildMemberRemove.ts b/src/listeners/guild/guildMemberRemove.ts
index 90634d6..5f13f22 100644
--- a/src/listeners/guild/guildMemberRemove.ts
+++ b/src/listeners/guild/guildMemberRemove.ts
@@ -27,16 +27,24 @@ export default class GuildMemberRemoveListener extends BushListener {
if (member.guild.id !== welcome?.guild.id) throw new Error('Welcome channel must be in the guild.');
const embed: MessageEmbed = new MessageEmbed()
.setDescription(
- `${util.emojis.leave} **${Util.escapeBold(user.tag)}** ${
- isBan ? 'banned from' : 'left'
+ `${util.emojis.leave} **${util.sanitizeWtlAndControl(Util.escapeBold(user.tag))}** ${
+ isBan ? 'got banned from' : 'left'
} the server. There are now ${welcome.guild.memberCount.toLocaleString()} members.`
)
.setColor(isBan ? util.colors.orange : util.colors.red);
welcome
.send({ embeds: [embed] })
- .then(() => client.console.info('guildMemberRemove', `Sent a message for <<${user.tag}>> in <<${member.guild.name}>>.`))
+ .then(() =>
+ client.console.info(
+ 'guildMemberRemove',
+ `Sent a message for <<${util.sanitizeWtlAndControl(user.tag)}>> in <<${member.guild.name}>>.`
+ )
+ )
.catch(() =>
- client.console.warn('guildMemberRemove', `Failed to send message for <<${user.tag}>> in <<${member.guild.name}>>.`)
+ client.console.warn(
+ 'guildMemberRemove',
+ `Failed to send message for <<${util.sanitizeWtlAndControl(user.tag)}>> in <<${member.guild.name}>>.`
+ )
);
}
@@ -65,7 +73,10 @@ export default class GuildMemberRemoveListener extends BushListener {
await row
.save()
.then(() =>
- client.console.info('guildMemberRemove', `${isNew ? 'Created' : 'Updated'} info for <<${member.user.tag}>>.`)
+ client.console.info(
+ 'guildMemberRemove',
+ `${isNew ? 'Created' : 'Updated'} info for <<${util.sanitizeWtlAndControl(member.user.tag)}>>.`
+ )
);
}
}
diff --git a/src/listeners/message/automodCreate.ts b/src/listeners/message/automodCreate.ts
index c3c89ff..03c1603 100644
--- a/src/listeners/message/automodCreate.ts
+++ b/src/listeners/message/automodCreate.ts
@@ -41,14 +41,15 @@ export default class AutomodMessageCreateListener extends BushListener {
const offences: { [key: string]: 0 | 1 | 2 | 3 } = {};
const cleanMessageContent = message.content?.toLowerCase().replace(/ /g, '');
- wordKeys.forEach((word) => {
+ for (const word in wordKeys) {
const cleanWord = word.toLowerCase().replace(/ /g, '');
if (cleanMessageContent.includes(cleanWord)) {
if (cleanWord === 'whore' && !message.content?.toLowerCase().includes(cleanWord)) return;
if (!offences[word]) offences[word] = wordMap[word as keyof typeof wordMap];
}
- });
+ }
+
if (!Object.keys(offences)?.length) return;
const highestOffence = Object.values(offences).sort((a, b) => b - a)[0];
diff --git a/yarn.lock b/yarn.lock
index ae43e9e..c724cb4 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1099,21 +1099,21 @@ __metadata:
languageName: node
linkType: hard
-"discord-akairo-message-util@github:NotEnoughUpdates/discord-akairo-message-util":
+"discord-akairo-message-util@npm:@notenoughupdates/discord-akairo-message-util@latest":
version: 1.0.0
- resolution: "discord-akairo-message-util@https://github.com/NotEnoughUpdates/discord-akairo-message-util.git#commit=9831d4f340bc8c3452d3dfef0497f7844dee0f29"
- checksum: 037722daf405eb7afebc47423e29a54816f5ab245e4aa0b0f99ad4ed32980839e1d1a399c12310acb1cabd6890d929d870223bddba4b6c2d107b5a79c4a37108
+ resolution: "@notenoughupdates/discord-akairo-message-util@npm:1.0.0"
+ checksum: fdd0f3e7f6410eb2fdc21aa8d293ff6a378b29c81ee8b54afca156da488c6af0353c91856bf01c775b5576da96478ada26cfdbdff76d54b3254e78dcad78bfa7
languageName: node
linkType: hard
"discord-akairo@npm:@notenoughupdates/discord-akairo@latest":
- version: 9.0.1
- resolution: "@notenoughupdates/discord-akairo@npm:9.0.1"
+ version: 9.0.2
+ resolution: "@notenoughupdates/discord-akairo@npm:9.0.2"
dependencies:
- discord-akairo-message-util: "github:NotEnoughUpdates/discord-akairo-message-util"
+ discord-akairo-message-util: "npm:@notenoughupdates/discord-akairo-message-util@latest"
lodash: ^4.17.21
- source-map-support: ^0.5.19
- checksum: 8a629b1e86f81124088ab83f0396f0eafc7f941e9044aee36ed59f9861bd7241c5cf41d08e0b5f88e78cb2121d2aa799c4d800b1b023ad225b96c39d38529ee3
+ source-map-support: ^0.5.20
+ checksum: cc02fade00aab2069fb1b16e160b92f0e145b65e2cd0b021d1f3c8468209ad821ec4c0a84551bf035fe13599c96d53a631e66b9fd0756792ed392ea4989f87c9
languageName: node
linkType: hard
@@ -1132,8 +1132,8 @@ __metadata:
linkType: hard
"discord.js@npm:@notenoughupdates/discord.js@latest":
- version: 13.2.0-dev-909c8596cbb989b811ca50d07a9895e8c9246f7d
- resolution: "@notenoughupdates/discord.js@npm:13.2.0-dev-909c8596cbb989b811ca50d07a9895e8c9246f7d"
+ version: 13.2.0-dev-4b07030
+ resolution: "@notenoughupdates/discord.js@npm:13.2.0-dev-4b07030"
dependencies:
"@discordjs/builders": ^0.5.0
"@discordjs/collection": ^0.2.1
@@ -1143,7 +1143,7 @@ __metadata:
discord-api-types: ^0.22.0
node-fetch: ^2.6.1
ws: ^7.5.1
- checksum: 7abbc9daeacff716e44473bc5f928949e6d1216471510ecd76c430056ca7a239cd5c36dbe71e34f287d8bbc10ebc54e1d14f061ee13f9dacea4e346a0ae1d800
+ checksum: bd1fa96fd02568082cfe235e6d94ca18e9d80d236dca78b50ecf4584562fd7cf04d477966f9cd1d2c88fb051ce5d2a8a60c3699da20d81c4afc506baeaec085b
languageName: node
linkType: hard
@@ -2062,19 +2062,19 @@ __metadata:
languageName: node
linkType: hard
-"mime-db@npm:1.49.0":
- version: 1.49.0
- resolution: "mime-db@npm:1.49.0"
- checksum: 3744efc45b17896ff8a5934a761c434d5ffe3c7816662002d799ca9934347e00f99ae4d9b4ddf1c48d391cc9e522cc4523a6e77e7701f8e27c426e3e1d6e215a
+"mime-db@npm:1.50.0":
+ version: 1.50.0
+ resolution: "mime-db@npm:1.50.0"
+ checksum: 95fcc19c3664ae72391c8a7e4015dde7fb6817c98c951493ca3a1d48050feb8ee08810a372ce7d9e16310042d26e5bda168916f600583a9a583655eeea8ff5f5
languageName: node
linkType: hard
"mime-types@npm:^2.1.12":
- version: 2.1.32
- resolution: "mime-types@npm:2.1.32"
+ version: 2.1.33
+ resolution: "mime-types@npm:2.1.33"
dependencies:
- mime-db: 1.49.0
- checksum: 4487dfd2f872126d2c219ec731ad47a6169a438d5a4cce6ecef7594ce08eaefaf0d85429485a76ec005f095016c7ec488a24cf8bfcc0ea06de0355e23395746f
+ mime-db: 1.50.0
+ checksum: 05f2a0b3f169fbc51d79bdc7674ceb379dd07dbeadb0143059a7def865224686ee9f9051aeb340e98b6c11dbc06794ce0122181db4312cb1ad054fd90b0d510e
languageName: node
linkType: hard
@@ -2960,7 +2960,7 @@ __metadata:
languageName: node
linkType: hard
-"source-map-support@npm:^0.5.19, source-map-support@npm:^0.5.20":
+"source-map-support@npm:^0.5.20":
version: 0.5.20
resolution: "source-map-support@npm:0.5.20"
dependencies: