Skip to content

Commit 47b74af

Browse files
Merge pull request #177 from Pdzly/chores/suggest
2 parents 47be44c + 09aa8bc commit 47b74af

15 files changed

+443
-414
lines changed

src/modules/core/set.command.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ import {
88
Colors,
99
type ComponentType,
1010
GuildMember,
11+
MessageFlags,
1112
} from "discord.js";
1213
import type { Command } from "djs-slash-helper";
1314
import { type DDUser, getOrCreateUserById } from "../../store/models/DDUser.js";
1415
import { createStandardEmbed } from "../../util/embeds.js";
16+
1517
import { mentionIfPingable } from "../../util/users.js";
1618
import { levelForXp } from "../xp/xpRoles.util.js";
1719

@@ -120,12 +122,12 @@ export const SetCommand: Command<ApplicationCommandType.ChatInput> = {
120122
const event = await collector.next;
121123
if (event.customId === "cancel") {
122124
await event.reply({
123-
flags: ["Ephemeral"],
125+
flags: MessageFlags.Ephemeral,
124126
content: "**Cancelled**",
125127
});
126128
} else if (event.customId === "confirm") {
127129
await event.deferReply({
128-
flags: "Ephemeral",
130+
flags: MessageFlags.Ephemeral,
129131
});
130132
setter(user, value);
131133
await user.save();
@@ -141,7 +143,7 @@ export const SetCommand: Command<ApplicationCommandType.ChatInput> = {
141143
],
142144
});
143145
await event.followUp({
144-
flags: "Ephemeral",
146+
flags: MessageFlags.Ephemeral,
145147
content: "Success!",
146148
});
147149
}

src/modules/faq/faq.command.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ import {
22
ApplicationCommandOptionType,
33
ApplicationCommandType,
44
type GuildMember,
5+
MessageFlags,
56
PermissionFlagsBits,
67
} from "discord.js";
78
import type { Command, ExecutableSubcommand } from "djs-slash-helper";
89
import { moduleManager } from "../../index.js";
910
import { logger } from "../../logging.js";
1011
import { FAQ } from "../../store/models/FAQ.js";
12+
1113
import createFaqModal from "./faq.modal.js";
1214
import { createFaqEmbed } from "./faq.util.js";
1315

@@ -45,7 +47,7 @@ const GetSubcommand: ExecutableSubcommand = {
4547
});
4648
if (faq == null) {
4749
return await interaction.reply({
48-
flags: ["Ephemeral"],
50+
flags: MessageFlags.Ephemeral,
4951
content: "No FAQ found with this name",
5052
});
5153
}
@@ -69,14 +71,14 @@ const EditSubcommand: ExecutableSubcommand = {
6971
const member = interaction.member as GuildMember;
7072
if (!member.permissions.has(PermissionFlagsBits.ManageMessages)) {
7173
return await interaction.reply({
72-
flags: ["Ephemeral"],
74+
flags: MessageFlags.Ephemeral,
7375
content: "No permission",
7476
});
7577
}
7678
const name = interaction.options.get("name")?.value as string | null;
7779
if (name == null) {
7880
return await interaction.reply({
79-
flags: ["Ephemeral"],
81+
flags: MessageFlags.Ephemeral,
8082
content: "No FAQ name provided",
8183
});
8284
}
@@ -97,7 +99,7 @@ const EditSubcommand: ExecutableSubcommand = {
9799
author: BigInt(interaction.user.id),
98100
});
99101
await response.reply({
100-
flags: ["Ephemeral"],
102+
flags: MessageFlags.Ephemeral,
101103
content: `FAQ named ${name} created`,
102104
});
103105

@@ -123,30 +125,30 @@ const DeleteSubcommand: ExecutableSubcommand = {
123125
const member = interaction.member as GuildMember;
124126
if (!member.permissions.has(PermissionFlagsBits.ManageMessages)) {
125127
return await interaction.reply({
126-
flags: ["Ephemeral"],
128+
flags: MessageFlags.Ephemeral,
127129
content: "No permission",
128130
});
129131
}
130132
const name = interaction.options.get("name")?.value as string | null;
131133
if (name == null) {
132134
return await interaction.reply({
133-
flags: ["Ephemeral"],
135+
flags: MessageFlags.Ephemeral,
134136
content: "No FAQ name provided",
135137
});
136138
}
137139

138140
const faq = await FAQ.findOne({ where: { name } });
139141
if (faq == null) {
140142
return await interaction.reply({
141-
flags: ["Ephemeral"],
143+
flags: MessageFlags.Ephemeral,
142144
content: "No FAQ found with this name",
143145
});
144146
}
145147
await faq.destroy();
146148
await updateChoices();
147149
await moduleManager.refreshCommands();
148150
return await interaction.reply({
149-
flags: ["Ephemeral"],
151+
flags: MessageFlags.Ephemeral,
150152
content: `FAQ named ${name} deleted`,
151153
});
152154
},

src/modules/information/informationMessage.command.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
type APIEmbed,
44
ApplicationCommandType,
55
ButtonBuilder,
6+
MessageFlags,
67
} from "discord.js";
78
import type { Command } from "djs-slash-helper";
89
import { config } from "../../Config.js";
@@ -30,15 +31,15 @@ export const InformationMessageCommand: Command<ApplicationCommandType.Message>
3031
async handle(interaction) {
3132
if (!interaction.targetMessage.editable) {
3233
await interaction.reply({
33-
flags: ["Ephemeral"],
34+
flags: MessageFlags.Ephemeral,
3435
content: "I can't edit that message.",
3536
});
3637
return;
3738
}
3839

3940
if (config.informationMessage == null) {
4041
await interaction.reply({
41-
flags: ["Ephemeral"],
42+
flags: MessageFlags.Ephemeral,
4243
content: "There is no information message configured.",
4344
});
4445
return;
@@ -67,7 +68,7 @@ export const InformationMessageCommand: Command<ApplicationCommandType.Message>
6768
)}`,
6869
);
6970
await interaction.reply({
70-
flags: ["Ephemeral"],
71+
flags: MessageFlags.Ephemeral,
7172
content: "Information message set.",
7273
});
7374
},

src/modules/information/informationMessage.listener.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ import {
33
type ButtonInteraction,
44
type GuildMember,
55
type Interaction,
6+
MessageFlags,
67
StringSelectMenuBuilder,
78
StringSelectMenuOptionBuilder,
89
} from "discord.js";
910
import { FAQ } from "../../store/models/FAQ.js";
1011
import { getEmoji, toAPIMessageComponentEmoji } from "../../util/emojis.js";
12+
1113
import { truncateTo } from "../../util/strings.js";
1214
import { createFaqEmbed } from "../faq/faq.util.js";
1315
import { getResourceEmbed } from "../learning/learning.command.js";
@@ -24,7 +26,7 @@ export const InformationButtonListener: EventListener = {
2426
interaction.customId === "learningResourcePicker"
2527
) {
2628
const resourceName = interaction.values[0];
27-
await interaction.deferReply({ flags: "Ephemeral" });
29+
await interaction.deferReply({ flags: MessageFlags.Ephemeral });
2830
const resource = await getResource(resourceName);
2931
if (resource == null) {
3032
return; // shouldn't ever happen
@@ -38,7 +40,7 @@ export const InformationButtonListener: EventListener = {
3840

3941
await interaction.followUp({
4042
embeds: [embed],
41-
flags: ["Ephemeral"],
43+
flags: MessageFlags.Ephemeral,
4244
});
4345
return;
4446
}
@@ -71,7 +73,7 @@ export const InformationButtonListener: EventListener = {
7173
(interaction.member as GuildMember) ?? undefined,
7274
);
7375
await interaction.followUp({
74-
flags: ["Ephemeral"],
76+
flags: MessageFlags.Ephemeral,
7577
embeds: [embed],
7678
});
7779
},
@@ -101,7 +103,7 @@ async function sendLearningResourcesPicker(interaction: ButtonInteraction) {
101103
components: [
102104
new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(selectMenu),
103105
],
104-
flags: ["Ephemeral"],
106+
flags: MessageFlags.Ephemeral,
105107
withResponse: false,
106108
});
107109
}

src/modules/learning/learning.command.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
ApplicationCommandType,
44
type Client,
55
type GuildMember,
6+
MessageFlags,
67
PermissionFlagsBits,
78
type User,
89
} from "discord.js";
@@ -11,6 +12,7 @@ import { moduleManager } from "../../index.js";
1112
import { logger } from "../../logging.js";
1213
import { createStandardEmbed, standardFooter } from "../../util/embeds.js";
1314
import { getEmoji, stringifyEmoji } from "../../util/emojis.js";
15+
1416
import { fakeMention } from "../../util/users.js";
1517
import type { LearningResource } from "./learningResource.model.js";
1618
import {
@@ -132,12 +134,14 @@ const LearningUpdateSubcommand: ExecutableSubcommand = {
132134
const member = interaction.member as GuildMember;
133135
if (!member.permissions.has(PermissionFlagsBits.ManageMessages)) {
134136
return await interaction.reply({
135-
flags: ["Ephemeral"],
137+
flags: MessageFlags.Ephemeral,
136138
content: "No permission",
137139
});
138140
}
139141

140-
await interaction.deferReply({ flags: "Ephemeral" });
142+
await interaction.deferReply({
143+
flags: MessageFlags.Ephemeral,
144+
});
141145
await updateResourcesForCommands();
142146
await moduleManager.refreshCommands();
143147
await interaction.followUp("Updated learning resources cache");
@@ -167,7 +171,7 @@ const LearningListSubcommand: ExecutableSubcommand = {
167171
});
168172

169173
await interaction.reply({
170-
flags: ["Ephemeral"],
174+
flags: MessageFlags.Ephemeral,
171175
embeds: [embed],
172176
});
173177
},

src/modules/moderation/kick.command.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
ApplicationCommandOptionType,
33
ApplicationCommandType,
4+
MessageFlags,
45
} from "discord.js";
56
import type { Command } from "djs-slash-helper";
67
import { logger } from "../../logging.js";
@@ -68,7 +69,7 @@ export const KickCommand: Command<ApplicationCommandType.ChatInput> = {
6869
await interaction.editReply("Something went wrong!");
6970
} else {
7071
await interaction.followUp({
71-
flags: "Ephemeral",
72+
flags: MessageFlags.Ephemeral,
7273
content: "Failed to kick member!",
7374
});
7475
}

0 commit comments

Comments
 (0)