Orca is implemented in plain C, its symbols are organized to be easily matched to the documentation of the API being covered.
This is done in order to:
- Reduce the need of thoroughly documenting every Orca API
- Reduce our user's cognitive burden of having to read both Orca API documentation and supported REST API documentations.
- The codebase becomes easier to navigate.
Orca's implementation has minimum external dependencies to make bot deployment deadly simple.
-
Easy to use for the end users: we provide internal synchronization so that the user may provide scalability to his applications without having to excessively worry about race-conditions. All transfers made with Orca are thread-safe by nature.
-
Easy to reason about the code: we use the most native data structures, the simplest algorithms, and intuitive interfaces.
-
Easy to debug (networking and logic) errors: extensive assertion and logging facilities.
-
Superior reliability.
The only dependencies are curl-7.64.0 or higher built with openssl
sudo apt-get install -y build-essential
sudo apt-get install -y libcurl4-openssl-dev libssl-dev
make
sudo make install
gcc your-bot.c -o your-bot.exe -ldiscord -lcurl -lcrypto -lpthread -lm
- If you do not have Ubuntu or Debian but have Windows 10, you can install WSL2 and get either Ubuntu or Debian here.
- If you have Windows but don't want to use WSL2, you can find a tutorial here
#include <string.h> // strcmp()
#include <orca/discord.h>
void on_ready(struct discord *client, const struct discord_user *bot) {
log_info("Logged in as %s!", bot->username);
}
void on_message(struct discord *client, const struct discord_user *bot, const struct discord_message *msg) {
if (0 == strcmp(msg->content, "ping")) {
struct discord_create_message_params params = { .content = "pong" };
discord_create_message(client, msg->channel_id, ¶ms, NULL);
}
}
int main() {
struct discord *client = discord_init(BOT_TOKEN);
discord_set_on_ready(client, &on_ready);
discord_set_on_message_create(client, &on_message);
discord_run(client);
}
This is a minimalistic example, refer to bots/
for a better overview.
- Get your bot token and paste it in
bot.config
, replacingYOUR-BOT-TOKEN
with it. There are well written instructions from the discord-irc about how to get your bot token and it to a server. - Invite your bot to a testing server. We can invite your bot to our testing servers at our Discord Server.
- Run
make bots
- Go to
bots/
folder and run./bot-echo.exe
Type a message in any channel the bot is part of.
Close the Terminal or type Ctrl-C
to kill the process.
-
The recommended method: Using SaiphC to build your bot, and run the executable. All runtime memory errors will be reported. The instruction to use SaiphC to build bots.
-
Using valgrind, which is more convenient but cannot report all runtime memory errors.
valgrind ./your-bot.exe
Check our Discord API's development Roadmap and Coding Guidelines to get started
If you are not familiar with git and are not comfortable with creating pull requests without introducing merge commits, please check our Commit Guidelines.
Please give a star if you like this project!