Пример #1
0
        void OnReady()
        {
            api       = new DiscordApiClient();
            api.Token = Config.BotToken;

            api.RunAsync();
            RegisterEvents();
        }
Пример #2
0
 void HandleResumedEvent(JsonObject data)
 {
     // May not be null when reconnecting
     if (api == null)
     {
         api       = new DiscordApiClient();
         api.Token = Config.BotToken;
         api.RunAsync();
     }
     OnReady();
 }
Пример #3
0
        void HandleReadyEvent(JsonObject data)
        {
            JsonObject user = (JsonObject)data["user"];

            botUserID = (string)user["id"];

            api       = new DiscordApiClient();
            api.Token = Config.BotToken;

            api.RunAsync();
            RegisterEvents();
        }
Пример #4
0
        protected override void OnStop()
        {
            socket = null;
            if (api != null)
            {
                api.StopAsync();
                api = null;
            }
            base.OnStop();

            OnPlayerConnectEvent.Unregister(HandlePlayerConnect);
            OnPlayerDisconnectEvent.Unregister(HandlePlayerDisconnect);
            OnPlayerActionEvent.Unregister(HandlePlayerAction);
        }
Пример #5
0
        void HandleReadyEvent(JsonObject data)
        {
            JsonObject user = (JsonObject)data["user"];

            botUserID = (string)user["id"];

            // May not be null when reconnecting
            if (api == null)
            {
                api       = new DiscordApiClient();
                api.Token = Config.BotToken;
                api.RunAsync();
            }
            OnReady();
        }