diff options
author | turret <turret@duck.com> | 2025-09-29 00:12:45 -0500 |
---|---|---|
committer | turret <turret@duck.com> | 2025-09-29 00:12:45 -0500 |
commit | 4e360a4ed7cd77709588b659c704b43d6d474031 (patch) | |
tree | 934bbdaed91aa282c015b7ad891b184bdcfe3e2c /include/dbs/commands.h | |
parent | 535ff19dd942d9d53228200eea9096e7e59f76f8 (diff) | |
download | discord-bot-skeleton-4e360a4ed7cd77709588b659c704b43d6d474031.tar.gz discord-bot-skeleton-4e360a4ed7cd77709588b659c704b43d6d474031.tar.bz2 discord-bot-skeleton-4e360a4ed7cd77709588b659c704b43d6d474031.zip |
command: add command decl sys
additionally, edit ping to use new abstractions and command declaration
facilities. TODO: move interaction create event to somewhere else. this
spot isnt too good for it.
Diffstat (limited to 'include/dbs/commands.h')
-rw-r--r-- | include/dbs/commands.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/include/dbs/commands.h b/include/dbs/commands.h new file mode 100644 index 0000000..181a2c0 --- /dev/null +++ b/include/dbs/commands.h @@ -0,0 +1,60 @@ +#ifndef DBS_COMMANDS_H +#define DBS_COMMANDS_H + +enum CommandType { + COMMAND_CHAT_INPUT = 1, + COMMAND_USER = 2, + COMMAND_MESSAGE = 3, + COMMAND_PRIMARY_ENTRY_POINT = 4 +}; + +enum CommandOptionType { + OPTION_SUB_COMMAND = 1, + OPTION_SUB_COMMAND_GROUP = 2, + OPTION_STRING = 3, + OPTION_INTEGER = 4, + OPTION_BOOLEAN = 5, + OPTION_USER = 6, + OPTION_CHANNEL = 7, + OPTION_ROLE = 8, + OPTION_MENTIONABLE = 9, + OPTION_NUMBER = 10, + OPTION_ATTACHMENT = 11 +}; + +struct command_option { + enum CommandOptionType type; + char *name; + char *description; + int required; + char **choices; + int **choices_int; + struct command_option **options; + int channel_types; + int min_value; + int max_value; + int min_length; + int max_length; + int autocomplete; +}; +typedef struct command_option CommandOption; + +struct command { + enum CommandType type; + char *name; + char *description; + CommandOption *options; + void (*callback)(cJSON*); +}; +typedef struct command Command; + +extern Command *commands; + +#define declare_command(command) \ + void command_register_##command(void) { \ + command ## _command.callback = &command; \ + arrput(commands, command ## _command); \ + } \ + l3_initcall(command_register_##command) + +#endif |