File tree Expand file tree Collapse file tree 4 files changed +56
-1
lines changed
src/handlers/command-handler Expand file tree Collapse file tree 4 files changed +56
-1
lines changed Original file line number Diff line number Diff line change 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" ,
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import registerCommands from './functions/registerCommands';
99import builtInValidations from './validations' ;
1010import colors from '../../utils/colors' ;
1111import rdfc from 'rfdc' ;
12+ import { SlashCommandBuilder } from 'discord.js' ;
1213
1314const 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 ) ] ;
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 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+ } ;
You can’t perform that action at this time.
0 commit comments