summaryrefslogtreecommitdiff
path: root/src/discord
diff options
context:
space:
mode:
Diffstat (limited to 'src/discord')
-rw-r--r--src/discord/activity.hpp2
-rw-r--r--src/discord/ban.hpp2
-rw-r--r--src/discord/interactions.hpp8
-rw-r--r--src/discord/relationship.hpp16
-rw-r--r--src/discord/snowflake.cpp11
-rw-r--r--src/discord/snowflake.hpp2
-rw-r--r--src/discord/store.cpp10
-rw-r--r--src/discord/usersettings.hpp20
8 files changed, 35 insertions, 36 deletions
diff --git a/src/discord/activity.hpp b/src/discord/activity.hpp
index 6b8e944..4382ac0 100644
--- a/src/discord/activity.hpp
+++ b/src/discord/activity.hpp
@@ -26,7 +26,7 @@ constexpr inline const char *GetPresenceString(PresenceStatus s) {
return "";
}
-constexpr inline const char* GetPresenceDisplayString(PresenceStatus s) {
+constexpr inline const char *GetPresenceDisplayString(PresenceStatus s) {
switch (s) {
case PresenceStatus::Online:
return "Online";
diff --git a/src/discord/ban.hpp b/src/discord/ban.hpp
index d417ce3..7ab3d33 100644
--- a/src/discord/ban.hpp
+++ b/src/discord/ban.hpp
@@ -4,7 +4,7 @@
struct BanData {
std::string Reason; // null
- UserData User; // access id
+ UserData User; // access id
friend void from_json(const nlohmann::json &j, BanData &m);
};
diff --git a/src/discord/interactions.hpp b/src/discord/interactions.hpp
index c076145..782c491 100644
--- a/src/discord/interactions.hpp
+++ b/src/discord/interactions.hpp
@@ -14,10 +14,10 @@ enum class InteractionType {
};
struct MessageInteractionData {
- Snowflake ID; // id of the interaction
- InteractionType Type; // the type of interaction
- std::string Name; // the name of the ApplicationCommand
- UserData User; // the user who invoked the interaction
+ Snowflake ID; // id of the interaction
+ InteractionType Type; // the type of interaction
+ std::string Name; // the name of the ApplicationCommand
+ UserData User; // the user who invoked the interaction
// undocumented???
std::optional<GuildMember> Member; // the member who invoked the interaction (in a guild)
diff --git a/src/discord/relationship.hpp b/src/discord/relationship.hpp
index d492bd3..1595502 100644
--- a/src/discord/relationship.hpp
+++ b/src/discord/relationship.hpp
@@ -3,19 +3,19 @@
#include "user.hpp"
enum class RelationshipType {
- None = 0,
- Friend = 1,
- Blocked = 2,
- PendingIncoming = 3,
- PendingOutgoing = 4,
- Implicit = 5,
+ None = 0,
+ Friend = 1,
+ Blocked = 2,
+ PendingIncoming = 3,
+ PendingOutgoing = 4,
+ Implicit = 5,
};
struct RelationshipData {
// Snowflake UserID; this is the same as ID apparently but it looks new so i wont touch it
RelationshipType Type;
Snowflake ID;
- // Unknown Nickname; // null
+ // Unknown Nickname; // null
- friend void from_json(const nlohmann::json &j, RelationshipData &m);
+ friend void from_json(const nlohmann::json &j, RelationshipData &m);
};
diff --git a/src/discord/snowflake.cpp b/src/discord/snowflake.cpp
index 8f470a7..3624c01 100644
--- a/src/discord/snowflake.cpp
+++ b/src/discord/snowflake.cpp
@@ -2,6 +2,7 @@
#include "util.hpp"
#include <chrono>
#include <ctime>
+#include <glibmm.h>
#include <iomanip>
constexpr static uint64_t DiscordEpochSeconds = 1420070400;
@@ -53,14 +54,12 @@ bool Snowflake::IsValid() const {
return m_num != Invalid;
}
-std::string Snowflake::GetLocalTimestamp() const {
+Glib::ustring Snowflake::GetLocalTimestamp() const {
const time_t secs_since_epoch = (m_num / SecondsInterval) + DiscordEpochSeconds;
const std::tm tm = *localtime(&secs_since_epoch);
- std::stringstream ss;
- const static std::locale locale("");
- ss.imbue(locale);
- ss << std::put_time(&tm, "%X %x");
- return ss.str();
+ std::array<char, 256> tmp;
+ std::strftime(tmp.data(), sizeof(tmp), "%X %x", &tm);
+ return tmp.data();
}
void from_json(const nlohmann::json &j, Snowflake &s) {
diff --git a/src/discord/snowflake.hpp b/src/discord/snowflake.hpp
index f2da5d1..e83317a 100644
--- a/src/discord/snowflake.hpp
+++ b/src/discord/snowflake.hpp
@@ -13,7 +13,7 @@ struct Snowflake {
static Snowflake FromISO8601(std::string_view ts);
bool IsValid() const;
- std::string GetLocalTimestamp() const;
+ Glib::ustring GetLocalTimestamp() const;
bool operator==(const Snowflake &s) const noexcept {
return m_num == s.m_num;
diff --git a/src/discord/store.cpp b/src/discord/store.cpp
index 8eb3613..ede6364 100644
--- a/src/discord/store.cpp
+++ b/src/discord/store.cpp
@@ -818,8 +818,8 @@ std::optional<GuildMember> Store::GetGuildMember(Snowflake guild_id, Snowflake u
s->Get(2, r.Nickname);
s->Get(3, r.JoinedAt);
s->Get(4, r.PremiumSince);
- //s->Get(5, r.IsDeafened);
- //s->Get(6, r.IsMuted);
+ // s->Get(5, r.IsDeafened);
+ // s->Get(6, r.IsMuted);
s->Get(7, r.Avatar);
s->Get(8, r.IsPending);
@@ -879,8 +879,8 @@ Message Store::GetMessageBound(std::unique_ptr<Statement> &s) const {
s->Get(4, r.Content);
s->Get(5, r.Timestamp);
s->Get(6, r.EditedTimestamp);
- //s->Get(7, r.IsTTS);
- //s->Get(8, r.DoesMentionEveryone);
+ // s->Get(7, r.IsTTS);
+ // s->Get(8, r.DoesMentionEveryone);
s->GetJSON(9, r.Embeds);
s->Get(10, r.IsPinned);
s->Get(11, r.WebhookID);
@@ -1005,7 +1005,7 @@ RoleData Store::GetRoleBound(std::unique_ptr<Statement> &s) const {
RoleData r;
s->Get(0, r.ID);
- //s->Get(1, guild id);
+ // s->Get(1, guild id);
s->Get(2, r.Name);
s->Get(3, r.Color);
s->Get(4, r.IsHoisted);
diff --git a/src/discord/usersettings.hpp b/src/discord/usersettings.hpp
index 6d37b3c..2baf61e 100644
--- a/src/discord/usersettings.hpp
+++ b/src/discord/usersettings.hpp
@@ -6,7 +6,7 @@
struct UserSettingsGuildFoldersEntry {
int Color = -1; // null
std::vector<Snowflake> GuildIDs;
- Snowflake ID; // null (this can be a snowflake as a string or an int that isnt a snowflake lol)
+ Snowflake ID; // null (this can be a snowflake as a string or an int that isnt a snowflake lol)
std::string Name; // null
friend void from_json(const nlohmann::json &j, UserSettingsGuildFoldersEntry &m);
@@ -19,16 +19,16 @@ struct UserSettings {
std::string Status; //
bool ShouldShowCurrentGame; //
// std::vector<Unknown> RestrictedGuilds; //
- bool ShouldRenderReactions; //
- bool ShouldRenderEmbeds; //
- bool IsNativePhoneIntegrationEnabled; //
- bool ShouldMessageDisplayCompact; //
- std::string Locale; //
- bool ShouldInlineEmbedMedia; //
- bool ShouldInlineAttachmentMedia; //
- std::vector<Snowflake> GuildPositions; // deprecated?
+ bool ShouldRenderReactions; //
+ bool ShouldRenderEmbeds; //
+ bool IsNativePhoneIntegrationEnabled; //
+ bool ShouldMessageDisplayCompact; //
+ std::string Locale; //
+ bool ShouldInlineEmbedMedia; //
+ bool ShouldInlineAttachmentMedia; //
+ std::vector<Snowflake> GuildPositions; // deprecated?
std::vector<UserSettingsGuildFoldersEntry> GuildFolders; //
- bool ShouldGIFAutoplay; //
+ bool ShouldGIFAutoplay; //
// Unknown FriendSourceFlags; //
int ExplicitContentFilter; //
bool IsTTSCommandEnabled; //