-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✨ add commands; add ekizu debug logging
- Loading branch information
Xminent
committed
Dec 10, 2023
1 parent
589b122
commit 313c7ef
Showing
11 changed files
with
831 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include <saber/saber.hpp> | ||
#include <saber/util.hpp> | ||
|
||
using namespace saber; | ||
|
||
struct Beep : Command { | ||
explicit Beep(Saber *creator) | ||
: Command(creator, CommandOptions{ | ||
"beep", | ||
DIRNAME, | ||
true, | ||
{}, | ||
{}, | ||
{}, | ||
{}, | ||
{}, | ||
"beep", | ||
"Replies with boop.", | ||
{ ekizu::Permissions::SendMessages, | ||
ekizu::Permissions::EmbedLinks }, | ||
{}, | ||
{}, | ||
{}, | ||
3000, | ||
}) | ||
{ | ||
} | ||
|
||
void setup() override | ||
{ | ||
} | ||
|
||
void | ||
execute(const ekizu::Message &message, | ||
[[maybe_unused]] const std::vector<std::string> &args) override | ||
{ | ||
(void)bot->http.create_message(message.channel_id) | ||
.content("Boop!") | ||
.send(); | ||
} | ||
}; | ||
|
||
COMMAND_ALLOC(Beep) | ||
COMMAND_FREE(Beep) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include <saber/saber.hpp> | ||
#include <saber/util.hpp> | ||
|
||
using namespace saber; | ||
|
||
struct Countdown : Command { | ||
explicit Countdown(Saber *creator) | ||
: Command(creator, CommandOptions{ | ||
"countdown", | ||
DIRNAME, | ||
true, | ||
{}, | ||
{}, | ||
{}, | ||
{}, | ||
{}, | ||
"countdown", | ||
"Start counting down from 5.", | ||
{ ekizu::Permissions::SendMessages, | ||
ekizu::Permissions::EmbedLinks }, | ||
{}, | ||
{}, | ||
{}, | ||
0, | ||
}) | ||
{ | ||
} | ||
|
||
void setup() override | ||
{ | ||
} | ||
|
||
void execute(const ekizu::Message &message, | ||
const std::vector<std::string> &args) override | ||
{ | ||
if (!args.empty()) { | ||
return; | ||
} | ||
|
||
const std::vector<std::string> countdown{ "five", "four", | ||
"three", "two", | ||
"one" }; | ||
|
||
for (const std::string &num : countdown) { | ||
(void)bot->http.create_message(message.channel_id) | ||
.content("**:" + num + ":**") | ||
.send(); | ||
std::this_thread::sleep_for(std::chrono::seconds(1)); | ||
} | ||
|
||
(void)bot->http.create_message(message.channel_id) | ||
.content("**:ok:** DING DING DING") | ||
.send(); | ||
} | ||
}; | ||
|
||
COMMAND_ALLOC(Countdown) | ||
COMMAND_FREE(Countdown) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include <saber/saber.hpp> | ||
#include <saber/util.hpp> | ||
|
||
using namespace saber; | ||
|
||
struct CSS : Command { | ||
explicit CSS(Saber *creator) | ||
: Command(creator, CommandOptions{ | ||
"css", | ||
DIRNAME, | ||
true, | ||
{}, | ||
{}, | ||
{}, | ||
{}, | ||
{}, | ||
"css", | ||
"", | ||
{ ekizu::Permissions::SendMessages, | ||
ekizu::Permissions::EmbedLinks }, | ||
{}, | ||
{}, | ||
{}, | ||
0, | ||
}) | ||
{ | ||
} | ||
|
||
void setup() override | ||
{ | ||
} | ||
|
||
void execute(const ekizu::Message &message, | ||
const std::vector<std::string> &args) override | ||
{ | ||
if (!args.empty()) { | ||
return; | ||
} | ||
|
||
(void)bot->http.create_message(message.channel_id) | ||
.content( | ||
"https://media2.giphy.com/media/yYSSBtDgbbRzq/giphy.gif?cid=ecf05e47ckbtzm84p629vw655dbua1qzaiw8tl46ejp4f0xj&ep=v1_gifs_search&rid=giphy.gif&ct=g") | ||
.send(); | ||
} | ||
}; | ||
|
||
COMMAND_ALLOC(CSS) | ||
COMMAND_FREE(CSS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#include <saber/saber.hpp> | ||
#include <saber/util.hpp> | ||
|
||
using namespace saber; | ||
|
||
struct Hype : Command { | ||
explicit Hype(Saber *creator) | ||
: Command(creator, CommandOptions{ | ||
"hype", | ||
DIRNAME, | ||
true, | ||
{}, | ||
{}, | ||
{}, | ||
{}, | ||
{ "hypu", "train" }, | ||
"hype", | ||
"", | ||
{ ekizu::Permissions::SendMessages, | ||
ekizu::Permissions::EmbedLinks }, | ||
{}, | ||
{}, | ||
{}, | ||
0, | ||
}) | ||
{ | ||
} | ||
|
||
void setup() override | ||
{ | ||
} | ||
|
||
void execute(const ekizu::Message &message, | ||
const std::vector<std::string> &args) override | ||
{ | ||
if (!args.empty()) { | ||
return; | ||
} | ||
|
||
const std::string &selectedHype = | ||
hypu[util::get_random_number<size_t>(0, | ||
hypu.size() - 1)]; | ||
std::string msg = ":train2: CHOO CHOO " + selectedHype; | ||
|
||
(void)bot->http.create_message(message.channel_id) | ||
.content(msg) | ||
.send(); | ||
} | ||
|
||
private: | ||
std::vector<std::string> hypu{ | ||
"https://cdn.discordapp.com/attachments/102817255661772800/219514281136357376/tumblr_nr6ndeEpus1u21ng6o1_540.gif", | ||
"https://cdn.discordapp.com/attachments/102817255661772800/219518372839161859/tumblr_n1h2afSbCu1ttmhgqo1_500.gif", | ||
"https://gfycat.com/HairyFloweryBarebirdbat", | ||
"https://i.imgur.com/PFAQSLA.gif", | ||
"https://abload.de/img/ezgif-32008219442iq0i.gif", | ||
"https://i.imgur.com/vOVwq5o.jpg", | ||
"https://i.imgur.com/Ki12X4j.jpg", | ||
"https://media.giphy.com/media/b1o4elYH8Tqjm/giphy.gif" | ||
}; | ||
}; | ||
|
||
COMMAND_ALLOC(Hype) | ||
COMMAND_FREE(Hype) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#include <ekizu/embed_builder.hpp> | ||
#include <nlohmann/json.hpp> | ||
#include <saber/saber.hpp> | ||
#include <saber/util.hpp> | ||
|
||
using namespace saber; | ||
|
||
struct Meme : Command { | ||
explicit Meme(Saber *creator) | ||
: Command(creator, | ||
CommandOptions{ | ||
"meme", | ||
DIRNAME, | ||
true, | ||
{}, | ||
{}, | ||
{}, | ||
{}, | ||
{}, | ||
"meme", | ||
"Displays a random meme from the `memes`, `dankmemes`, or `me_irl` subreddits.", | ||
{ ekizu::Permissions::SendMessages, | ||
ekizu::Permissions::EmbedLinks }, | ||
{}, | ||
{}, | ||
{}, | ||
0, | ||
}) | ||
{ | ||
} | ||
|
||
void setup() override | ||
{ | ||
} | ||
|
||
void | ||
execute(const ekizu::Message &message, | ||
[[maybe_unused]] const std::vector<std::string> &args) override | ||
{ | ||
fetch_meme(message); | ||
} | ||
|
||
void fetch_meme(const ekizu::Message &message) | ||
{ | ||
auto res = net::http::get("https://meme-api.com/gimme"); | ||
|
||
if (!res) { | ||
return; | ||
} | ||
|
||
const auto json = | ||
nlohmann::json::parse(res->body, nullptr, false); | ||
|
||
if (json.is_discarded() || !json.is_object()) { | ||
return; | ||
} | ||
|
||
auto embed = | ||
ekizu::EmbedBuilder{} | ||
.set_title(json["title"]) | ||
.set_description(fmt::format( | ||
"By: **{}** | {}", | ||
json["author"].get<std::string>(), | ||
json["postLink"].get<std::string>())) | ||
.set_image({ | ||
json["url"].get<std::string>(), | ||
}) | ||
.build(); | ||
|
||
(void)bot->http.create_message(message.channel_id) | ||
.embeds({ std::move(embed) }) | ||
.send(); | ||
} | ||
}; | ||
|
||
COMMAND_ALLOC(Meme) | ||
COMMAND_FREE(Meme) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include <saber/saber.hpp> | ||
#include <saber/util.hpp> | ||
|
||
using namespace saber; | ||
|
||
struct Praise : Command { | ||
explicit Praise(Saber *creator) | ||
: Command(creator, CommandOptions{ | ||
"praise", | ||
DIRNAME, | ||
true, | ||
{}, | ||
{}, | ||
{}, | ||
{}, | ||
{}, | ||
"praise", | ||
"", | ||
{ ekizu::Permissions::SendMessages, | ||
ekizu::Permissions::EmbedLinks }, | ||
{}, | ||
{}, | ||
{}, | ||
0, | ||
}) | ||
{ | ||
} | ||
|
||
void setup() override | ||
{ | ||
} | ||
|
||
void execute(const ekizu::Message &message, | ||
const std::vector<std::string> &args) override | ||
{ | ||
if (!args.empty()) { | ||
return; | ||
} | ||
|
||
(void)bot->http.create_message(message.channel_id) | ||
.content("https://i.imgur.com/K8ySn3e.gif") | ||
.send(); | ||
} | ||
}; | ||
|
||
COMMAND_ALLOC(Praise) | ||
COMMAND_FREE(Praise) |
Oops, something went wrong.