Skip to content

Commit 88dffa1

Browse files
authored
refactor: resolve deprecation of ephemeral option (#2718)
1 parent 1cba773 commit 88dffa1

8 files changed

Lines changed: 31 additions & 26 deletions

File tree

src/commands/General/info.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
ButtonStyle,
1111
ComponentType,
1212
InteractionContextType,
13+
MessageFlags,
1314
OAuth2Scopes,
1415
PermissionFlagsBits,
1516
chatInputApplicationCommandMention,
@@ -58,7 +59,7 @@ export class UserCommand extends SkyraCommand {
5859
.addFields(this.getApplicationStatistics(t), this.getUptimeStatistics(t), this.getServerUsageStatistics(t));
5960
const components = this.getComponents(t);
6061

61-
return interaction.reply({ embeds: [embed], components, ephemeral: true });
62+
return interaction.reply({ embeds: [embed], components, flags: MessageFlags.Ephemeral });
6263
}
6364

6465
private getApplicationStatistics(t: TFunction): APIEmbedField {

src/commands/Management/AutoModeration/automod-words.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { send } from '@sapphire/plugin-editable-commands';
1818
import { applyLocalizedBuilder, type TFunction } from '@sapphire/plugin-i18next';
1919
import { isNullishOrEmpty, type Awaitable } from '@sapphire/utilities';
2020
import { remove as removeConfusables } from 'confusables';
21-
import { inlineCode, type Guild } from 'discord.js';
21+
import { inlineCode, MessageFlags, type Guild } from 'discord.js';
2222

2323
const Root = LanguageKeys.Commands.AutoModeration;
2424

@@ -63,11 +63,11 @@ export class UserAutoModerationCommand extends AutoModerationCommand {
6363
const t = getSupportedUserLanguageT(interaction);
6464
using trx = await writeSettingsTransaction(guild);
6565
if (await this.#hasWord(trx.settings, word)) {
66-
return interaction.reply({ content: t(Root.WordAddFiltered, { word }), ephemeral: true });
66+
return interaction.reply({ content: t(Root.WordAddFiltered, { word }), flags: MessageFlags.Ephemeral });
6767
}
6868

6969
await trx.write({ selfmodFilterRaw: trx.settings.selfmodFilterRaw.concat(word) }).submit();
70-
return interaction.reply({ content: t(Root.EditSuccess), ephemeral: true });
70+
return interaction.reply({ content: t(Root.EditSuccess), flags: MessageFlags.Ephemeral });
7171
}
7272

7373
public async chatInputRunRemove(interaction: AutoModerationCommand.Interaction) {
@@ -79,11 +79,11 @@ export class UserAutoModerationCommand extends AutoModerationCommand {
7979

8080
const index = trx.settings.selfmodFilterRaw.indexOf(word);
8181
if (index === -1) {
82-
return interaction.reply({ content: t(Root.WordRemoveNotFiltered, { word }), ephemeral: true });
82+
return interaction.reply({ content: t(Root.WordRemoveNotFiltered, { word }), flags: MessageFlags.Ephemeral });
8383
}
8484

8585
await trx.write({ selfmodFilterRaw: trx.settings.selfmodFilterRaw.toSpliced(index, 1) }).submit();
86-
return interaction.reply({ content: t(Root.EditSuccess), ephemeral: true });
86+
return interaction.reply({ content: t(Root.EditSuccess), flags: MessageFlags.Ephemeral });
8787
}
8888

8989
protected override showEnabled(t: TFunction, settings: ReadonlyGuildData) {

src/commands/Misc/snipe.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { ApplyOptions } from '@sapphire/decorators';
1010
import { ApplicationCommandRegistry, CommandOptionsRunTypeEnum } from '@sapphire/framework';
1111
import { send } from '@sapphire/plugin-editable-commands';
1212
import { applyLocalizedBuilder } from '@sapphire/plugin-i18next';
13-
import { InteractionContextType, PermissionFlagsBits, type GuildTextBasedChannel } from 'discord.js';
13+
import { InteractionContextType, MessageFlags, PermissionFlagsBits, type GuildTextBasedChannel } from 'discord.js';
1414

1515
const Root = LanguageKeys.Commands.Snipe;
1616

@@ -51,7 +51,7 @@ export class UserCommand extends SkyraCommand {
5151
const sniped = getSnipedMessage(interaction.channel as GuildTextBasedChannel);
5252
if (sniped === null) {
5353
const content = t(Root.MessageEmpty);
54-
return interaction.reply({ content, ephemeral: true });
54+
return interaction.reply({ content, flags: MessageFlags.Ephemeral });
5555
}
5656

5757
const embed = new EmbedBuilder()
@@ -65,6 +65,6 @@ export class UserCommand extends SkyraCommand {
6565
if (content !== null) embed.setDescription(content);
6666

6767
const embeds = setMultipleEmbedImages(embed, getImages(sniped));
68-
return interaction.reply({ embeds, ephemeral: true });
68+
return interaction.reply({ embeds, flags: MessageFlags.Ephemeral });
6969
}
7070
}

src/commands/Moderation/Utilities/case.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { cutText, isNullish, isNullishOrEmpty, isNullishOrZero } from '@sapphire
1919
import {
2020
EmbedBuilder,
2121
InteractionContextType,
22+
MessageFlags,
2223
PermissionFlagsBits,
2324
TimestampStyles,
2425
User,
@@ -147,12 +148,12 @@ export class UserCommand extends SkyraSubcommand {
147148
const action = getAction(entry.type);
148149
if (!action.isUndoActionAvailable) {
149150
const content = t(Root.TimeNotAllowed, { type: t(getTranslationKey(entry.type)) });
150-
return interaction.reply({ content, ephemeral: true });
151+
return interaction.reply({ content, flags: MessageFlags.Ephemeral });
151152
}
152153

153154
if (entry.isCompleted()) {
154155
const content = t(Root.TimeNotAllowedInCompletedEntries, { caseId: entry.id });
155-
return interaction.reply({ content, ephemeral: true });
156+
return interaction.reply({ content, flags: MessageFlags.Ephemeral });
156157
}
157158

158159
if (duration !== 0) {
@@ -162,7 +163,7 @@ export class UserCommand extends SkyraSubcommand {
162163
start: time(seconds.fromMilliseconds(entry.createdAt), TimestampStyles.LongDateTime),
163164
time: time(seconds.fromMilliseconds(next), TimestampStyles.RelativeTime)
164165
});
165-
return interaction.reply({ content, ephemeral: true });
166+
return interaction.reply({ content, flags: MessageFlags.Ephemeral });
166167
}
167168
}
168169
}
@@ -173,23 +174,23 @@ export class UserCommand extends SkyraSubcommand {
173174
});
174175

175176
const content = t(Root.EditSuccess, { caseId: entry.id });
176-
return interaction.reply({ content, ephemeral: true });
177+
return interaction.reply({ content, flags: MessageFlags.Ephemeral });
177178
}
178179

179180
public async chatInputRunArchive(interaction: SkyraSubcommand.Interaction) {
180181
const entry = await this.#getCase(interaction, true);
181182
await getModeration(interaction.guild).archive(entry);
182183

183184
const content = getSupportedUserLanguageT(interaction)(Root.ArchiveSuccess, { caseId: entry.id });
184-
return interaction.reply({ content, ephemeral: true });
185+
return interaction.reply({ content, flags: MessageFlags.Ephemeral });
185186
}
186187

187188
public async chatInputRunDelete(interaction: SkyraSubcommand.Interaction) {
188189
const entry = await this.#getCase(interaction, true);
189190
await getModeration(interaction.guild).delete(entry);
190191

191192
const content = getSupportedUserLanguageT(interaction)(Root.DeleteSuccess, { caseId: entry.id });
192-
return interaction.reply({ content, ephemeral: true });
193+
return interaction.reply({ content, flags: MessageFlags.Ephemeral });
193194
}
194195

195196
public async viewMessageRun(message: GuildMessage, args: SkyraSubcommand.Args) {
@@ -217,7 +218,7 @@ export class UserCommand extends SkyraSubcommand {
217218
) {
218219
if (entries.length === 0) {
219220
const content = getSupportedUserLanguageT(interaction)(Root.ListEmpty);
220-
return interaction.reply({ content, ephemeral: true });
221+
return interaction.reply({ content, flags: MessageFlags.Ephemeral });
221222
}
222223

223224
await interaction.deferReply({ ephemeral: !show });

src/commands/Tools/whois.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
ChatInputCommandInteraction,
2121
GuildMember,
2222
InteractionContextType,
23+
MessageFlags,
2324
PermissionFlagsBits,
2425
UserContextMenuCommandInteraction,
2526
bold,
@@ -79,7 +80,7 @@ export class UserCommand extends SkyraCommand {
7980

8081
return interaction.reply({
8182
...this.sharedRun(getSupportedUserLanguageT(interaction), user, member),
82-
ephemeral: true
83+
flags: MessageFlags.Ephemeral
8384
});
8485
}
8586

@@ -89,7 +90,7 @@ export class UserCommand extends SkyraCommand {
8990

9091
return interaction.reply({
9192
...this.sharedRun(getSupportedUserLanguageT(interaction), user, member),
92-
ephemeral: true
93+
flags: MessageFlags.Ephemeral
9394
});
9495
}
9596

src/lib/moderation/structures/AutoModerationCommand.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { CommandOptionsRunTypeEnum, type ApplicationCommandRegistry } from '@sap
2323
import { send } from '@sapphire/plugin-editable-commands';
2424
import { applyLocalizedBuilder, createLocalizedChoice, type TFunction } from '@sapphire/plugin-i18next';
2525
import { isNullish, isNullishOrEmpty, isNullishOrZero, type Awaitable } from '@sapphire/utilities';
26-
import { InteractionContextType, PermissionFlagsBits, chatInputApplicationCommandMention, strikethrough, type Guild } from 'discord.js';
26+
import { InteractionContextType, MessageFlags, PermissionFlagsBits, chatInputApplicationCommandMention, strikethrough, type Guild } from 'discord.js';
2727

2828
const Root = LanguageKeys.Commands.AutoModeration;
2929
const RootModeration = LanguageKeys.Moderation;
@@ -128,7 +128,7 @@ export abstract class AutoModerationCommand extends SkyraSubcommand {
128128
const embed = settings[this.keyEnabled] //
129129
? this.showEnabled(t, settings)
130130
: this.showDisabled(t);
131-
return interaction.reply({ embeds: [embed], ephemeral: true });
131+
return interaction.reply({ embeds: [embed], flags: MessageFlags.Ephemeral });
132132
}
133133

134134
public async chatInputRunEdit(interaction: AutoModerationCommand.Interaction) {
@@ -163,7 +163,7 @@ export abstract class AutoModerationCommand extends SkyraSubcommand {
163163

164164
const t = getSupportedUserLanguageT(interaction);
165165
const content = t(Root.EditSuccess);
166-
return interaction.reply({ content, ephemeral: true });
166+
return interaction.reply({ content, flags: MessageFlags.Ephemeral });
167167
}
168168

169169
public async chatInputRunReset(interaction: AutoModerationCommand.Interaction) {
@@ -172,7 +172,7 @@ export abstract class AutoModerationCommand extends SkyraSubcommand {
172172

173173
const t = getSupportedUserLanguageT(interaction);
174174
const content = t(Root.EditSuccess);
175-
return interaction.reply({ content, ephemeral: true });
175+
return interaction.reply({ content, flags: MessageFlags.Ephemeral });
176176
}
177177

178178
protected async resetGetKeyValuePair(guild: Guild, key: ResetKey): Promise<readonly [SchemaDataKey, GuildDataValue]> {

src/lib/setup/paginated-message.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { LanguageKeys } from '#lib/i18n/languageKeys';
22
import { fetchT } from '#lib/i18n/translate';
33
import { userMention } from '@discordjs/builders';
44
import { PaginatedMessage } from '@sapphire/discord.js-utilities';
5+
import { MessageFlags } from 'discord.js';
56

67
PaginatedMessage.selectMenuOptions = async (pageIndex, internationalizationContext) => {
78
const t = await fetchT(internationalizationContext);
@@ -16,7 +17,7 @@ PaginatedMessage.wrongUserInteractionReply = async (targetUser, _, international
1617

1718
return {
1819
content: t(LanguageKeys.Globals.PaginatedMessageWrongUserInteractionReply, { user: userMention(targetUser.id) }),
19-
ephemeral: true,
20-
allowedMentions: { users: [], roles: [] }
20+
allowedMentions: { users: [], roles: [] },
21+
flags: MessageFlags.Ephemeral
2122
};
2223
};
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { getSupportedUserLanguageT } from '#lib/i18n/translate';
22
import { type ChatInputCommandErrorPayload } from '@sapphire/framework';
33
import type { ChatInputSubcommandErrorPayload } from '@sapphire/plugin-subcommands';
4+
import { MessageFlags } from 'discord.js';
45
import { flattenError, generateUnexpectedErrorMessage, resolveError } from './_shared.js';
56

67
export async function handleCommandError(error: unknown, payload: ChatInputCommandErrorPayload | ChatInputSubcommandErrorPayload) {
@@ -10,8 +11,8 @@ export async function handleCommandError(error: unknown, payload: ChatInputComma
1011
const content = resolved ? resolveError(t, resolved) : generateUnexpectedErrorMessage(interaction.user.id, payload.command, t, error);
1112

1213
try {
13-
if (interaction.replied) await interaction.followUp({ content, ephemeral: true });
14+
if (interaction.replied) await interaction.followUp({ content, flags: MessageFlags.Ephemeral });
1415
else if (interaction.deferred) await interaction.editReply({ content });
15-
else await interaction.reply({ content, ephemeral: true });
16+
else await interaction.reply({ content, flags: MessageFlags.Ephemeral });
1617
} catch {}
1718
}

0 commit comments

Comments
 (0)