From 729e9ac8ac0a0f7659a5a12e77d2aa9b291a1741 Mon Sep 17 00:00:00 2001 From: Xminent Date: Mon, 11 Dec 2023 12:53:21 -0600 Subject: [PATCH] refactor: :necktie: exit early if DISCORD_TOKEN is not provided --- src/main.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 502a628..4bed1b4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,7 +1,15 @@ +#include #include int main() { - auto saber = saber::Saber{std::getenv("DISCORD_TOKEN")}; + const auto* token = std::getenv("DISCORD_TOKEN"); + + if (token == nullptr) { + std::cerr << "Missing DISCORD_TOKEN environment variable\n"; + return 1; + } + + auto saber = saber::Saber{token}; saber.run(); }