add starter concord code
This commit is contained in:
parent
9b34c8c350
commit
8962f77af6
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
config.json
|
21
TEMPLATE-config.json
Normal file
21
TEMPLATE-config.json
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"logging": {
|
||||||
|
"level": "warn",
|
||||||
|
"filename": "bot.log",
|
||||||
|
"quiet": false,
|
||||||
|
"overwrite": true,
|
||||||
|
"use_color": true,
|
||||||
|
"http": {
|
||||||
|
"enable": false,
|
||||||
|
"filename": "http.log"
|
||||||
|
},
|
||||||
|
"disable_modules": ["WEBSOCKETS", "USER_AGENT"]
|
||||||
|
},
|
||||||
|
"discord": {
|
||||||
|
"token": "your token",
|
||||||
|
"default_prefix": {
|
||||||
|
"enable": false,
|
||||||
|
"prefix": "YOUR-COMMANDS-PREFIX"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
22
src/main.c
Normal file
22
src/main.c
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#include <string.h>
|
||||||
|
#include <concord/discord.h>
|
||||||
|
#include <concord/log.h>
|
||||||
|
|
||||||
|
void on_ready(struct discord *client, const struct discord_ready *event) {
|
||||||
|
log_info("Logged in as %s!", event->user->username);
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_message(struct discord *client, const struct discord_message *event) {
|
||||||
|
if (strcmp(event->content, "ping") == 0) {
|
||||||
|
struct discord_create_message params = { .content = "pong" };
|
||||||
|
discord_create_message(client, event->channel_id, ¶ms, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
struct discord *client = discord_config_init("config.json");
|
||||||
|
discord_add_intents(client, DISCORD_GATEWAY_MESSAGE_CONTENT);
|
||||||
|
discord_set_on_ready(client, &on_ready);
|
||||||
|
discord_set_on_message_create(client, &on_message);
|
||||||
|
discord_run(client);
|
||||||
|
}
|
Loading…
Reference in a new issue