Skip to content

Commit 8fc01cb

Browse files
committed
patch fix type missing from command options
1 parent 72d829b commit 8fc01cb

File tree

4 files changed

+56
-1
lines changed

4 files changed

+56
-1
lines changed

packages/commandkit/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "commandkit",
33
"description": "Beginner friendly command & event handler for Discord.js",
4-
"version": "0.1.4",
4+
"version": "0.1.5",
55
"license": "MIT",
66
"main": "./dist/index.js",
77
"module": "./dist/index.mjs",

packages/commandkit/src/handlers/command-handler/CommandHandler.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import registerCommands from './functions/registerCommands';
99
import builtInValidations from './validations';
1010
import colors from '../../utils/colors';
1111
import rdfc from 'rfdc';
12+
import { SlashCommandBuilder } from 'discord.js';
1213

1314
const clone = rdfc();
1415

@@ -80,6 +81,17 @@ export class CommandHandler {
8081
let importedObj = await import(`${modulePath}?t=${Date.now()}`);
8182
let commandObj: CommandFileObject = clone(importedObj); // Make commandObj extensible
8283

84+
// Ensure builder properties
85+
if (importedObj.default) {
86+
commandObj.data = importedObj.default.data;
87+
} else {
88+
commandObj.data = importedObj.data;
89+
}
90+
91+
try {
92+
commandObj.data = (commandObj.data as any).toJSON();
93+
} catch (error) {}
94+
8395
// If it's CommonJS, invalidate the import cache
8496
if (typeof module !== 'undefined' && typeof require !== 'undefined') {
8597
delete require.cache[require.resolve(commandFilePath)];

packages/commandkit/src/handlers/command-handler/functions/loadCommandsWithRest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ async function handleLoading(
3636
reloading?: boolean,
3737
type?: ReloadOptions,
3838
) {
39+
commands = commands.filter((cmd) => !cmd.options?.deleted);
3940
const devOnlyCommands = commands.filter((cmd) => cmd.options?.devOnly);
4041
const globalCommands = commands.filter((cmd) => !cmd.options?.devOnly);
4142

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { ChannelType, SlashCommandBuilder } from 'discord.js';
2+
3+
export const data = new SlashCommandBuilder()
4+
.setName('giveaway')
5+
.setDescription('Giveaway related commands')
6+
.addSubcommand((cmd) =>
7+
cmd
8+
.setName('create')
9+
.setDescription('Create a giveaway with a modal')
10+
.addChannelOption((option) =>
11+
option
12+
.setName('channel')
13+
.setDescription('The channel you would like to send the giveaway to')
14+
.addChannelTypes(ChannelType.GuildText),
15+
)
16+
.addRoleOption((option) =>
17+
option
18+
.setName('ping-role')
19+
.setDescription('The role you would like to ping for this giveaway'),
20+
),
21+
)
22+
.addSubcommand((cmd) =>
23+
cmd
24+
.setName('end')
25+
.setDescription('End a giveaway early')
26+
.addStringOption((option) =>
27+
option
28+
.setName('giveaway-id')
29+
.setDescription('The Message ID for the giveaway')
30+
.setRequired(true),
31+
),
32+
)
33+
.addSubcommand((cmd) =>
34+
cmd.setName('list').setDescription('List all active giveaways for this server'),
35+
);
36+
37+
export function run() {}
38+
39+
export const options = {
40+
devOnly: true,
41+
// deleted: true,
42+
};

0 commit comments

Comments
 (0)