Skip to content

Commit

Permalink
feat: ✨ add OWNER_ID environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Xminent committed Dec 11, 2023
1 parent 7fd4e99 commit 5c12389
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions include/saber/saber.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace saber {
struct Saber {
explicit Saber(std::string_view token);
explicit Saber(std::string_view token, ekizu::Snowflake owner_id);

void run();
void handle_event(ekizu::Event ev);
Expand All @@ -20,7 +20,7 @@ struct Saber {
ekizu::HttpClient http;
std::shared_ptr<spdlog::logger> logger;
ekizu::LruCache<ekizu::Snowflake, ekizu::Message> messages_cache{500};
ekizu::Snowflake owner_id{155780111197536256};
ekizu::Snowflake owner_id;
std::string prefix{">"};
ekizu::Shard shard;
ekizu::CurrentUser user;
Expand Down
8 changes: 7 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <iostream>
#include <saber/saber.hpp>

static constexpr uint64_t DEFAULT_OWNER_ID{155780111197536256};

int main() {
const auto* token = std::getenv("DISCORD_TOKEN");

Expand All @@ -9,7 +11,11 @@ int main() {
return 1;
}

auto saber = saber::Saber{token};
const auto* owner_id_str = std::getenv("OWNER_ID");
ekizu::Snowflake owner_id{
owner_id_str != nullptr ? std::stoull(owner_id_str) : DEFAULT_OWNER_ID};

auto saber = saber::Saber{token, owner_id};

saber.run();
}
3 changes: 2 additions & 1 deletion src/saber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ overload(Func...) -> overload<Func...>;
} // namespace

namespace saber {
Saber::Saber(std::string_view token)
Saber::Saber(std::string_view token, ekizu::Snowflake owner_id_)
: commands{this},
http{token},
owner_id{owner_id_},
shard{ekizu::ShardId::ONE, token, ekizu::Intents::AllIntents} {
logger = spdlog::stdout_color_mt("saber");
spdlog::set_pattern("[%Y-%m-%d %H:%M:%S.%e] [%^%l%$] %v");
Expand Down

0 comments on commit 5c12389

Please sign in to comment.