-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.cpp
204 lines (166 loc) · 4.8 KB
/
Main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#include "Blitzcord.h"
discord::Core* core{};
discord::Activity activity{};
//CORE FUNCTIONS
//--------------
BLITZ3D(int) BlitzcordCreateCore(cstring id)
{
long long convertedLong = atoll(id);
discord::Result result = discord::Core::Create(convertedLong, DiscordCreateFlags_NoRequireDiscord, &core);
return (int)result;
}
BLITZ3D(void) BlitzcordRunCallbacks()
{
if (core == nullptr) return;
::core->RunCallbacks();
}
//ACTIVITY FUNCTIONS
//------------------
BLITZ3D(void) BlitzcordSetActivityState(cstring state)
{
if (core == nullptr) return;
activity.SetState(state);
}
BLITZ3D(void) BlitzcordSetActivityDetails(cstring details)
{
if (core == nullptr) return;
activity.SetDetails(details);
}
BLITZ3D(void) BlitzcordSetActivityType(int type)
{
if (core == nullptr) return;
activity.SetType((discord::ActivityType)type);
}
BLITZ3D(void) BlitzcordClearActivity()
{
if (core == nullptr) return;
core->ActivityManager().ClearActivity([](discord::Result result) {});
}
BLITZ3D(void) BlitzcordUpdateActivity()
{
if (core == nullptr) return;
core->ActivityManager().UpdateActivity(activity, [](discord::Result result) {});
}
//SMALL IMAGE FUNCTIONS
//---------------------
BLITZ3D(void) BlitzcordSetSmallImage(cstring image)
{
if (core == nullptr) return;
activity.GetAssets().SetSmallImage(image);
}
BLITZ3D(void) BlitzcordSetSmallText(cstring text)
{
if (core == nullptr) return;
activity.GetAssets().SetSmallText(text);
}
BLITZ3D(cstring) BlitzcordGetSmallImage()
{
if (core == nullptr) return "";
return activity.GetAssets().GetSmallImage();
}
BLITZ3D(cstring) BlitzcordGetSmallText()
{
if (core == nullptr) return "";
return activity.GetAssets().GetSmallText();
}
//LARGE IMAGE FUNCTIONS
//---------------------
BLITZ3D(void) BlitzcordSetLargeImage(cstring image)
{
if (core == nullptr) return;
activity.GetAssets().SetLargeImage(image);
}
BLITZ3D(void) BlitzcordSetLargeText(cstring text)
{
if (core == nullptr) return;
activity.GetAssets().SetLargeText(text);
}
BLITZ3D(cstring) BlitzcordGetLargeImage()
{
if (core == nullptr) return "";
return activity.GetAssets().GetLargeImage();
}
BLITZ3D(cstring) BlitzcordGetLargeText()
{
if (core == nullptr) return "";
return activity.GetAssets().GetLargeText();
}
//TIMESTAMP FUNCTIONS
//-------------------
BLITZ3D(void) BlitzcordSetTimestampStart(cstring timestamp)
{
if (core == nullptr) return;
long long convertedLong = atoll(timestamp);
activity.GetTimestamps().SetStart(convertedLong);
}
BLITZ3D(void) BlitzcordSetTimestampEnd(cstring timestamp)
{
if (core == nullptr) return;
long long convertedLong = atoll(timestamp);
activity.GetTimestamps().SetEnd(convertedLong);
}
BLITZ3D(int) BlitzcordGetTimestampStartUpper()
{
if (core == nullptr) return INT_MAX;
return longUpper(activity.GetTimestamps().GetStart());
}
BLITZ3D(int) BlitzcordGetTimestampStartLower()
{
if (core == nullptr) return INT_MAX;
return longLower(activity.GetTimestamps().GetStart());
}
BLITZ3D(int) BlitzcordGetTimestampEndUpper()
{
if (core == nullptr) return INT_MAX;
return longUpper(activity.GetTimestamps().GetEnd());
}
BLITZ3D(int) BlitzcordGetTimestampEndLower()
{
if (core == nullptr) return INT_MAX;
return longLower(activity.GetTimestamps().GetEnd());
}
//UNIX TIMESTAMP FUNCTIONS
//------------------------
BLITZ3D(cstring) BlitzcordGetCurrentTimestamp()
{
auto clockNow = std::chrono::system_clock::now();
return _strdup(std::to_string(std::chrono::duration_cast<std::chrono::seconds>(clockNow.time_since_epoch()).count()).c_str());
}
BLITZ3D(cstring) BlitzcordGetTimestampPlus(int hours, int minutes, int seconds)
{
auto clockNow = std::chrono::system_clock::now();
auto clockAdded = clockNow + std::chrono::hours(hours) + std::chrono::minutes(minutes) + std::chrono::seconds(seconds);
return _strdup(std::to_string(std::chrono::duration_cast<std::chrono::seconds>(clockAdded.time_since_epoch()).count()).c_str());
}
BLITZ3D(cstring) BlitzcordGetTimestampMinus(int hours, int minutes, int seconds)
{
auto clockNow = std::chrono::system_clock::now();
auto clockSubstracted = clockNow - std::chrono::hours(hours) - std::chrono::minutes(minutes) - std::chrono::seconds(seconds);
return _strdup(std::to_string(std::chrono::duration_cast<std::chrono::seconds>(clockSubstracted.time_since_epoch()).count()).c_str());
}
//LONG SPLITTING
//--------------
BLITZ3D(int) StringToUpperLong(cstring stringLong)
{
return longUpper(atoll(stringLong));
}
BLITZ3D(int) StringToLowerLong(cstring stringLong)
{
return longLower(atoll(stringLong));
}
BLITZ3D(cstring) LongToString(int upperLong, int lowerLong)
{
return _strdup(std::to_string(mergeLong(upperLong, lowerLong)).c_str());
}
int longUpper(uint64 value)
{
return value >> 32;
}
int longLower(uint64 value)
{
return value & 0xffffffff;
}
uint64 mergeLong(int upperLong, int lowerLong)
{
return((uint64)upperLong << 32) | (uint32)lowerLong;
}