예제 #1
0
        private static void RunDiscordThread()
        {
            var thread = new Thread(async() =>
            {
                try
                {
                    DiscordAPI = new DiscordAPI();

                    while (!_token.IsCancellationRequested)
                    {
                        await Task.Delay(10);
                    }

                    DiscordAPI?.Stop();
                }
                catch (Exception ex)
                {
                    await LogHelper.LogEx("Discord Thread", ex, LogCat.Discord);
                    DiscordAPI?.Stop();
                    if (!_token.IsCancellationRequested)
                    {
                        RunDiscordThread();
                    }
                }
            });

            thread.Start();
        }
예제 #2
0
 private void OnDestroy()
 {
     if (Singleton == this)
     {
         DiscordAPI.UnregisterEventsHandler(this);
         DiscordAPI.Stop();
         Singleton = null;
     }
 }
예제 #3
0
        static void Main(string[] args)
        {
            Console.Title           = "DiscordUnity";
            Console.ForegroundColor = ConsoleColor.Green;

            Console.WriteLine("Starting up DiscordUnity!");
            thread = Thread.CurrentThread;

            DiscordAPI.Logger = new Logger();

            Start();

            while (Console.ReadLine() != "exit")
            {
                DiscordAPI.Update();
            }

            DiscordAPI.Stop();

            Console.ReadKey();
        }
예제 #4
0
 public void Dispose()
 {
     API.Stop();
 }