aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/commands/info/pronouns.ts15
-rw-r--r--src/commands/moulberry-bush/capePermissions.ts9
-rw-r--r--src/commands/moulberry-bush/capes.ts7
-rw-r--r--src/commands/utilities/highlight-clear.ts7
-rw-r--r--src/commands/utilities/uuid.ts12
-rw-r--r--src/lib/extensions/discord-akairo/BushClient.ts2
-rw-r--r--src/lib/utils/AllowedMentions.ts82
7 files changed, 93 insertions, 41 deletions
diff --git a/src/commands/info/pronouns.ts b/src/commands/info/pronouns.ts
index 043b660..b45f9b3 100644
--- a/src/commands/info/pronouns.ts
+++ b/src/commands/info/pronouns.ts
@@ -1,4 +1,4 @@
-import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { AllowedMentions, BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
import { ApplicationCommandOptionType, EmbedBuilder, PermissionFlagsBits } from 'discord.js';
export default class PronounsCommand extends BushCommand {
@@ -34,11 +34,14 @@ export default class PronounsCommand extends BushCommand {
const pronouns = await util.getPronounsOf(user);
if (!pronouns) {
- return await message.util.reply(
- `${author ? 'You do' : `${util.discord.escapeMarkdown(user.tag)} does`} not appear to have any pronouns set. Please${
- author ? '' : ' tell them to'
- } go to https://pronoundb.org/ and set ${author ? 'your' : 'their'} pronouns.`
- );
+ return await message.util.reply({
+ content: `${
+ author ? 'You do' : `${util.discord.escapeMarkdown(user.tag)} does`
+ } not appear to have any pronouns set. Please${author ? '' : ' tell them to'} go to https://pronoundb.org/ and set ${
+ author ? 'your' : 'their'
+ } pronouns.`,
+ allowedMentions: AllowedMentions.none()
+ });
} else {
return await message.util.reply({
embeds: [
diff --git a/src/commands/moulberry-bush/capePermissions.ts b/src/commands/moulberry-bush/capePermissions.ts
index 93cfb99..dd210e2 100644
--- a/src/commands/moulberry-bush/capePermissions.ts
+++ b/src/commands/moulberry-bush/capePermissions.ts
@@ -1,4 +1,4 @@
-import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { AllowedMentions, BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
import { ApplicationCommandOptionType, EmbedBuilder, PermissionFlagsBits } from 'discord.js';
import got from 'got';
@@ -32,9 +32,10 @@ export default class CapePermissionsCommand extends BushCommand {
try {
uuid = await util.mcUUID(args.ign);
} catch (e) {
- return await message.util.reply(
- `${util.emojis.error} ${util.format.input(args.ign)} doesn't appear to be a valid username.`
- );
+ return await message.util.reply({
+ content: `${util.emojis.error} ${util.format.input(args.ign)} doesn't appear to be a valid username.`,
+ allowedMentions: AllowedMentions.none()
+ });
}
try {
diff --git a/src/commands/moulberry-bush/capes.ts b/src/commands/moulberry-bush/capes.ts
index a37388b..3f273c1 100644
--- a/src/commands/moulberry-bush/capes.ts
+++ b/src/commands/moulberry-bush/capes.ts
@@ -1,4 +1,4 @@
-import { BushCommand, ButtonPaginator, DeleteButton, type BushMessage, type OptArgType } from '#lib';
+import { AllowedMentions, BushCommand, ButtonPaginator, DeleteButton, type BushMessage, type OptArgType } from '#lib';
import assert from 'assert';
import { APIEmbed } from 'discord-api-types/v10';
import { ApplicationCommandOptionType, AutocompleteInteraction, PermissionFlagsBits } from 'discord.js';
@@ -68,7 +68,10 @@ export default class CapesCommand extends BushCommand {
const embed = this.makeEmbed(cape);
await DeleteButton.send(message, { embeds: [embed] });
} else {
- await message.util.reply(`${util.emojis.error} Cannot find a cape called ${util.format.input(args.cape)}.`);
+ await message.util.reply({
+ content: `${util.emojis.error} Cannot find a cape called ${util.format.input(args.cape)}.`,
+ allowedMentions: AllowedMentions.none()
+ });
}
} else {
const embeds: APIEmbed[] = capes.map(this.makeEmbed);
diff --git a/src/commands/utilities/highlight-clear.ts b/src/commands/utilities/highlight-clear.ts
index 8c261c2..274c6fb 100644
--- a/src/commands/utilities/highlight-clear.ts
+++ b/src/commands/utilities/highlight-clear.ts
@@ -1,4 +1,4 @@
-import { AllowedMentions, BushCommand, ConfirmationPrompt, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, ConfirmationPrompt, type BushMessage, type BushSlashMessage } from '#lib';
import assert from 'assert';
import { highlightSubcommands } from './highlight-!.js';
@@ -26,9 +26,6 @@ export default class HighlightClearCommand extends BushCommand {
const success = await client.highlightManager.removeAllHighlights(message.guild.id, message.author.id);
if (!success) return await message.util.reply(`${util.emojis.error} There was an error clearing your highlight list.`);
- return await message.util.reply({
- content: `${util.emojis.success} Successfully cleared your highlight list.`,
- allowedMentions: AllowedMentions.none()
- });
+ return await message.util.reply(`${util.emojis.success} Successfully cleared your highlight list.`);
}
}
diff --git a/src/commands/utilities/uuid.ts b/src/commands/utilities/uuid.ts
index 3699478..448baf3 100644
--- a/src/commands/utilities/uuid.ts
+++ b/src/commands/utilities/uuid.ts
@@ -1,4 +1,4 @@
-import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
+import { AllowedMentions, BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
import { ApplicationCommandOptionType } from 'discord.js';
export default class UuidCommand extends BushCommand {
@@ -45,9 +45,15 @@ export default class UuidCommand extends BushCommand {
const readableIGN = ign.match[0];
try {
const uuid = await util.mcUUID(readableIGN, dashed);
- return await message.util.reply(`The uuid for ${util.format.input(readableIGN)} is ${util.format.input(uuid)}`);
+ return await message.util.reply({
+ content: `The uuid for ${util.format.input(readableIGN)} is ${util.format.input(uuid)}`,
+ allowedMentions: AllowedMentions.none()
+ });
} catch (e) {
- return await message.util.reply(`${util.emojis.error} Could not find an uuid for ${util.format.input(readableIGN)}.`);
+ return await message.util.reply({
+ content: `${util.emojis.error} Could not find an uuid for ${util.format.input(readableIGN)}.`,
+ allowedMentions: AllowedMentions.none()
+ });
}
}
}
diff --git a/src/lib/extensions/discord-akairo/BushClient.ts b/src/lib/extensions/discord-akairo/BushClient.ts
index ac4de5f..db0ad91 100644
--- a/src/lib/extensions/discord-akairo/BushClient.ts
+++ b/src/lib/extensions/discord-akairo/BushClient.ts
@@ -217,7 +217,7 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re
activities: [{ name: 'Beep Boop', type: ActivityType.Watching }],
status: 'online'
},
- allowedMentions: AllowedMentions.users(), // No everyone or role mentions by default
+ allowedMentions: AllowedMentions.none(), // no mentions by default
makeCache: Options.cacheWithLimits({}),
failIfNotExists: false,
rest: { api: 'https://canary.discord.com/api' }
diff --git a/src/lib/utils/AllowedMentions.ts b/src/lib/utils/AllowedMentions.ts
index 7a377be..400da76 100644
--- a/src/lib/utils/AllowedMentions.ts
+++ b/src/lib/utils/AllowedMentions.ts
@@ -1,51 +1,93 @@
import { type MessageMentionOptions, type MessageMentionTypes } from 'discord.js';
+/**
+ * A utility class for creating allowed mentions.
+ */
export class AllowedMentions {
+ /**
+ * Whether @everyone and @here should be mentioned.
+ */
public everyone: boolean;
+
+ /**
+ * Whether users should be mentioned.
+ */
public users: boolean;
+
+ /**
+ * Whether roles should be mentioned.
+ */
public roles: boolean;
- public constructor(users = true, roles = false, everyone = false) {
+ /**
+ * Whether the author of the Message being replied to should be mentioned.
+ */
+ public repliedUser: boolean;
+
+ /**
+ * @param users Whether users should be mentioned.
+ * @param roles Whether roles should be mentioned.
+ * @param everyone Whether @everyone and @here should be mentioned.
+ * @param repliedUser Whether the author of the Message being replied to should be mentioned.
+ */
+ public constructor(users = true, roles = false, everyone = false, repliedUser = true) {
this.everyone = everyone;
this.roles = roles;
this.users = users;
+ this.repliedUser = repliedUser;
}
- public static none(): MessageMentionOptions {
- return { parse: [] };
+ /**
+ * Don't mention anyone.
+ * @param repliedUser Whether the author of the Message being replied to should be mentioned.
+ */
+ public static none(repliedUser = true): MessageMentionOptions {
+ return { parse: [], repliedUser };
}
- public static all(): MessageMentionOptions {
- return {
- parse: ['everyone', 'roles', 'users']
- };
+ /**
+ * Mention @everyone and @here, roles, and users.
+ * @param repliedUser Whether the author of the Message being replied to should be mentioned.
+ */
+ public static all(repliedUser = true): MessageMentionOptions {
+ return { parse: ['everyone', 'roles', 'users'], repliedUser };
}
- public static users(): MessageMentionOptions {
- return {
- parse: ['users']
- };
+ /**
+ * Mention users.
+ * @param repliedUser Whether the author of the Message being replied to should be mentioned.
+ */
+ public static users(repliedUser = true): MessageMentionOptions {
+ return { parse: ['users'], repliedUser };
}
- public static everyone(): MessageMentionOptions {
- return {
- parse: ['everyone']
- };
+ /**
+ * Mention @everyone and @here.
+ * @param repliedUser Whether the author of the Message being replied to should be mentioned.
+ */
+ public static everyone(repliedUser = true): MessageMentionOptions {
+ return { parse: ['everyone'], repliedUser };
}
- public static roles(): MessageMentionOptions {
- return {
- parse: ['roles']
- };
+ /**
+ * Mention roles.
+ * @param repliedUser Whether the author of the Message being replied to should be mentioned.
+ */
+ public static roles(repliedUser = true): MessageMentionOptions {
+ return { parse: ['roles'], repliedUser };
}
+ /**
+ * Converts this into a MessageMentionOptions object.
+ */
public toObject(): MessageMentionOptions {
return {
parse: [
...(this.users ? ['users'] : []),
...(this.roles ? ['roles'] : []),
...(this.everyone ? ['everyone'] : [])
- ] as MessageMentionTypes[]
+ ] as MessageMentionTypes[],
+ repliedUser: this.repliedUser
};
}
}