Beispiel #1
0
        void OnReady()
        {
            api       = new DiscordApiClient();
            api.Token = Config.BotToken;

            api.RunAsync();
            RegisterEvents();
        }
Beispiel #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();
 }
Beispiel #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();
        }
Beispiel #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);
        }
Beispiel #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();
        }