mirror of
https://github.com/Syping/dtranslatebot.git
synced 2024-11-21 13:20:23 +01:00
add DTRANSLATEBOT_TOKEN env value, small fixes
This commit is contained in:
parent
531c24b050
commit
5191dcbefc
4 changed files with 14 additions and 13 deletions
|
@ -1,4 +1,4 @@
|
|||
find_path(DPP_INCLUDE_DIR NAMES dpp/dpp.h HINTS ${DPP_ROOT_DIR})
|
||||
find_library(DPP_LIBRARIES NAMES dpp "libdpp.a" HINTS ${DPP_ROOT_DIR})
|
||||
find_path(DPP_INCLUDE_DIR NAMES "dpp/dpp.h" HINTS "${DPP_ROOT_DIR}")
|
||||
find_library(DPP_LIBRARIES NAMES "dpp" "libdpp.a" HINTS "${DPP_ROOT_DIR}")
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(DPP DEFAULT_MSG DPP_LIBRARIES DPP_INCLUDE_DIR)
|
||||
|
|
|
@ -39,7 +39,7 @@ int main(int argc, char* argv[]) {
|
|||
std::cout << "[Launch] Requesting supported languages..." << std::endl;
|
||||
if (settings.get_translator()->get_languages().empty()) {
|
||||
std::cerr << "[Error] Failed to initialise translateable languages" << std::endl;
|
||||
return 2;
|
||||
return 1;
|
||||
}
|
||||
|
||||
dpp::cluster bot(settings.token(), dpp::i_default_intents | dpp::i_message_content);
|
||||
|
|
|
@ -455,15 +455,18 @@ bool settings::parse(const std::string &data, bool initialize)
|
|||
return false;
|
||||
}
|
||||
|
||||
const std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
||||
auto json_token = json.find("token");
|
||||
if (json_token == json.end()) {
|
||||
std::cerr << "[Error] Value token not found" << std::endl;
|
||||
if (json_token != json.end())
|
||||
m_token = *json_token;
|
||||
else if (char *token = getenv("DTRANSLATEBOT_TOKEN"))
|
||||
m_token = token;
|
||||
|
||||
if (m_token.empty()) {
|
||||
std::cerr << "[Error] Discord Bot Token is not configured" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
||||
m_token = *json_token;
|
||||
|
||||
std::filesystem::path storage_path;
|
||||
auto json_storage = json.find("storage");
|
||||
if (json_storage != json.end())
|
||||
|
@ -484,8 +487,6 @@ bool settings::parse(const std::string &data, bool initialize)
|
|||
if (!process_translator_settings(*json_translator, &m_translator))
|
||||
return false;
|
||||
|
||||
m_avatarSize = 256;
|
||||
|
||||
auto json_guilds = json.find("guilds");
|
||||
if (json_guilds != json.end() && json_guilds->is_object())
|
||||
process_guild_settings(*json_guilds, &m_guilds, &m_webhookIds);
|
||||
|
|
|
@ -61,8 +61,8 @@ namespace bot {
|
|||
|
||||
private:
|
||||
mutable std::recursive_mutex m_mutex;
|
||||
size_t m_externallyLockedCount;
|
||||
uint16_t m_avatarSize;
|
||||
size_t m_externallyLockedCount = 0;
|
||||
uint16_t m_avatarSize = 256;
|
||||
std::shared_ptr<bot::database::database> m_database;
|
||||
std::vector<guild> m_guilds;
|
||||
std::vector<std::string> m_prefLangs;
|
||||
|
|
Loading…
Reference in a new issue