示例#1
0
    static async Task MainAsync(string[] args)
    {
        GlobalProperties.discord = new DiscordClient(new DiscordConfiguration
        {//MzU5MTk5NjAwMjE0NTQwMjg5.DKDjSA.E9in_YB9nQ3ZhX0Q4_O8z3_KL2g
            Token                 = GlobalProperties.Token,
            TokenType             = TokenType.Bot,
            UseInternalLogHandler = true,
            LogLevel              = LogLevel.Debug
        });
        GlobalProperties.discord.SetWebSocketClient <WebSocket4NetCoreClient>();

        GlobalProperties.commands = GlobalProperties.discord.UseCommandsNext(new CommandsNextConfiguration
        {
            StringPrefix      = "!",
            EnableDefaultHelp = true,
            CaseSensitive     = false
        });
        GlobalProperties.commands.RegisterCommands <Commands>();
        GlobalProperties.commands.RegisterCommands <OfficerCommands>();
        GlobalProperties.commands.RegisterCommands <OwnerCommands>();
        GlobalProperties.discord.MessageCreated += async(e) =>
        {
            if (!e.Message.Author.IsBot)
            {
                if (e.Message.Content.ToLower().Contains("titan-bot") || e.Message.Content.ToLower().Contains("titan bot"))
                {
                    if (e.Message.Content.ToLower().RemovePunc().Simplify().Contains("can u check ur dictionary"))
                    {
                        if (e.Message.Author.Username == "Tastygod")
                        {
                            await ai.Respond(e, "Of course Tastygod, I'll get right on that!");

                            ai.GetContextJson();
                        }
                        else
                        {
                            await ai.Respond(e, "Sorry, @. This function is only available to Tastygod!");
                        }
                    }
                    else if (e.Message.Content.ToLower() == "bad titan-bot" || e.Message.Content.ToLower() == "bad titan bot")
                    {
                        await ai.Respond(e, ":(");
                    }
                    else if (e.Message.Content.ToLower() == "good titan-bot" || e.Message.Content.ToLower() == "good titan bot")
                    {
                        await ai.Respond(e, ":)");
                    }
                    else
                    {
                        await ai.Interact(e);
                    }
                }
            }
        };
        //on ready
        GlobalProperties.discord.Ready += async e =>
        {
            await Task.Yield(); //

            GlobalProperties.discord.DebugLogger.LogMessage(LogLevel.Info, "Bot", "Ready! Setting status message..", DateTime.Now);
            await Utils.SetStatus();

            //await OpeningMessage();
        };

        await GlobalProperties.discord.ConnectAsync();

        await Task.Delay(-1);
    }