|
Concord - C Discord API library
A Discord API wrapper library written in C
|
The Message Commands API for registering and parsing user commands. More...
Data Structures | |
| struct | discord_message_commands |
| The handle for storing user's message commands. More... | |
Functions | |
| CCORDcode | discord_message_commands_init (struct discord_message_commands *cmds) |
| Initialize a Message Commands handle. More... | |
| void | discord_message_commands_cleanup (struct discord_message_commands *cmds) |
| Free a Message Commands handle. More... | |
| discord_ev_message | discord_message_commands_find (struct discord_message_commands *cmds, const char command[], size_t length) |
| Search for a callback matching the command. More... | |
| void | discord_message_commands_append (struct discord_message_commands *cmds, const char command[], size_t length, discord_ev_message callback) |
| Add a new command/callback pair, or update an existing command. More... | |
| void | discord_message_commands_set_prefix (struct discord_message_commands *cmds, const char prefix[], size_t length) |
| Set a mandatory prefix before commands. More... | |
| bool | discord_message_commands_try_perform (struct discord_message_commands *cmds, struct discord_gateway_payload *payload) |
| Read the current DISCORD_EV_MESSAGE_CREATE payload and attempt to perform its matching callback. More... | |
The Message Commands API for registering and parsing user commands.
| CCORDcode discord_message_commands_init | ( | struct discord_message_commands * | cmds | ) |
| void discord_message_commands_cleanup | ( | struct discord_message_commands * | cmds | ) |
Free a Message Commands handle.
| cmds | the handle initialized with discord_message_commands_init() |
| discord_ev_message discord_message_commands_find | ( | struct discord_message_commands * | cmds, |
| const char | command[], | ||
| size_t | length | ||
| ) |
Search for a callback matching the command.
| cmds | the handle initialized with discord_message_commands_init() |
| command | the command to be searched for |
| length | the command length |
NULL in case there wasn't a match | void discord_message_commands_append | ( | struct discord_message_commands * | cmds, |
| const char | command[], | ||
| size_t | length, | ||
| discord_ev_message | callback | ||
| ) |
Add a new command/callback pair, or update an existing command.
| cmds | the handle initialized with discord_message_commands_init() |
| command | the message command to be matched with callback |
| length | the command length |
| callback | the callback to be triggered when the command is sent |
| void discord_message_commands_set_prefix | ( | struct discord_message_commands * | cmds, |
| const char | prefix[], | ||
| size_t | length | ||
| ) |
Set a mandatory prefix before commands.
Example: If 'help' is a command and '!' prefix is set, the command will only be validated if '!help' is sent
| cmds | the handle initialized with discord_message_commands_init() |
| prefix | the mandatory command prefix |
| length | the prefix length |
| bool discord_message_commands_try_perform | ( | struct discord_message_commands * | cmds, |
| struct discord_gateway_payload * | payload | ||
| ) |
Read the current DISCORD_EV_MESSAGE_CREATE payload and attempt to perform its matching callback.
| cmds | the handle initialized with discord_message_commands_init() |
| payload | the event payload to read from (assumes its from MESSAGE_CREATE) |
true if the callback has been performed