예제 #1
0
        public DiscordInterface(string token)
        {
            if (token == "" || token == null)
            {
                Console.WriteLine("Couldn't get login token!");
                return;
            }

            client = new Discord.DiscordClient();
            client.MessageReceived += (s, e) =>
            {
                if (!e.Message.IsAuthor)
                {
                    DiscordUser    user    = new DiscordUser(e.User);
                    DiscordChannel channel = new DiscordChannel(e.Channel);
                    DiscordServer  server  = new DiscordServer(e.Server);
                    DiscordMessage message = new DiscordMessage(e.Message);
                    Task.Run(() => OnMessageRecieved(user, channel, server, message));
                }
            };

            client.UserUpdated += (s, e) =>
            {
                Task.Run(() => OnUserChange(new DiscordUser(e.Before), new DiscordUser(e.After), new DiscordServer(e.Server)));
            };

            client.UserJoined += (s, e) =>
            {
                DiscordUser   user   = new DiscordUser(e.User);
                DiscordServer server = new DiscordServer(e.Server);
                Task.Run(() => OnUserJoined(user, server));
            };

            client.UserBanned += (s, e) =>
            {
                DiscordUser   user   = new DiscordUser(e.User);
                DiscordServer server = new DiscordServer(e.Server);
                Task.Run(() => OnUserBanned(user, server));
            };

            client.UserUnbanned += (s, e) =>
            {
                DiscordUser   user   = new DiscordUser(e.User);
                DiscordServer server = new DiscordServer(e.Server);
                Task.Run(() => OnUserUnbanned(user, server));
            };

            client.UserLeft += (s, e) =>
            {
                DiscordUser   user   = new DiscordUser(e.User);
                DiscordServer server = new DiscordServer(e.Server);
                Task.Run(() => OnUserLeave(user, server));
            };

            client.ExecuteAndWait(async() =>
            {
                await client.Connect(token, Discord.TokenType.Bot);
            });
        }
예제 #2
0
        public override BaseServer GetServer()
        {
            DiscordServer server = new DiscordServer(channelInterface.Server);

            return(server);
        }