Browse Source

Add voice chat commands

tags/v1.0.1
NGnius (Graham) 4 years ago
parent
commit
8d44536ea0
3 changed files with 31 additions and 0 deletions
  1. +1
    -0
      GamecraftRPC/CallbackUtility.cs
  2. +28
    -0
      GamecraftRPC/Plugin.cs
  3. +2
    -0
      GamecraftRPC/PresenceUtility.cs

+ 1
- 0
GamecraftRPC/CallbackUtility.cs View File

@@ -74,6 +74,7 @@ namespace GamecraftRPC
}
PresenceUtility.IsActivityHost = false;
PresenceUtility.IsServerActive = false;
PresenceUtility.IsVoiceConnected = false;
Plugin.SetDiscordActivity(PresenceUtility.Activity, debug: "MenuEnter-API-callback");
}



+ 28
- 0
GamecraftRPC/Plugin.cs View File

@@ -145,6 +145,34 @@ namespace GamecraftRPC

})
.Build();

CommandBuilder.Builder()
.Name("DiscordVoice")
.Description("Connect to Discord Voice Lobby")
.Action(() =>
{
if (DiscordRPC != null)
{
GamecraftModdingAPI.Utility.Logging.CommandLogError("Discord GameSDK is unavailable. Please make sure Discord is open when launching Gamecraft.");
return;
}
if (PresenceUtility.Lobby.HasValue)
{
//LobbyManager lm = DiscordRPC.GetLobbyManager();
if (PresenceUtility.IsVoiceConnected)
{
lm.DisconnectLobby(PresenceUtility.Lobby.Value.Id, (result) => { GamecraftModdingAPI.Utility.Logging.CommandLog($"Disconnected voice (Result: {result})"); });
PresenceUtility.IsVoiceConnected = false;
}
else
{
lm.ConnectVoice(PresenceUtility.Lobby.Value.Id, (result) => { GamecraftModdingAPI.Utility.Logging.CommandLog($"Connected voice (Result: {result})"); });
PresenceUtility.IsVoiceConnected = true;
}

}
})
.Build();
#if !RELEASE
bool alreadyWarned = false;
Client.EnterMenu += (_, args) =>


+ 2
- 0
GamecraftRPC/PresenceUtility.cs View File

@@ -28,5 +28,7 @@ namespace GamecraftRPC
public static bool IsServerActive = false;

public static bool IsConnecting = false;

public static bool IsVoiceConnected = false;
}
}

Loading…
Cancel
Save