Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Threading;
- // Causes: https://youtu.be/yQ8G4XwoyL8
- class Program
- {
- static void Main(string[] args)
- {
- // Provide one in code
- long clientId = -1;
- // ... or have it prompted.
- if (clientId == -1)
- {
- Console.Write("Enter clientId: ");
- string clientIdStr = Console.ReadLine();
- clientId = long.Parse(clientIdStr);
- }
- Console.WriteLine("Enter 0 below if you have only one Discord client.");
- Console.Write("DISCORD_INSTANCE_ID: ");
- string instanceID = Console.ReadLine();
- Environment.SetEnvironmentVariable("DISCORD_INSTANCE_ID", instanceID);
- var discord = new Discord.Discord(clientId, (ulong)Discord.CreateFlags.Default);
- discord.SetLogHook(Discord.LogLevel.Debug, (level, message) =>
- {
- Console.WriteLine("Log[{0}] {1}", level, message);
- });
- var userManager = discord.GetUserManager();
- userManager.OnCurrentUserUpdate += () =>
- {
- // To show everything is working properly.
- var currentUser = userManager.GetCurrentUser();
- Console.WriteLine($"Current user is {currentUser.Username}.");
- //Console.WriteLine(currentUser.Id);
- Console.WriteLine("So the API is working fine right now.");
- Console.WriteLine();
- };
- var overlayManager = discord.GetOverlayManager();
- try
- {
- Console.WriteLine("Press Q to quit.");
- Console.WriteLine();
- Console.WriteLine("Press O to open voice settings overlay.");
- Console.WriteLine("Keep an eye on Discord when you do so.");
- while (true)
- {
- discord.RunCallbacks();
- Thread.Sleep(1000 / 60);
- if (Console.KeyAvailable)
- {
- ConsoleKeyInfo key = Console.ReadKey(true);
- if (key.Key == ConsoleKey.Q)
- break;
- if (key.Key == ConsoleKey.O)
- {
- Console.WriteLine("Opening overlay...");
- overlayManager.OpenVoiceSettings((result) =>
- {
- Console.WriteLine($"Result was {result}.");
- });
- Console.WriteLine("Signaled open overlay.");
- }
- }
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine($"Error: {ex}");
- }
- finally
- {
- Console.WriteLine("Closing...");
- discord.Dispose();
- }
- }
- }
Add Comment
Please, Sign In to add comment