def f(func): newf = func for flag in flagList: dec = flags.add_flag(FLAGS[flag]["flag"], action=FLAGS[flag]["action"], default=FLAGS[flag]["default"], help=FLAGS[flag]["help"]) newf = dec(func) return newf
def snipe_parser(func: flags.FlagCommand): """ Decorator to add the snipe parser :param func: The FlagCommand to add the parser to :return: The new FlagCommand with the added parser """ flags.add_flag("--authors", nargs="+", type=discord.Member)(func) flags.add_flag("--channel", type=discord.TextChannel)(func) flags.add_flag("--guild", "--server", action="store_true")(func) flags.add_flag("--before", type=int)(func) flags.add_flag("--after", type=int)(func) flags.add_flag("--list", action="store_true")(func) flags.add_flag("--mode", choices=("deleted", "purged", "edited"))(func) flags.add_flag("--contains", nargs="+")(func) flags.add_flag("index", nargs="?", default=0, type=int)(func) return func
return func def __call__(self, func=None, **kwargs): if func is None: return functools.partial(self.call, **kwargs) return self.call(func, **kwargs) def apply(self, *, flags: Iterable, func: _F) -> _F: for flag in flags: flag(func) return func embed_input = FlagAdder({ "basic": ( flags.add_flag("--title", "-t"), flags.add_flag("--description", "-d"), flags.add_flag("--fields", "-f", nargs="+"), flags.add_flag("--colour", "--color", "-c", type=colortype), ), "image": ( flags.add_flag("--thumbnail", "-th", type=url_type), flags.add_flag("--image", "-i", type=url_type), ), "author": ( flags.add_flag("--author-name", "--aname", "-an"), flags.add_flag("--auto-author", "-aa", action="store_true", default=False), flags.add_flag("--author-url", "--aurl", "-au", type=url_type),