/[sudobot]/trunk/lib/common/core/command.h
ViewVC logotype

Annotation of /trunk/lib/common/core/command.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 575 - (hide annotations)
Mon Jul 29 17:59:26 2024 UTC (8 months ago) by rakinar2
File MIME type: text/x-c
File size: 1560 byte(s)
chore: add trunk
1 rakinar2 575 #ifndef SUDOBOT_CORE_COMMAND_H
2     #define SUDOBOT_CORE_COMMAND_H
3    
4     #include <stdlib.h>
5     #include <stdbool.h>
6     #include <concord/discord.h>
7    
8     #define CMD_MODE_INTERACTION (CMD_MODE_CHAT_INPUT_COMMAND_INTERACTION | CMD_MODE_CONTEXT_MENU_INTERACTION)
9     #define CMD_MODE_ALL (CMD_MODE_INTERACTION | CMD_MODE_LEGACY)
10     #define CMD_MODE_BASIC (CMD_MODE_CHAT_INPUT_COMMAND_INTERACTION | CMD_MODE_LEGACY)
11    
12     typedef enum sudobot_command_context_type
13     {
14     CMDCTX_LEGACY,
15     CMDCTX_CHAT_INPUT_COMMAND_INTERACTION
16     } cmdctx_type_t;
17    
18     typedef struct sudobot_command_context
19     {
20     cmdctx_type_t type;
21    
22     union
23     {
24     const struct discord_message *message;
25     const struct discord_interaction *interaction;
26     };
27    
28     bool is_legacy;
29     bool is_interaction;
30     bool is_chat_input_command_interaction;
31     const char *command_name;
32     size_t argc;
33     const char **argv;
34     } cmdctx_t;
35    
36     typedef void (*cmd_callback_t)(struct discord *, cmdctx_t);
37    
38     enum command_mode
39     {
40     CMD_MODE_LEGACY = 1,
41     CMD_MODE_CHAT_INPUT_COMMAND_INTERACTION = 2,
42     CMD_MODE_CONTEXT_MENU_INTERACTION = 4,
43     };
44    
45     struct command_info
46     {
47     const char *name;
48     cmd_callback_t callback;
49     int mode;
50     const char *description;
51     enum discord_application_command_types type;
52     };
53    
54     void command_on_message_handler(struct discord *client, const struct discord_message *message);
55     void register_slash_commands(struct discord *client, u64snowflake guild);
56     void command_on_interaction_handler(struct discord *client, const struct discord_interaction *interaction);
57    
58     #endif /* SUDOBOT_CORE_COMMAND_H */

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26