sleepy-discord
sleepy-discord copied to clipboard
updateStatus not working
Hey, when I use updateStatus, the server disconnects, because he doesn't know that opcode.
The problem is, the discord team has updated the version 6 of the gateway.
Here is my solution code:
enum GameType {
game = 0,
streaming = 1,
listening = 2
};
enum Status {
online = 0,
dnd = 1,
idle = 2,
invisible = 3,
offline = 4
};
std::map<int, std::string> statusMap = { { 0, "online" }, { 1, "dnd" }, { 2, "idle" }, { 3, "invisble" }, { 4, "offline"} };
void BaseDiscordClient::updateStatus(std::string gameName, GameType gameType, Status status, bool afk, uint64_t idleSince) {
sendL(SleepyDiscord::json::createJSON({
{ "op", SleepyDiscord::json::integer(STATUS_UPDATE) },
{ "d", SleepyDiscord::json::createJSON({
{ "since", idleSince != 0 ? SleepyDiscord::json::UInteger(idleSince) : "null" },
{ "game", gameName != "" ? SleepyDiscord::json::createJSON({
{ "name", SleepyDiscord::json::string(gameName) },
{ "type", SleepyDiscord::json::integer(gameType)}
}) : "null" },
{ "status", SleepyDiscord::json::string(statusMap[status]) },
{ "afk", SleepyDiscord::json::boolean(afk) }
}) }
}));
}
BUT please add the streaming url to the game tab
ok thanks for telling, sorry I wasn't aware. However, is there a reason you are using a map with global scope instead of an array?
Only reason I can think of is he didn't want to check if status < 5. If Discord API adds another status that would be an illegal read. Other than that std::array will probably work which has bounds checking in debug mode.
it's only as an example an a fast workaround