Skip to content

Commit 828ca2e

Browse files
committed
update ephemeral responses to use MessageFlags.Ephemeral
1 parent 4be77c2 commit 828ca2e

File tree

7 files changed

+27
-17
lines changed

7 files changed

+27
-17
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2024 Avraj Sahota
1+
Copyright 2025 Avraj Sahota
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so.
44

apps/docs/content/guide/validation-file-setup.mdx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ Validation functions are called on every command trigger, so it's important to k
1919
<Tab value="CommonJS">
2020
```js title="validations/cooldowns.js"
2121
const cooldowns = require('../cooldowns-cache');
22+
const { MessageFlags } = require('discord.js');
2223

2324
module.exports = ({ interaction, commandObj, handler }) => {
2425
if (cooldowns.has(`${interaction.user.id}-${commandObj.data.name}`)) {
2526
interaction.reply({
2627
content: "You're on cooldown, please wait some time before running this command again.",
27-
ephemeral: true,
28+
flags: MessageFlags.Ephemeral
2829
});
2930

3031
return true; // This is important
@@ -36,12 +37,13 @@ Validation functions are called on every command trigger, so it's important to k
3637
<Tab value="ESM">
3738
```js title="validations/cooldowns.js"
3839
import cooldowns from '../cooldowns-cache';
40+
import { MessageFlags } from 'discord.js';
3941

4042
export default function ({ interaction, commandObj, handler }) {
4143
if (cooldowns.has(`${interaction.user.id}-${commandObj.data.name}`)) {
4244
interaction.reply({
4345
content: "You're on cooldown, please wait some time before running this command again.",
44-
ephemeral: true,
46+
flags: MessageFlags.Ephemeral
4547
});
4648

4749
return true; // This is important
@@ -54,12 +56,13 @@ Validation functions are called on every command trigger, so it's important to k
5456
```ts title="validations/cooldowns.ts"
5557
import type { ValidationProps } from 'commandkit';
5658
import cooldowns from '../cooldowns-cache';
59+
import { MessageFlags } from 'discord.js';
5760

5861
export default function ({ interaction, commandObj, handler }: ValidationProps) {
5962
if (cooldowns.has(`${interaction.user.id}-${commandObj.data.name}`)) {
6063
interaction.reply({
6164
content: "You're on cooldown, please wait some time before running this command again.",
62-
ephemeral: true,
65+
flags: MessageFlags.Ephemeral,
6366
});
6467

6568
return true; // This is important

apps/website/docs/guide/06-validation-file-setup.mdx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ commands.
2222
<TabItem value='cjs' label='CommonJS' default>
2323
```js title="src/validations/cooldowns.js"
2424
const cooldowns = require('../cooldowns-cache');
25+
const { MessageFlags } = require('discord.js');
2526

2627
module.exports = ({ interaction, commandObj, handler }) => {
2728
if (cooldowns.has(`${interaction.user.id}-${commandObj.data.name}`)) {
2829
interaction.reply({
2930
content: "You're on cooldown, please wait some time before running this command again.",
30-
ephemeral: true,
31+
flags: MessageFlags.Ephemeral,
3132
});
3233

3334
return true; // This is important
@@ -39,12 +40,13 @@ commands.
3940
<TabItem value='esm' label='ESM'>
4041
```js title="src/validations/cooldowns.js"
4142
import cooldowns from '../cooldowns-cache';
43+
import { MessageFlags } from 'discord.js';
4244

4345
export default function ({ interaction, commandObj, handler }) {
4446
if (cooldowns.has(`${interaction.user.id}-${commandObj.data.name}`)) {
4547
interaction.reply({
4648
content: "You're on cooldown, please wait some time before running this command again.",
47-
ephemeral: true,
49+
flags: MessageFlags.Ephemeral,
4850
});
4951

5052
return true; // This is important
@@ -57,12 +59,13 @@ commands.
5759
```ts title="src/validations/cooldowns.ts"
5860
import type { ValidationProps } from 'commandkit';
5961
import cooldowns from '../cooldowns-cache';
62+
import { MessageFlags } from 'discord.js';
6063

6164
export default function ({ interaction, commandObj, handler }: ValidationProps) {
6265
if (cooldowns.has(`${interaction.user.id}-${commandObj.data.name}`)) {
6366
interaction.reply({
6467
content: "You're on cooldown, please wait some time before running this command again.",
65-
ephemeral: true,
68+
flags: MessageFlags.Ephemeral,
6669
});
6770

6871
return true; // This is important

apps/website/versioned_docs/version-0.1.10/guide/06-validation-file-setup.mdx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ commands.
2222
<TabItem value='cjs' label='CommonJS' default>
2323
```js title="src/validations/cooldowns.js"
2424
const cooldowns = require('../cooldowns-cache');
25+
const { MessageFlags } = require('discord.js');
2526

2627
module.exports = ({ interaction, commandObj, handler }) => {
2728
if (cooldowns.has(`${interaction.user.id}-${commandObj.data.name}`)) {
2829
interaction.reply({
2930
content: "You're on cooldown, please wait some time before running this command again.",
30-
ephemeral: true,
31+
flags: MessageFlags.Ephemeral,
3132
});
3233

3334
return true; // This is important
@@ -39,12 +40,13 @@ commands.
3940
<TabItem value='esm' label='ESM'>
4041
```js title="src/validations/cooldowns.js"
4142
import cooldowns from '../cooldowns-cache';
43+
import { MessageFlags } from 'discord.js';
4244

4345
export default function ({ interaction, commandObj, handler }) {
4446
if (cooldowns.has(`${interaction.user.id}-${commandObj.data.name}`)) {
4547
interaction.reply({
4648
content: "You're on cooldown, please wait some time before running this command again.",
47-
ephemeral: true,
49+
flags: MessageFlags.Ephemeral,
4850
});
4951

5052
return true; // This is important
@@ -57,12 +59,13 @@ commands.
5759
```ts title="src/validations/cooldowns.ts"
5860
import type { ValidationProps } from 'commandkit';
5961
import cooldowns from '../cooldowns-cache';
62+
import { MessageFlags } from 'discord.js';
6063

6164
export default function ({ interaction, commandObj, handler }: ValidationProps) {
6265
if (cooldowns.has(`${interaction.user.id}-${commandObj.data.name}`)) {
6366
interaction.reply({
6467
content: "You're on cooldown, please wait some time before running this command again.",
65-
ephemeral: true,
68+
flags: MessageFlags.Ephemeral,
6669
});
6770

6871
return true; // This is important

packages/commandkit/src/context/async-context.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { AsyncLocalStorage } from 'node:async_hooks';
22
import { CommandKitEnvironment } from './environment';
33
import { CommandKitErrorCodes, isCommandKitError } from '../utils/error-codes';
4-
import { Interaction } from 'discord.js';
4+
import { Interaction, MessageFlags } from 'discord.js';
55
import { CommandKit } from '../CommandKit';
66

77
const context = new AsyncLocalStorage<CommandKitEnvironment>();
@@ -42,7 +42,7 @@ export function makeContextAwareFunction<
4242
if (interaction.isRepliable()) {
4343
await interaction.reply({
4444
content: 'This command is only available in guilds.',
45-
ephemeral: true,
45+
flags: MessageFlags.Ephemeral,
4646
});
4747
}
4848
return;
@@ -51,7 +51,7 @@ export function makeContextAwareFunction<
5151
if (interaction.isRepliable()) {
5252
await interaction.reply({
5353
content: 'This command is only available in DMs.',
54-
ephemeral: true,
54+
flags: MessageFlags.Ephemeral,
5555
});
5656
}
5757
return;

packages/commandkit/src/handlers/command-handler/validations/devOnly.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { BuiltInValidationParams } from '../typings';
2+
import { MessageFlags } from 'discord.js';
23

34
export default function ({
45
interaction,
@@ -14,7 +15,7 @@ export default function ({
1415
) {
1516
interaction.reply({
1617
content: '❌ This command can only be used inside development servers.',
17-
ephemeral: true,
18+
flags: MessageFlags.Ephemeral,
1819
});
1920

2021
return true;
@@ -39,7 +40,7 @@ export default function ({
3940
if (!isDevUser) {
4041
interaction.reply({
4142
content: '❌ This command can only be used by developers.',
42-
ephemeral: true,
43+
flags: MessageFlags.Ephemeral,
4344
});
4445

4546
return true;

packages/commandkit/src/handlers/command-handler/validations/permissions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { BuiltInValidationParams } from '../typings';
2-
import { EmbedBuilder } from 'discord.js';
2+
import { EmbedBuilder, MessageFlags } from 'discord.js';
33

44
export default function ({
55
interaction,
@@ -93,6 +93,6 @@ export default function ({
9393
.setDescription(embedDescription)
9494
.setColor('Red');
9595

96-
interaction.reply({ embeds: [embed], ephemeral: true });
96+
interaction.reply({ embeds: [embed], flags: MessageFlags.Ephemeral });
9797
return true;
9898
}

0 commit comments

Comments
 (0)