示例#1
0
        public async Task FilterBase(CommandContext ctx,
                                     string action,
                                     [RemainingText]
                                     string mask = @"")
        {
            // Check if they have the permissions to call this command.
            if (await Permissions.HandlePermissionsCheck(ctx))
            {
                switch (action)
                {
                case "new":
                case "add":
                    if (!(await FilterSystem.HasItem(mask)))
                    {       // The mask doesn't exist already.
                        await FilterSystem.AddMask(ctx, mask);
                    }
                    else
                    {       // The mask does exist.
                        await GenericResponses.SendGenericCommandError(
                            ctx.Channel,
                            ctx.Member.Mention,
                            "Unable to add mask",
                            $"the provided mask `{mask}` exists already as an exclude or mask...");
                    }
                    break;

                case "remove":
                case "delete":
                    if ((await FilterSystem.HasMask(mask)))
                    {       // The mask exists.
                        await FilterSystem.RemoveMask(ctx, mask);
                    }
                    else
                    {       // The mask doesn't exist.
                        await GenericResponses.SendGenericCommandError(
                            ctx.Channel,
                            ctx.Member.Mention,
                            "Unable to remove mask",
                            $"the provided mask `{mask}` does not exist...");
                    }
                    break;

                case "list":
                    await FilterSystem.ListMasks(ctx);

                    break;

                default:     // Invalid arguments.
                    await GenericResponses.HandleInvalidArguments(ctx);

                    break;
                }
            }
        }