Skip to content

Commit 7096dec

Browse files
committed
fix: only set fallback description when missing in chat input commands
1 parent a912a1e commit 7096dec

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { MessageContextMenuCommand } from 'commandkit';
2+
import { ApplicationCommandType, ContextMenuCommandBuilder } from 'discord.js';
3+
4+
export const command = new ContextMenuCommandBuilder()
5+
.setName('translate')
6+
.setType(ApplicationCommandType.Message);
7+
8+
export const messageContextMenu: MessageContextMenuCommand = async ({
9+
interaction,
10+
}) => {
11+
interaction.reply('test');
12+
};

packages/commandkit/src/app/handlers/AppCommandHandler.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -832,8 +832,14 @@ export class AppCommandHandler {
832832

833833
// Apply the specified logic for name and description
834834
const commandName = commandFileData.command.name || command.name;
835-
const commandDescription =
836-
commandFileData.command.description || `${commandName} command`;
835+
let commandDescription = commandFileData.command.description as
836+
| string
837+
| undefined;
838+
839+
// since `description` is optional in `CommandData` type, set a fallback description if none is provided
840+
if (!commandDescription && commandFileData.chatInput) {
841+
commandDescription = 'No command description set.';
842+
}
837843

838844
// Update the command data with resolved name and description
839845
const updatedCommandData = {

packages/commandkit/src/types.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,6 @@ export interface CommandMetadata {
7070
nameAliases?: Record<'user' | 'message', string>;
7171
}
7272

73-
/**
74-
* @deprecated Use `CommandMetadata` instead.
75-
*/
76-
export interface LegacyCommandMetadata {
77-
/**
78-
* The aliases of the command.
79-
* @deprecated Use `metadata.aliases` or `generateMetadata` instead.
80-
*/
81-
aliases?: string[];
82-
/**
83-
* The guilds that the command is available in.
84-
* @deprecated Use `metadata.guilds` or `generateMetadata` instead.
85-
*/
86-
guilds?: string[];
87-
}
88-
8973
/**
9074
* Represents a command that can be executed by CommandKit.
9175
*/
@@ -95,7 +79,7 @@ export type CommandData = Prettify<
9579
* The description of the command.
9680
*/
9781
description?: string;
98-
} & LegacyCommandMetadata
82+
}
9983
>;
10084

10185
/**

0 commit comments

Comments
 (0)