Skip to content

Instantly share code, notes, and snippets.

#include <chrono>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <thread>
#include "files/discord.h"
namespace {
volatile bool interrupted{ false };
@msciotti
msciotti / Player1.cs
Created April 28, 2020 21:15
Lobby Member Update Bug Repro
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Discord;
public class DiscordController : MonoBehaviour {
public Discord.Discord discord;
// Use this for initialization
using System.Collections;
using System.Collections.Generic;
using Discord;
using UnityEngine;
public class DiscordController : MonoBehaviour
{
public Discord.Discord discord;
public Discord.LobbyManager lobbyManager;
public System.Int64 lobbyId;

Getting Slab Notifications in Discord

We have lots of things to keep track of and lots of places that we get pings. Also, no one checks emails. Here's a small integration to get Slab notifications to ping you on Discord.

Steps

In Discord

  1. Create some sort of test server for yourself (I assume a lot of us already have one)
  2. Create a channel for the pings to go in
  1. In your project folder, you'll want to make something like a "discord-files" folder, for organization. In that folder, copy all the .h and .cpp files from the zip

  2. You want to include all the header and source files respectively in your project

  1. In your project settings, you'll want to include discord_game_sdk.dll.lib as an additional dependency

using System;
using UnityEngine;
[Serializable]
public class DiscordJoinEvent : UnityEngine.Events.UnityEvent<string> {}
[Serializable]
public class DiscordSpectateEvent : UnityEngine.Events.UnityEvent<string> {}
[Serializable]

So, the thing that's gonna help us here is making use of multiple manifests. When you create a config.json file to upload your game, you've got something that looks like this.

{
  "application": {
    "id": your_app_id,
    "manifests": [
      {
        // a bunch of stuff
      }
// This code is client #1. All is unity examples
public void OnClick()
{
var lobbyManager = discord.GetLobbyManager();
lobbyManager.SendNetworkMessage(lobby.Id, 363446008341987328, 0, System.Text.Encoding.UTF8.GetBytes("Sup"));
}
void OnEnable()
{
struct DiscordState {
std::unique_ptr<discord::Core> core;
};
namespace {
volatile bool interrupted{ false };
}
int main()
{
var lobbyManager = discord.GetLobbyManager();
lobbyManager.ConnectLobby(lobbyId, lobbySecret, (Discord.Result result, ref Discord.Lobby lobby) =>
{
if (result == Discord.Result.Ok)
{
// User is in the lobby
lobbyManager.ConnectVoice(lobby.Id, (res) =>
{
if (res == Discord.Result.Ok)
{