Skip to content

Instantly share code, notes, and snippets.

@msciotti
Created April 28, 2020 21:30
Show Gist options
  • Save msciotti/3f1c9a91c2cae3f0d71195dc5c21bdea to your computer and use it in GitHub Desktop.
Save msciotti/3f1c9a91c2cae3f0d71195dc5c21bdea to your computer and use it in GitHub Desktop.
#include <chrono>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <thread>
#include "files/discord.h"
namespace {
volatile bool interrupted{ false };
}
void main()
{
using namespace std::chrono_literals;
discord::Core* core;
auto result = discord::Core::Create(461618159171141643, DiscordCreateFlags_Default, &core);
if (result != discord::Result::Ok)
{
std::cout << "Failed to init Discord.\n";
return;
}
core->LobbyManager().OnMemberUpdate.Connect([](std::int64_t LobbyId, std::int64_t UserId) {
std::cout << "lobby " << LobbyId << ", user " << UserId << " was updated\n";
});
core->LobbyManager().ConnectLobbyWithActivitySecret("704806335459491902:1879ef508b673e1e", [&core](discord::Result result, discord::Lobby const& lobby) {
if (result == discord::Result::Ok) {
std::cout << "Connected to lobby: " << lobby.GetId();
discord::LobbyMemberTransaction txn;
core->LobbyManager().GetMemberUpdateTransaction(lobby.GetId(), 53908232506183680, &txn);
txn.SetMetadata("current_mmr", "1337");
core->LobbyManager().UpdateMember(lobby.GetId(), 53908232506183680, txn, [](discord::Result result) {
std::cout << "Updated member";
});
}});
int m = 0;
while (true)
{
// run callbacks
core->RunCallbacks();
m++;
std::this_thread::sleep_for(100ms);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment