def __init__(self, bot: LightningBot, record: dict): self.id = record['id'] self.guild = bot.get_guild(record['guild_id']) or record['guild_id'] self.user = bot.get_user(record['user_id']) or record['user_id'] self.moderator = bot.get_user( record['moderator_id']) or record['user_id'] self.action = ActionType(record['action']) self.reason = record['reason'] self.created_at = record['created_at'] self.active = record['active'] self.extra = record['extra']
def __init__(self, bot: LightningBot): self.bot = bot self.original_help_command = bot.help_command bot.help_command = PaginatedHelpCommand() bot.help_command.cog = self self.unavailable_guilds = [] self.process = psutil.Process()
def build_command_docs(): """Builds documentation for commands and stores them in the build directory""" bot = LightningBot() for command in bot.walk_commands(): description = command.description or command.help flag_fmt = "" signature = command.signature or command.usage subcmd_fmt = "" if hasattr(command.callback, "__lightning_argparser__"): flags = command.callback.__lightning_argparser__.get_all_unique_flags( ) flag_fmt = flag_page.format(flags=format_command_flags(flags)) # This is a group if hasattr(command, "commands"): subcmd_fmt = subcmds_page.format( subcmds=format_subcommands(command.commands)) fmt = command_page.format( name=command.qualified_name, signature=signature.strip() or "", description=description.replace("\n", "<br>") if description else "", aliases=format_command_aliases(command.aliases), params=format_command_params(command.clean_params), flags=flag_fmt, subcmds=subcmd_fmt) fname = command.qualified_name.replace(" ", "_") if command.cog: cog = command.cog.qualified_name.lower() else: cog = "not_categorized" path = pathlib.Path(f"build/docs/commands/{cog}/") path.mkdir(parents=True, exist_ok=True) path = path / pathlib.Path(f"{fname}.md") with path.open("w", encoding="utf-8") as fp: fp.write(fmt) typer.echo(f"Built {command.qualified_name} page ({str(path)})") typer.echo("Built all command pages!")
def build_cog_docs(): """Builds documentation pages for cogs and stores them in the build directory""" bot = LightningBot() cogs = sorted(bot.cogs.values(), key=lambda c: c.qualified_name) for cog in cogs: cmds = [] for command in sorted(cog.walk_commands(), key=lambda c: c.qualified_name): aliases = ' '.join("`{}`".format(r) for r in command.aliases) or "None" signature = command.signature or command.usage usage = f".{command.qualified_name}" if signature: usage += f" {signature}" if command.cog: cog_name = command.cog.qualified_name.lower() else: cog_name = "not_categorized" description = command.help.replace( '\n', '<br>') if command.help else None link = f'https://lightning-bot.gitlab.io/commands/{cog_name}/'\ f'{command.qualified_name.lower().replace(" ", "_")}' cmds.append((f"[{command.qualified_name}]({link})", aliases, description, f"`{usage}`")) path = pathlib.Path( f"build/docs/commands/{cog.qualified_name.lower()}") path.mkdir(parents=True, exist_ok=True) path = path / pathlib.Path( "index.md") # There should never be a command called "index" desc = (cog.qualified_name, cog.description, tabulate(cmds, headers=("Name", "Aliases", "Description", "Usage"), tablefmt="github")) fmt = "# {}\n{}\n\n{}\n\n".format(desc[0], desc[1], desc[2]) with path.open("w", encoding="utf-8") as fp: fp.write(fmt) typer.echo(f"Built {cog.qualified_name} page ({str(path)})") typer.echo("Built all cog pages!")
def setup(bot: LightningBot) -> None: bot.add_cog(Switchy(bot))
def setup(bot: LightningBot): bot.add_cog(Meta(bot)) # Remove support command if not in config if bot.config['bot'].get("support_server_invite", None) is None: bot.remove_command("support")
def setup(bot: LightningBot) -> None: bot.add_cog(Configuration(bot)) if "beta_prefix" in bot.config['bot']: bot.remove_command("config prefix")
def setup(bot: LightningBot) -> None: bot.add_cog(Homebrew(bot))
def setup(bot: LightningBot): bot.add_cog(Roles(bot))
def setup(bot: LightningBot) -> None: bot.add_cog(Git(bot))
def setup(bot: LightningBot) -> None: bot.add_cog(Infractions(bot))
def setup(bot: LightningBot): bot.add_cog(Misc(bot))
def setup(bot: LightningBot) -> None: bot.add_cog(Emoji(bot))
def setup(bot: LightningBot) -> None: bot.add_cog(ListenerEvents(bot))
def setup(bot: LightningBot) -> None: bot.add_cog(ModLog(bot))
def setup(bot: LightningBot) -> None: bot.add_cog(Memes(bot))
def setup(bot: LightningBot) -> None: bot.add_cog(Activities(bot))
def setup(bot: LightningBot): bot.add_cog(API(bot))
def setup(bot: LightningBot) -> None: bot.add_cog(Stats(bot))
def setup(bot: LightningBot) -> None: bot.add_cog(Owner(bot=bot))
def setup(bot: LightningBot) -> None: bot.add_cog(FeaturesListeners(bot))