Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/modules/core/set.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import {
Colors,
type ComponentType,
GuildMember,
MessageFlags,
} from "discord.js";
import type { Command } from "djs-slash-helper";
import { type DDUser, getOrCreateUserById } from "../../store/models/DDUser.js";
import { createStandardEmbed } from "../../util/embeds.js";

import { mentionIfPingable } from "../../util/users.js";
import { levelForXp } from "../xp/xpRoles.util.js";

Expand Down Expand Up @@ -120,12 +122,12 @@ export const SetCommand: Command<ApplicationCommandType.ChatInput> = {
const event = await collector.next;
if (event.customId === "cancel") {
await event.reply({
flags: ["Ephemeral"],
flags: MessageFlags.Ephemeral,
content: "**Cancelled**",
});
} else if (event.customId === "confirm") {
await event.deferReply({
flags: "Ephemeral",
flags: MessageFlags.Ephemeral,
});
setter(user, value);
await user.save();
Expand All @@ -141,7 +143,7 @@ export const SetCommand: Command<ApplicationCommandType.ChatInput> = {
],
});
await event.followUp({
flags: "Ephemeral",
flags: MessageFlags.Ephemeral,
content: "Success!",
});
}
Expand Down
18 changes: 10 additions & 8 deletions src/modules/faq/faq.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import {
ApplicationCommandOptionType,
ApplicationCommandType,
type GuildMember,
MessageFlags,
PermissionFlagsBits,
} from "discord.js";
import type { Command, ExecutableSubcommand } from "djs-slash-helper";
import { moduleManager } from "../../index.js";
import { logger } from "../../logging.js";
import { FAQ } from "../../store/models/FAQ.js";

import createFaqModal from "./faq.modal.js";
import { createFaqEmbed } from "./faq.util.js";

Expand Down Expand Up @@ -45,7 +47,7 @@ const GetSubcommand: ExecutableSubcommand = {
});
if (faq == null) {
return await interaction.reply({
flags: ["Ephemeral"],
flags: MessageFlags.Ephemeral,
content: "No FAQ found with this name",
});
}
Expand All @@ -69,14 +71,14 @@ const EditSubcommand: ExecutableSubcommand = {
const member = interaction.member as GuildMember;
if (!member.permissions.has(PermissionFlagsBits.ManageMessages)) {
return await interaction.reply({
flags: ["Ephemeral"],
flags: MessageFlags.Ephemeral,
content: "No permission",
});
}
const name = interaction.options.get("name")?.value as string | null;
if (name == null) {
return await interaction.reply({
flags: ["Ephemeral"],
flags: MessageFlags.Ephemeral,
content: "No FAQ name provided",
});
}
Expand All @@ -97,7 +99,7 @@ const EditSubcommand: ExecutableSubcommand = {
author: BigInt(interaction.user.id),
});
await response.reply({
flags: ["Ephemeral"],
flags: MessageFlags.Ephemeral,
content: `FAQ named ${name} created`,
});

Expand All @@ -123,30 +125,30 @@ const DeleteSubcommand: ExecutableSubcommand = {
const member = interaction.member as GuildMember;
if (!member.permissions.has(PermissionFlagsBits.ManageMessages)) {
return await interaction.reply({
flags: ["Ephemeral"],
flags: MessageFlags.Ephemeral,
content: "No permission",
});
}
const name = interaction.options.get("name")?.value as string | null;
if (name == null) {
return await interaction.reply({
flags: ["Ephemeral"],
flags: MessageFlags.Ephemeral,
content: "No FAQ name provided",
});
}

const faq = await FAQ.findOne({ where: { name } });
if (faq == null) {
return await interaction.reply({
flags: ["Ephemeral"],
flags: MessageFlags.Ephemeral,
content: "No FAQ found with this name",
});
}
await faq.destroy();
await updateChoices();
await moduleManager.refreshCommands();
return await interaction.reply({
flags: ["Ephemeral"],
flags: MessageFlags.Ephemeral,
content: `FAQ named ${name} deleted`,
});
},
Expand Down
7 changes: 4 additions & 3 deletions src/modules/information/informationMessage.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
type APIEmbed,
ApplicationCommandType,
ButtonBuilder,
MessageFlags,
} from "discord.js";
import type { Command } from "djs-slash-helper";
import { config } from "../../Config.js";
Expand Down Expand Up @@ -30,15 +31,15 @@ export const InformationMessageCommand: Command<ApplicationCommandType.Message>
async handle(interaction) {
if (!interaction.targetMessage.editable) {
await interaction.reply({
flags: ["Ephemeral"],
flags: MessageFlags.Ephemeral,
content: "I can't edit that message.",
});
return;
}

if (config.informationMessage == null) {
await interaction.reply({
flags: ["Ephemeral"],
flags: MessageFlags.Ephemeral,
content: "There is no information message configured.",
});
return;
Expand Down Expand Up @@ -67,7 +68,7 @@ export const InformationMessageCommand: Command<ApplicationCommandType.Message>
)}`,
);
await interaction.reply({
flags: ["Ephemeral"],
flags: MessageFlags.Ephemeral,
content: "Information message set.",
});
},
Expand Down
10 changes: 6 additions & 4 deletions src/modules/information/informationMessage.listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import {
type ButtonInteraction,
type GuildMember,
type Interaction,
MessageFlags,
StringSelectMenuBuilder,
StringSelectMenuOptionBuilder,
} from "discord.js";
import { FAQ } from "../../store/models/FAQ.js";
import { getEmoji, toAPIMessageComponentEmoji } from "../../util/emojis.js";

import { truncateTo } from "../../util/strings.js";
import { createFaqEmbed } from "../faq/faq.util.js";
import { getResourceEmbed } from "../learning/learning.command.js";
Expand All @@ -24,7 +26,7 @@ export const InformationButtonListener: EventListener = {
interaction.customId === "learningResourcePicker"
) {
const resourceName = interaction.values[0];
await interaction.deferReply({ flags: "Ephemeral" });
await interaction.deferReply({ flags: MessageFlags.Ephemeral });
const resource = await getResource(resourceName);
if (resource == null) {
return; // shouldn't ever happen
Expand All @@ -38,7 +40,7 @@ export const InformationButtonListener: EventListener = {

await interaction.followUp({
embeds: [embed],
flags: ["Ephemeral"],
flags: MessageFlags.Ephemeral,
});
return;
}
Expand Down Expand Up @@ -71,7 +73,7 @@ export const InformationButtonListener: EventListener = {
(interaction.member as GuildMember) ?? undefined,
);
await interaction.followUp({
flags: ["Ephemeral"],
flags: MessageFlags.Ephemeral,
embeds: [embed],
});
},
Expand Down Expand Up @@ -101,7 +103,7 @@ async function sendLearningResourcesPicker(interaction: ButtonInteraction) {
components: [
new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(selectMenu),
],
flags: ["Ephemeral"],
flags: MessageFlags.Ephemeral,
withResponse: false,
});
}
10 changes: 7 additions & 3 deletions src/modules/learning/learning.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
ApplicationCommandType,
type Client,
type GuildMember,
MessageFlags,
PermissionFlagsBits,
type User,
} from "discord.js";
Expand All @@ -11,6 +12,7 @@ import { moduleManager } from "../../index.js";
import { logger } from "../../logging.js";
import { createStandardEmbed, standardFooter } from "../../util/embeds.js";
import { getEmoji, stringifyEmoji } from "../../util/emojis.js";

import { fakeMention } from "../../util/users.js";
import type { LearningResource } from "./learningResource.model.js";
import {
Expand Down Expand Up @@ -132,12 +134,14 @@ const LearningUpdateSubcommand: ExecutableSubcommand = {
const member = interaction.member as GuildMember;
if (!member.permissions.has(PermissionFlagsBits.ManageMessages)) {
return await interaction.reply({
flags: ["Ephemeral"],
flags: MessageFlags.Ephemeral,
content: "No permission",
});
}

await interaction.deferReply({ flags: "Ephemeral" });
await interaction.deferReply({
flags: MessageFlags.Ephemeral,
});
await updateResourcesForCommands();
await moduleManager.refreshCommands();
await interaction.followUp("Updated learning resources cache");
Expand Down Expand Up @@ -167,7 +171,7 @@ const LearningListSubcommand: ExecutableSubcommand = {
});

await interaction.reply({
flags: ["Ephemeral"],
flags: MessageFlags.Ephemeral,
embeds: [embed],
});
},
Expand Down
3 changes: 2 additions & 1 deletion src/modules/moderation/kick.command.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
ApplicationCommandOptionType,
ApplicationCommandType,
MessageFlags,
} from "discord.js";
import type { Command } from "djs-slash-helper";
import { logger } from "../../logging.js";
Expand Down Expand Up @@ -68,7 +69,7 @@ export const KickCommand: Command<ApplicationCommandType.ChatInput> = {
await interaction.editReply("Something went wrong!");
} else {
await interaction.followUp({
flags: "Ephemeral",
flags: MessageFlags.Ephemeral,
content: "Failed to kick member!",
});
}
Expand Down
Loading