mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-19 20:11:59 +03:00
rename and reorder a bunch of discord stuff
This commit is contained in:
31
discord/snowflake.cpp
Normal file
31
discord/snowflake.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "snowflake.hpp"
|
||||
|
||||
Snowflake::Snowflake()
|
||||
: m_num(Invalid) {}
|
||||
|
||||
Snowflake::Snowflake(const Snowflake &s)
|
||||
: m_num(s.m_num) {}
|
||||
|
||||
Snowflake::Snowflake(uint64_t n)
|
||||
: m_num(n) {}
|
||||
|
||||
Snowflake::Snowflake(const std::string &str) {
|
||||
if (str.size())
|
||||
m_num = std::stoull(str);
|
||||
else
|
||||
m_num = Invalid;
|
||||
};
|
||||
|
||||
bool Snowflake::IsValid() const {
|
||||
return m_num != Invalid;
|
||||
}
|
||||
|
||||
void from_json(const nlohmann::json &j, Snowflake &s) {
|
||||
std::string tmp;
|
||||
j.get_to(tmp);
|
||||
s.m_num = std::stoull(tmp);
|
||||
}
|
||||
|
||||
void to_json(nlohmann::json &j, const Snowflake &s) {
|
||||
j = std::to_string(s);
|
||||
}
|
||||
Reference in New Issue
Block a user