Lachee / discord-rpc-csharp

C# custom implementation for Discord Rich Presence. Not deprecated and still available!
MIT License
593 stars 100 forks source link

[BUG] Rich Presence not updated #103

Open GoldenPalazzo opened 4 years ago

GoldenPalazzo commented 4 years ago

Describe the bug Whenever I start my game with this simple script attached to a Node (I'm using Godot Mono), Rich Presence doesn't show up

using Godot;
using System;
using DiscordRPC;
public class RichPresence : Node
{
    public DiscordRpcClient client;

    //[Export]
    public int level = 0;

    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        client = new DiscordRpcClient("761541156173250580");
        //UInt64 unixSeconds = Convert.ToUInt64(DateTimeOffset.Now.ToUnixTimeSeconds());
        //GD.Print(unixSeconds.ToString());
        /*if (level > 0) {
            client.SetPresence(new DiscordRPC.RichPresence()
            {
                Details = "Level 1-"+level.ToString(),
                State = "Singleplayer",
                //Timestamps = unixSeconds,
                Assets = new Assets() {
                    LargeImageKey = "gamejoltbannersquare",
                    LargeImageText = "Best videogioco ever"
                }
            });
        } else {*/
            client.SetPresence(new DiscordRPC.RichPresence()
            {
                Details = "Idling",
                //Timestamps = unixSeconds,
                Assets = new Assets() {
                    LargeImageKey = "gamejoltbannersquare",
                    LargeImageText = "Best videogioco ever"
                }
            });
        //}
        client.Initialize();
    }
//  // Called every frame. 'delta' is the elapsed time since the previous frame.
//  public override void _Process(float delta)
//  {
//      
//  }
}

To Reproduce Steps to reproduce the behavior:

  1. Create a Node
  2. Attach the script below
  3. Build and run the project

Expected behavior My discord status should show up.

Desktop (please complete the following information):

Lachee commented 4 years ago

If you are using Mono, you will need to use the native pipe wrapper that is used in the Unity version.

GoldenPalazzo commented 4 years ago

How? I checked your other repo, built it with Visual Studio code and tried to import in my project's .csproj like this

<Project Sdk="Godot.NET.Sdk/3.2.3">
  <PropertyGroup>
    <TargetFramework>net472</TargetFramework>
    <RootNamespace>IndustrialRun</RootNamespace>
  </PropertyGroup>
  <ItemGroup>
  <!-- My Libraries -->
  <PackageReference Include="Newtonsoft.Json">
    <Version>12.0.3</Version>
  </PackageReference>
  <Reference Include="UnityNamedPipe">
    <Private>False</Private>
    <HintPath>$(ProjectDir)/lib/UnityNamedPipe.dll</HintPath>
  </Reference>
  <PackageReference Include="DiscordRichPresence">
    <Version>1.0.147</Version>
  </PackageReference>
  </ItemGroup>
</Project>

But then when I write using UnityNamedPipe; VS Code tells me that the namespace hasn't been found.

I'm not very familiar with C#, I'm using it just because this is the only way to use Rich Presence in Godot.

sitiom commented 2 years ago

Duplicate of #94