Example #1
0
        internal override async Task Execute(CommandObjects CommandObject)
        {
            string[] msgs = CommandObject.CommandArgs.Remove(0);
            if (msgs.Length == 0)
            {
                await CommandObject.Message.Channel.SendMessageAsync("何も入力されていません");

                return;
            }
            await Task.Delay(0);
        }
Example #2
0
        internal static async Task Start(DiscordClient Bot, MessageCreateEventArgs Message_Objects)
        {
            Log.Debug("Command check");

            CommandObjects CommandObject = new CommandObjects(Bot, Message_Objects);

            // Bot Check
            if (CommandObject.Author.IsBot)
            {
                return;
            }
            //if (Message_Objects.Channel.IsPrivate) return;

            // Prefix Check

            string GuildPrefix = CommandObject.Guild is null ? null : Database.DatabaseMethods.GuildConfigMethods.PrefixFind(CommandObject.Guild.Id);

            if (GuildPrefix == null)
            {
                GuildPrefix = CommandConfig.Prefix;
            }

            string CommandPrefix = CommandObject.CommandArgs[0][0..GuildPrefix.Length];
Example #3
0
        internal static async Task <bool> Confirmation(CommandObjects CommandObject)
        {
            string AuthCode = RandomCodeGenerate();
            await CommandObject.Member.SendMessageAsync(AuthCode);

            DiscordMessage BotSendMessage = await CommandObject.Message.Channel.SendMessageAsync("処理を実行する前に確認のためDMに送信した6文字のコードを入力してください");

            DiscordMessage AuthSend = await BotSendMessage.AwaitMessage(CommandObject.Message.Author.Id, 1 * 60 * 1000);

            if (AuthSend == null)
            {
                return(false);
            }

            if (AuthSend.Content != AuthCode)
            {
                await CommandObject.Message.Channel.SendMessageAsync("コードが違います");

                return(false);
            }

            return(true);
        }
Example #4
0
        private static async Task ExecuteCommands(CommandObjects CommandObject, string CommandText, RoleLevel Role_Level)
        {
            Log.Debug($"Command RoleLevel [{Role_Level}]");

            if (Role_Level == RoleLevel.Bot)
            {
                Log.Error("Why this method access allowed?");
                return;
            }

            foreach (CommandInfo Command_Info in CommandInfo.GetCommandInfo())
            {
                if (Command_Info.Command_Attribute.CommandName != CommandText)
                {
                    continue;
                }
                else if (Command_Info.Command_Attribute.CommandRoleLevel == RoleLevel.Bot)
                {
                    Log.Error("It will never be executed.");
                    continue;
                }
                else if (Command_Info.Command_Attribute.CommandRoleLevel != RoleLevel.Owner && CommandObject.Channel.IsPrivate)
                {
                    continue;
                }
                else if (Command_Info.Command_Attribute.CommandRoleLevel == RoleLevel.Owner && !CommandObject.Channel.IsPrivate)
                {
                    continue;
                }

                if (Role_Level != RoleLevel.Owner)
                {
                    if (Command_Info.Command_Attribute.CommandRoleLevel == RoleLevel.Owner)
                    {
                        Log.Info("Not bot owner user tried to access the bot owner command.");
                        continue;
                    }
                    else if (Command_Info.Command_Attribute.CommandRoleLevel > Role_Level)
                    {
                        Log.Info("The member who has not been granted roles registered in the database tried to access the command.");
                        continue;
                    }
                }

                if (Command_Info.Command is null)
                {
                    Log.Error("Command is not wrapped with CommandAbstruct.");
                    continue;
                }

                await Command_Info.Command.Execute(CommandObject).ContinueWith(CommandTask => {
                    if (CommandTask.IsFaulted || CommandTask.IsCanceled)
                    {
                        Log.Error($"Command Execute Error in {Command_Info.Command_Attribute.CommandName}", CommandTask.Exception);
                    }
                    else
                    {
                        Log.Info($"{Command_Info.Command_Attribute.CommandName} completed successfully.");
                    }
                }).ConfigureAwait(false);

                return;
            }

            Log.Error("Commnad Not Found.");
        }