Пример #1
0
        void SetToken(string token)
        {
            if (token == bottoken)
            {
                return;
            }

            if (bottoken != null)
            {
                websocket.Connected      -= OnConnected;
                websocket.MessageCreated -= OnMessage;
                websocket.Disconnect();
                discord = null;
            }

            bottoken = token;
            context.Settings.Set(this, "bottoken", token);

            if (!string.IsNullOrEmpty(bottoken))
            {
                websocket                 = new DiscordWebsocket(bottoken);
                websocket.Connected      += OnConnected;
                websocket.MessageCreated += OnMessage;

                discord = new DiscordRest(bottoken, true);
                websocket.Connect();
            }
        }
Пример #2
0
 /// <summary>
 /// creates a new <see cref="DiscordChatChannel"/>
 /// </summary>
 /// <param name="discord"></param>
 /// <param name="key"></param>
 /// <param name="flags">additional flags for channel (<see cref="ChannelFlags.Bot"/> is automatically set)</param>
 public DiscordChatChannel(DiscordRest discord, string key, ChannelFlags flags = ChannelFlags.None)
 {
     this.discord = discord;
     this.flags   = flags;
     Key          = key;
 }