discord / discord-api-docs

Official Discord API Documentation
https://discord.com/developers/docs/intro
Other
5.91k stars 1.25k forks source link

Unity #6378

Closed ShevchukKirill closed 1 year ago

ShevchukKirill commented 1 year ago

Description

I'm using the Discord Game SDK. I added lobby creation to my code, but the error CS1061 and CS1628 happens

Steps to Reproduce

Code:

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Discord;

public class DS : MonoBehaviour
{
    public Discord.Discord discord;
    void Start()
    {
        discord = new Discord.Discord(CLIENT_ID, (System.UInt64)Discord.CreateFlags.Default);
        CreateLobby();
        var activityManager = discord.GetActivityManager();
        Discord.Activity activity = new Discord.Activity
        {
            State = "Test",
            Details = "Test"
        };
        activityManager.UpdateActivity(activity, (result) =>
        {
            if (result == Discord.Result.Ok)
            {
                Console.WriteLine("Success!");
            }
            else
            {
                Console.WriteLine("Failed");
            }
        });
    }
    // Update is called once per frame
    void Update()
    {
        discord.RunCallbacks();
    }

    void CreateLobby() {
        var lobbyManager = discord.GetLobbyManager();
        var txn = lobbyManager.GetLobbyCreateTransaction();
        txn.SetCapacity(6);
        txn.SetType(Discord.LobbyType.Public);
        txn.SetMetadata("a", "123");
        lobbyManager.CreateLobby(txn, LobbyCreateCallback);
    }
    void LobbyCreateCallback(Discord.Result result, ref Discord.Lobby lobby) {
        var lobbyManager = discord.GetLobbyManager();
        Console.WriteLine("lobby {0} created with secret {1}", lobby.Id, lobby.Secret);
        var newTxn = lobbyManager.GetLobbyUpdateTransaction(lobby.id);
        newTxn.SetCapacity(5);

        lobbyManager.UpdateLobby(lobby.id, newTxn, (result) =>
        {
            Console.WriteLine("lobby {0} updated", lobby.Id);
        });
    }
}

Expected Behavior

Creating a lobby

Current Behavior

Assets\DS.cs(49,61): error CS1061: 'Lobby' does not contain a definition for 'id' and no accessible extension method 'id' accepting a first argument of type 'Lobby' could be found (are you missing a using directive or an assembly reference?)

Assets\DS.cs(52,34): error CS1061: 'Lobby' does not contain a definition for 'id' and no accessible extension method 'id' accepting a first argument of type 'Lobby' could be found (are you missing a using directive or an assembly reference?)

Assets\DS.cs(54,43): error CS1628: Cannot use ref, out, or in parameter 'lobby' inside an anonymous method, lambda expression, query expression, or local function

Screenshots/Videos

No response

Client and System Information

Unity Engine: 2022.3.7f1 Discord Game SDK: 3.2.1

Zoddo commented 1 year ago

The lobbies part of the GameSDK was deprecated last year and was planned to be decommissioned on May 2, 2023: https://discord.com/developers/docs/change-log#gamesdk-feature-deprecation

ShevchukKirill commented 1 year ago

How can I make a connection via Discord?

ShevchukKirill commented 1 year ago

#