Example #1
0
        static async Task MainAsync(string[] args)
        {
            discord = new DiscordClient(new DiscordConfiguration
            {
                Token     = ConfigurationManager.AppSettings["Token"],
                TokenType = TokenType.Bot
            });

            discord.SetWebSocketClient <WebSocket4NetClient>();

            discord.MessageCreated += async e =>
            {
                Boolean master  = e.Message.Author.Username.Contains("lxdnz") && e.Message.Author.Discriminator.Equals("0605");
                string  content = e.Message.Content.ToLower();
                // waits for a query from user "??"
                if (content.StartsWith("??"))
                {
                    await e.Message.RespondAsync(BotResponse.BotReply(content));
                }
                if (content.StartsWith("?+") && master)
                {
                    await e.Message.RespondAsync("I hear you oh master! - " + BotResponse.BotAdd(content));
                }
                if (content.StartsWith("?+") && !master)
                {
                    await e.Message.RespondAsync("I do not take orders from imposters, " + BotResponse.BotUserAdd(content));
                }
                if (content.StartsWith("?*") && master)
                {
                    await e.Message.RespondAsync(BotResponse.BotUpdate(content));
                }
                if (content.StartsWith("+?") && master)
                {
                    await e.Message.RespondAsync("Master, the serfs wish to add :" + BotResponse.GetModeration());
                }
                if (content.StartsWith("-?") && master)
                {
                    await e.Message.RespondAsync(BotResponse.DeleteModeration(content));
                }
                if (content.StartsWith("*?") && master)
                {
                    await e.Message.RespondAsync(BotResponse.ApproveModeration());
                }
            };

            await discord.ConnectAsync();

            ConsoleAsync.AsyncConsole(args).ConfigureAwait(false).GetAwaiter().GetResult();
            await Task.Delay(-1);
        }
        internal static async Task AsyncConsole(string[] args)
        {
            var consoleLine = Console.ReadLine();

            if (consoleLine == "")
            {
                Console.WriteLine("Master, the serfs wish to add :" + BotResponse.GetModeration());
                AsyncConsole(args).ConfigureAwait(false).GetAwaiter().GetResult();
            }
            ;
            if (consoleLine.StartsWith("??"))
            {
                Console.WriteLine(BotResponse.BotReply(consoleLine));
                AsyncConsole(args).ConfigureAwait(false).GetAwaiter().GetResult();
            }
            if (consoleLine.StartsWith("-?"))
            {
                Console.WriteLine(BotResponse.DeleteModeration(consoleLine));
                AsyncConsole(args).ConfigureAwait(false).GetAwaiter().GetResult();
            }
            if (consoleLine == "OK")
            {
                Console.WriteLine(BotResponse.ApproveModeration());
                AsyncConsole(args).ConfigureAwait(false).GetAwaiter().GetResult();
            }
            if (consoleLine.StartsWith("++"))
            {
                Console.WriteLine(BotResponse.BotAdd(consoleLine));
                AsyncConsole(args).ConfigureAwait(false).GetAwaiter().GetResult();
            }
            if (consoleLine.StartsWith("**"))
            {
                Console.WriteLine(BotResponse.BotUpdate(consoleLine));
                AsyncConsole(args).ConfigureAwait(false).GetAwaiter().GetResult();
            }
            if (consoleLine.StartsWith("+?"))
            {
                Console.WriteLine("Trick me master, " + BotResponse.BotUserAdd(consoleLine));
                AsyncConsole(args).ConfigureAwait(false).GetAwaiter().GetResult();
            }
            await Task.Delay(-1);
        }