diff options
author | 2019-09-10 16:56:04 -0400 | |
---|---|---|
committer | 2019-09-10 16:56:04 -0400 | |
commit | 6e9526729d8bb4142b6aadf39a92e6258404f95b (patch) | |
tree | a7cc99fd6854104c201ef9b302d471ecdecf22e4 | |
parent | Docstring linting chunk 1 (diff) |
Docstring linting chunk 2
-rw-r--r-- | bot/cogs/alias.py | 140 | ||||
-rw-r--r-- | bot/cogs/clean.py | 97 | ||||
-rw-r--r-- | bot/cogs/cogs.py | 28 | ||||
-rw-r--r-- | bot/cogs/deployment.py | 31 | ||||
-rw-r--r-- | bot/cogs/information.py | 35 | ||||
-rw-r--r-- | bot/cogs/modlog.py | 65 | ||||
-rw-r--r-- | bot/cogs/verification.py | 39 |
7 files changed, 150 insertions, 285 deletions
diff --git a/bot/cogs/alias.py b/bot/cogs/alias.py index 85d101448..a01a05715 100644 --- a/bot/cogs/alias.py +++ b/bot/cogs/alias.py @@ -4,7 +4,7 @@ from typing import Union from discord import Colour, Embed, Member, User from discord.ext.commands import ( - Command, Context, clean_content, command, group + Bot, Command, Context, clean_content, command, group ) from bot.cogs.watchchannels.watchchannel import proxy_user @@ -15,25 +15,13 @@ log = logging.getLogger(__name__) class Alias: - """ - Aliases for more used commands - """ + """Aliases for commonly used commands.""" - def __init__(self, bot): + def __init__(self, bot: Bot): self.bot = bot - async def invoke(self, ctx, cmd_name, *args, **kwargs): - """ - Invokes a command with args and kwargs. - Fail early through `command.can_run`, and logs warnings. - - :param ctx: Context instance for command call - :param cmd_name: Name of command/subcommand to be invoked - :param args: args to be passed to the command - :param kwargs: kwargs to be passed to the command - :return: None - """ - + async def invoke(self, ctx: Context, cmd_name: str, *args, **kwargs) -> None: + """Invokes a command with args and kwargs.""" log.debug(f"{cmd_name} was invoked through an alias") cmd = self.bot.get_command(cmd_name) if not cmd: @@ -46,9 +34,8 @@ class Alias: await ctx.invoke(cmd, *args, **kwargs) @command(name='aliases') - async def aliases_command(self, ctx): + async def aliases_command(self, ctx: Context) -> None: """Show configured aliases on the bot.""" - embed = Embed( title='Configured aliases', colour=Colour.blue() @@ -64,140 +51,89 @@ class Alias: ) @command(name="resources", aliases=("resource",), hidden=True) - async def site_resources_alias(self, ctx): - """ - Alias for invoking <prefix>site resources. - """ - + async def site_resources_alias(self, ctx: Context) -> None: + """Alias for invoking <prefix>site resources.""" await self.invoke(ctx, "site resources") @command(name="watch", hidden=True) - async def bigbrother_watch_alias(self, ctx, user: Union[Member, User, proxy_user], *, reason: str): - """ - Alias for invoking <prefix>bigbrother watch [user] [reason]. - """ - + async def bigbrother_watch_alias(self, ctx: Context, user: Union[Member, User, proxy_user], *, reason: str) -> None: + """Alias for invoking <prefix>bigbrother watch [user] [reason].""" await self.invoke(ctx, "bigbrother watch", user, reason=reason) @command(name="unwatch", hidden=True) - async def bigbrother_unwatch_alias(self, ctx, user: Union[User, proxy_user], *, reason: str): - """ - Alias for invoking <prefix>bigbrother unwatch [user] [reason]. - """ - + async def bigbrother_unwatch_alias(self, ctx: Context, user: Union[User, proxy_user], *, reason: str) -> None: + """Alias for invoking <prefix>bigbrother unwatch [user] [reason].""" await self.invoke(ctx, "bigbrother unwatch", user, reason=reason) @command(name="home", hidden=True) - async def site_home_alias(self, ctx): - """ - Alias for invoking <prefix>site home. - """ - + async def site_home_alias(self, ctx: Context) -> None: + """Alias for invoking <prefix>site home.""" await self.invoke(ctx, "site home") @command(name="faq", hidden=True) - async def site_faq_alias(self, ctx): - """ - Alias for invoking <prefix>site faq. - """ - + async def site_faq_alias(self, ctx: Context) -> None: + """Alias for invoking <prefix>site faq.""" await self.invoke(ctx, "site faq") @command(name="rules", hidden=True) - async def site_rules_alias(self, ctx): - """ - Alias for invoking <prefix>site rules. - """ - + async def site_rules_alias(self, ctx: Context) -> None: + """Alias for invoking <prefix>site rules.""" await self.invoke(ctx, "site rules") @command(name="reload", hidden=True) - async def cogs_reload_alias(self, ctx, *, cog_name: str): - """ - Alias for invoking <prefix>cogs reload [cog_name]. - - cog_name: str - name of the cog to be reloaded. - """ - + async def cogs_reload_alias(self, ctx: Context, *, cog_name: str) -> None: + """Alias for invoking <prefix>cogs reload [cog_name].""" await self.invoke(ctx, "cogs reload", cog_name) @command(name="defon", hidden=True) - async def defcon_enable_alias(self, ctx): - """ - Alias for invoking <prefix>defcon enable. - """ - + async def defcon_enable_alias(self, ctx: Context) -> None: + """Alias for invoking <prefix>defcon enable.""" await self.invoke(ctx, "defcon enable") @command(name="defoff", hidden=True) - async def defcon_disable_alias(self, ctx): - """ - Alias for invoking <prefix>defcon disable. - """ - + async def defcon_disable_alias(self, ctx: Context) -> None: + """Alias for invoking <prefix>defcon disable.""" await self.invoke(ctx, "defcon disable") @command(name="exception", hidden=True) - async def tags_get_traceback_alias(self, ctx): - """ - Alias for invoking <prefix>tags get traceback. - """ - + async def tags_get_traceback_alias(self, ctx: Context) -> None: + """Alias for invoking <prefix>tags get traceback.""" await self.invoke(ctx, "tags get traceback") @group(name="get", aliases=("show", "g"), hidden=True, invoke_without_command=True) - async def get_group_alias(self, ctx): - """ - Group for reverse aliases for commands like `tags get`, - allowing for `get tags` or `get docs`. - """ - + async def get_group_alias(self, ctx: Context) -> None: + """Group for reverse aliases for commands like `tags get`, allowing for `get tags` or `get docs`.""" pass @get_group_alias.command(name="tags", aliases=("tag", "t"), hidden=True) async def tags_get_alias( self, ctx: Context, *, tag_name: TagNameConverter = None - ): - """ - Alias for invoking <prefix>tags get [tag_name]. - - tag_name: str - tag to be viewed. - """ - + ) -> None: + """Alias for invoking <prefix>tags get [tag_name].""" await self.invoke(ctx, "tags get", tag_name) @get_group_alias.command(name="docs", aliases=("doc", "d"), hidden=True) async def docs_get_alias( self, ctx: Context, symbol: clean_content = None - ): - """ - Alias for invoking <prefix>docs get [symbol]. - - symbol: str - name of doc to be viewed. - """ - + ) -> None: + """Alias for invoking <prefix>docs get [symbol].""" await self.invoke(ctx, "docs get", symbol) @command(name="nominate", hidden=True) - async def nomination_add_alias(self, ctx, user: Union[Member, User, proxy_user], *, reason: str): - """ - Alias for invoking <prefix>talentpool add [user] [reason]. - """ - + async def nomination_add_alias(self, ctx: Context, user: Union[Member, User, proxy_user], *, reason: str) -> None: + """Alias for invoking <prefix>talentpool add [user] [reason].""" await self.invoke(ctx, "talentpool add", user, reason=reason) @command(name="unnominate", hidden=True) - async def nomination_end_alias(self, ctx, user: Union[User, proxy_user], *, reason: str): - """ - Alias for invoking <prefix>nomination end [user] [reason]. - """ - + async def nomination_end_alias(self, ctx: Context, user: Union[User, proxy_user], *, reason: str) -> None: + """Alias for invoking <prefix>nomination end [user] [reason].""" await self.invoke(ctx, "nomination end", user, reason=reason) -def setup(bot): +def setup(bot: Bot) -> None: + """Alias cog load.""" bot.add_cog(Alias(bot)) log.info("Cog loaded: Alias") diff --git a/bot/cogs/clean.py b/bot/cogs/clean.py index e7b6bac85..2c889c9f2 100644 --- a/bot/cogs/clean.py +++ b/bot/cogs/clean.py @@ -18,17 +18,13 @@ log = logging.getLogger(__name__) class Clean: """ - A cog that allows messages to be deleted in - bulk, while applying various filters. + A cog that allows messages to be deleted in bulk, while applying various filters. - You can delete messages sent by a specific user, - messages sent by bots, all messages, or messages - that match a specific regular expression. + You can delete messages sent by a specific user, messages sent by bots, all messages, or messages that match a + specific regular expression. - The deleted messages are saved and uploaded - to the database via an API endpoint, and a URL is - returned which can be used to view the messages - in the Discord dark theme style. + The deleted messages are saved and uploaded to the database via an API endpoint, and a URL is returned which can be + used to view the messages in the Discord dark theme style. """ def __init__(self, bot: Bot): @@ -37,44 +33,25 @@ class Clean: @property def mod_log(self) -> ModLog: + """Get currently loaded ModLog cog instance.""" return self.bot.get_cog("ModLog") async def _clean_messages( self, amount: int, ctx: Context, bots_only: bool = False, user: User = None, regex: Optional[str] = None - ): - """ - A helper function that does the actual message cleaning. - - :param bots_only: Set this to True if you only want to delete bot messages. - :param user: Specify a user and it will only delete messages by this user. - :param regular_expression: Specify a regular expression and it will only - delete messages that match this. - """ - + ) -> None: + """A helper function that does the actual message cleaning.""" def predicate_bots_only(message: Message) -> bool: - """ - Returns true if the message was sent by a bot - """ - + """Returns true if the message was sent by a bot.""" return message.author.bot def predicate_specific_user(message: Message) -> bool: - """ - Return True if the message was sent by the - user provided in the _clean_messages call. - """ - + """Return True if the message was sent by the user provided in the _clean_messages call.""" return message.author == user - def predicate_regex(message: Message): - """ - Returns True if the regex provided in the - _clean_messages matches the message content - or any embed attributes the message may have. - """ - + def predicate_regex(message: Message) -> bool: + """Check if the regex provided in _clean_messages matches the message content or any embed attributes.""" content = [message.content] # Add the content for all embed attributes @@ -191,61 +168,38 @@ class Clean: @group(invoke_without_command=True, name="clean", hidden=True) @with_role(*MODERATION_ROLES) - async def clean_group(self, ctx: Context): - """ - Commands for cleaning messages in channels - """ - + async def clean_group(self, ctx: Context) -> None: + """Commands for cleaning messages in channels.""" await ctx.invoke(self.bot.get_command("help"), "clean") @clean_group.command(name="user", aliases=["users"]) @with_role(*MODERATION_ROLES) - async def clean_user(self, ctx: Context, user: User, amount: int = 10): - """ - Delete messages posted by the provided user, - and stop cleaning after traversing `amount` messages. - """ - + async def clean_user(self, ctx: Context, user: User, amount: int = 10) -> None: + """Delete messages posted by the provided user, stop cleaning after traversing `amount` messages.""" await self._clean_messages(amount, ctx, user=user) @clean_group.command(name="all", aliases=["everything"]) @with_role(*MODERATION_ROLES) - async def clean_all(self, ctx: Context, amount: int = 10): - """ - Delete all messages, regardless of poster, - and stop cleaning after traversing `amount` messages. - """ - + async def clean_all(self, ctx: Context, amount: int = 10) -> None: + """Delete all messages, regardless of poster, stop cleaning after traversing `amount` messages.""" await self._clean_messages(amount, ctx) @clean_group.command(name="bots", aliases=["bot"]) @with_role(*MODERATION_ROLES) - async def clean_bots(self, ctx: Context, amount: int = 10): - """ - Delete all messages posted by a bot, - and stop cleaning after traversing `amount` messages. - """ - + async def clean_bots(self, ctx: Context, amount: int = 10) -> None: + """Delete all messages posted by a bot, stop cleaning after traversing `amount` messages.""" await self._clean_messages(amount, ctx, bots_only=True) @clean_group.command(name="regex", aliases=["word", "expression"]) @with_role(*MODERATION_ROLES) - async def clean_regex(self, ctx: Context, regex, amount: int = 10): - """ - Delete all messages that match a certain regex, - and stop cleaning after traversing `amount` messages. - """ - + async def clean_regex(self, ctx: Context, regex: str, amount: int = 10) -> None: + """Delete all messages that match a certain regex, stop cleaning after traversing `amount` messages.""" await self._clean_messages(amount, ctx, regex=regex) @clean_group.command(name="stop", aliases=["cancel", "abort"]) @with_role(*MODERATION_ROLES) - async def clean_cancel(self, ctx: Context): - """ - If there is an ongoing cleaning process, - attempt to immediately cancel it. - """ - + async def clean_cancel(self, ctx: Context) -> None: + """If there is an ongoing cleaning process, attempt to immediately cancel it.""" self.cleaning = False embed = Embed( @@ -255,6 +209,7 @@ class Clean: await ctx.send(embed=embed, delete_after=10) -def setup(bot): +def setup(bot: Bot) -> None: + """Clean cog load.""" bot.add_cog(Clean(bot)) log.info("Cog loaded: Clean") diff --git a/bot/cogs/cogs.py b/bot/cogs/cogs.py index 5bef52c0a..e6fa92927 100644 --- a/bot/cogs/cogs.py +++ b/bot/cogs/cogs.py @@ -16,9 +16,7 @@ KEEP_LOADED = ["bot.cogs.cogs", "bot.cogs.modlog"] class Cogs: - """ - Cog management commands - """ + """Cog management commands.""" def __init__(self, bot: Bot): self.bot = bot @@ -38,21 +36,19 @@ class Cogs: @group(name='cogs', aliases=('c',), invoke_without_command=True) @with_role(*MODERATION_ROLES, Roles.devops) - async def cogs_group(self, ctx: Context): + async def cogs_group(self, ctx: Context) -> None: """Load, unload, reload, and list active cogs.""" - await ctx.invoke(self.bot.get_command("help"), "cogs") @cogs_group.command(name='load', aliases=('l',)) @with_role(*MODERATION_ROLES, Roles.devops) - async def load_command(self, ctx: Context, cog: str): + async def load_command(self, ctx: Context, cog: str) -> None: """ - Load up an unloaded cog, given the module containing it + Load up an unloaded cog, given the module containing it. You can specify the cog name for any cogs that are placed directly within `!cogs`, or specify the entire module directly. """ - cog = cog.lower() embed = Embed() @@ -98,14 +94,13 @@ class Cogs: @cogs_group.command(name='unload', aliases=('ul',)) @with_role(*MODERATION_ROLES, Roles.devops) - async def unload_command(self, ctx: Context, cog: str): + async def unload_command(self, ctx: Context, cog: str) -> None: """ - Unload an already-loaded cog, given the module containing it + Unload an already-loaded cog, given the module containing it. You can specify the cog name for any cogs that are placed directly within `!cogs`, or specify the entire module directly. """ - cog = cog.lower() embed = Embed() @@ -150,9 +145,9 @@ class Cogs: @cogs_group.command(name='reload', aliases=('r',)) @with_role(*MODERATION_ROLES, Roles.devops) - async def reload_command(self, ctx: Context, cog: str): + async def reload_command(self, ctx: Context, cog: str) -> None: """ - Reload an unloaded cog, given the module containing it + Reload an unloaded cog, given the module containing it. You can specify the cog name for any cogs that are placed directly within `!cogs`, or specify the entire module directly. @@ -160,7 +155,6 @@ class Cogs: If you specify "*" as the cog, every cog currently loaded will be unloaded, and then every cog present in the bot/cogs directory will be loaded. """ - cog = cog.lower() embed = Embed() @@ -255,13 +249,12 @@ class Cogs: @cogs_group.command(name='list', aliases=('all',)) @with_role(*MODERATION_ROLES, Roles.devops) - async def list_command(self, ctx: Context): + async def list_command(self, ctx: Context) -> None: """ Get a list of all cogs, including their loaded status. Gray indicates that the cog is unloaded. Green indicates that the cog is currently loaded. """ - embed = Embed() lines = [] cogs = {} @@ -301,6 +294,7 @@ class Cogs: await LinePaginator.paginate(lines, ctx, embed, max_size=300, empty=False) -def setup(bot): +def setup(bot: Bot) -> None: + """Cogs cog load.""" bot.add_cog(Cogs(bot)) log.info("Cog loaded: Cogs") diff --git a/bot/cogs/deployment.py b/bot/cogs/deployment.py index e71e07c2f..e8e8ba677 100644 --- a/bot/cogs/deployment.py +++ b/bot/cogs/deployment.py @@ -10,27 +10,21 @@ log = logging.getLogger(__name__) class Deployment: - """ - Bot information commands - """ + """Bot information commands.""" def __init__(self, bot: Bot): self.bot = bot @group(name='redeploy', invoke_without_command=True) @with_role(*MODERATION_ROLES) - async def redeploy_group(self, ctx: Context): + async def redeploy_group(self, ctx: Context) -> None: """Redeploy the bot or the site.""" - await ctx.invoke(self.bot.get_command("help"), "redeploy") @redeploy_group.command(name='bot') @with_role(Roles.admin, Roles.owner, Roles.devops) - async def bot_command(self, ctx: Context): - """ - Trigger bot deployment on the server - will only redeploy if there were changes to deploy - """ - + async def bot_command(self, ctx: Context) -> None: + """Trigger bot deployment on the server - will only redeploy if there were changes to deploy.""" response = await self.bot.http_session.get(URLs.deploy, headers={"token": Keys.deploy_bot}) result = await response.text() @@ -43,11 +37,8 @@ class Deployment: @redeploy_group.command(name='site') @with_role(Roles.admin, Roles.owner, Roles.devops) - async def site_command(self, ctx: Context): - """ - Trigger website deployment on the server - will only redeploy if there were changes to deploy - """ - + async def site_command(self, ctx: Context) -> None: + """Trigger website deployment on the server - will only redeploy if there were changes to deploy.""" response = await self.bot.http_session.get(URLs.deploy, headers={"token": Keys.deploy_bot}) result = await response.text() @@ -60,11 +51,8 @@ class Deployment: @command(name='uptimes') @with_role(Roles.admin, Roles.owner, Roles.devops) - async def uptimes_command(self, ctx: Context): - """ - Check the various deployment uptimes for each service - """ - + async def uptimes_command(self, ctx: Context) -> None: + """Check the various deployment uptimes for each service.""" log.debug(f"{ctx.author} requested service uptimes.") response = await self.bot.http_session.get(URLs.status) data = await response.json() @@ -85,6 +73,7 @@ class Deployment: await ctx.send(embed=embed) -def setup(bot): +def setup(bot: Bot) -> None: + """Deployment cog load.""" bot.add_cog(Deployment(bot)) log.info("Cog loaded: Deployment") diff --git a/bot/cogs/information.py b/bot/cogs/information.py index a2585f395..3495f6181 100644 --- a/bot/cogs/information.py +++ b/bot/cogs/information.py @@ -18,11 +18,7 @@ log = logging.getLogger(__name__) class Information: - """ - A cog with commands for generating embeds with - server information, such as server statistics - and user information. - """ + """A cog with commands for generating embeds with server info, such as server stats and user info.""" def __init__(self, bot: Bot): self.bot = bot @@ -30,12 +26,8 @@ class Information: @with_role(*MODERATION_ROLES) @command(name="roles") - async def roles_info(self, ctx: Context): - """ - Returns a list of all roles and their - corresponding IDs. - """ - + async def roles_info(self, ctx: Context) -> None: + """Returns a list of all roles and their corresponding IDs.""" # Sort the roles alphabetically and remove the @everyone role roles = sorted(ctx.guild.roles, key=lambda role: role.name) roles = [role for role in roles if role.name != "@everyone"] @@ -57,12 +49,8 @@ class Information: await ctx.send(embed=embed) @command(name="server", aliases=["server_info", "guild", "guild_info"]) - async def server_info(self, ctx: Context): - """ - Returns an embed full of - server information. - """ - + async def server_info(self, ctx: Context) -> None: + """Returns an embed full of server information.""" created = time_since(ctx.guild.created_at, precision="days") features = ", ".join(ctx.guild.features) region = ctx.guild.region @@ -126,11 +114,8 @@ class Information: await ctx.send(embed=embed) @command(name="user", aliases=["user_info", "member", "member_info"]) - async def user_info(self, ctx: Context, user: Member = None, hidden: bool = False): - """ - Returns info about a user. - """ - + async def user_info(self, ctx: Context, user: Member = None, hidden: bool = False) -> None: + """Returns info about a user.""" # Do a role check if this is being executed on # someone other than the caller if user and user != ctx.author: @@ -210,7 +195,8 @@ class Information: await ctx.send(embed=embed) @user_info.error - async def user_info_command_error(self, ctx: Context, error: CommandError): + async def user_info_command_error(self, ctx: Context, error: CommandError) -> None: + """Info commands error handler.""" embed = Embed(colour=Colour.red()) if isinstance(error, BadArgument): @@ -227,6 +213,7 @@ class Information: log.exception(f"Unhandled error: {error}") -def setup(bot): +def setup(bot: Bot) -> None: + """Information cog load.""" bot.add_cog(Information(bot)) log.info("Cog loaded: Information") diff --git a/bot/cogs/modlog.py b/bot/cogs/modlog.py index 9f0c88424..d3ff406d8 100644 --- a/bot/cogs/modlog.py +++ b/bot/cogs/modlog.py @@ -29,9 +29,7 @@ ROLE_CHANGES_UNSUPPORTED = ("colour", "permissions") class ModLog: - """ - Logging for server events and staff actions - """ + """Logging for server events and staff actions.""" def __init__(self, bot: Bot): self.bot = bot @@ -42,14 +40,12 @@ class ModLog: async def upload_log(self, messages: List[Message], actor_id: int) -> Optional[str]: """ - Uploads the log data to the database via - an API endpoint for uploading logs. + Uploads the log data to the database via an API endpoint for uploading logs. Used in several mod log embeds. Returns a URL that can be used to view the log. """ - response = await self.bot.api_client.post( 'bot/deleted-messages', json={ @@ -70,7 +66,8 @@ class ModLog: return f"{URLs.site_logs_view}/{response['id']}" - def ignore(self, event: Event, *items: int): + def ignore(self, event: Event, *items: int) -> None: + """Add event to ignored events to suppress log emitting.""" for item in items: if item not in self._ignored[event]: self._ignored[event].append(item) @@ -90,7 +87,8 @@ class ModLog: additional_embeds_msg: Optional[str] = None, timestamp_override: Optional[datetime] = None, footer: Optional[str] = None, - ): + ) -> None: + """Generate log embed and send to logging channel.""" embed = Embed(description=text) if title and icon_url: @@ -122,7 +120,8 @@ class ModLog: return await self.bot.get_context(log_message) # Optionally return for use with antispam - async def on_guild_channel_create(self, channel: GUILD_CHANNEL): + async def on_guild_channel_create(self, channel: GUILD_CHANNEL) -> None: + """Log channel create event to mod log.""" if channel.guild.id != GuildConstant.id: return @@ -146,7 +145,8 @@ class ModLog: await self.send_log_message(Icons.hash_green, Colour(Colours.soft_green), title, message) - async def on_guild_channel_delete(self, channel: GUILD_CHANNEL): + async def on_guild_channel_delete(self, channel: GUILD_CHANNEL) -> None: + """Log channel delete event to mod log.""" if channel.guild.id != GuildConstant.id: return @@ -167,7 +167,8 @@ class ModLog: title, message ) - async def on_guild_channel_update(self, before: GUILD_CHANNEL, after: GuildChannel): + async def on_guild_channel_update(self, before: GUILD_CHANNEL, after: GuildChannel) -> None: + """Log channel update event to mod log.""" if before.guild.id != GuildConstant.id: return @@ -225,7 +226,8 @@ class ModLog: "Channel updated", message ) - async def on_guild_role_create(self, role: Role): + async def on_guild_role_create(self, role: Role) -> None: + """Log role create event to mod log.""" if role.guild.id != GuildConstant.id: return @@ -234,7 +236,8 @@ class ModLog: "Role created", f"`{role.id}`" ) - async def on_guild_role_delete(self, role: Role): + async def on_guild_role_delete(self, role: Role) -> None: + """Log role delete event to mod log.""" if role.guild.id != GuildConstant.id: return @@ -243,7 +246,8 @@ class ModLog: "Role removed", f"{role.name} (`{role.id}`)" ) - async def on_guild_role_update(self, before: Role, after: Role): + async def on_guild_role_update(self, before: Role, after: Role) -> None: + """Log role update event to mod log.""" if before.guild.id != GuildConstant.id: return @@ -294,7 +298,8 @@ class ModLog: "Role updated", message ) - async def on_guild_update(self, before: Guild, after: Guild): + async def on_guild_update(self, before: Guild, after: Guild) -> None: + """Log guild update event to mod log.""" if before.id != GuildConstant.id: return @@ -343,7 +348,8 @@ class ModLog: thumbnail=after.icon_url_as(format="png") ) - async def on_member_ban(self, guild: Guild, member: Union[Member, User]): + async def on_member_ban(self, guild: Guild, member: Union[Member, User]) -> None: + """Log ban event to mod log.""" if guild.id != GuildConstant.id: return @@ -358,7 +364,8 @@ class ModLog: channel_id=Channels.modlog ) - async def on_member_join(self, member: Member): + async def on_member_join(self, member: Member) -> None: + """Log member join event to user log.""" if member.guild.id != GuildConstant.id: return @@ -378,7 +385,8 @@ class ModLog: channel_id=Channels.userlog ) - async def on_member_remove(self, member: Member): + async def on_member_remove(self, member: Member) -> None: + """Log member leave event to user log.""" if member.guild.id != GuildConstant.id: return @@ -393,7 +401,8 @@ class ModLog: channel_id=Channels.userlog ) - async def on_member_unban(self, guild: Guild, member: User): + async def on_member_unban(self, guild: Guild, member: User) -> None: + """Log member unban event to mod log.""" if guild.id != GuildConstant.id: return @@ -408,7 +417,8 @@ class ModLog: channel_id=Channels.modlog ) - async def on_member_update(self, before: Member, after: Member): + async def on_member_update(self, before: Member, after: Member) -> None: + """Log member update event to user log.""" if before.guild.id != GuildConstant.id: return @@ -497,7 +507,8 @@ class ModLog: channel_id=Channels.userlog ) - async def on_message_delete(self, message: Message): + async def on_message_delete(self, message: Message) -> None: + """Log message delete event to message change log.""" channel = message.channel author = message.author @@ -548,7 +559,8 @@ class ModLog: channel_id=Channels.message_log ) - async def on_raw_message_delete(self, event: RawMessageDeleteEvent): + async def on_raw_message_delete(self, event: RawMessageDeleteEvent) -> None: + """Log raw message delete event to message change log.""" if event.guild_id != GuildConstant.id or event.channel_id in GuildConstant.ignored: return @@ -587,7 +599,8 @@ class ModLog: channel_id=Channels.message_log ) - async def on_message_edit(self, before: Message, after: Message): + async def on_message_edit(self, before: Message, after: Message) -> None: + """Log message edit event to message change log.""" if ( not before.guild or before.guild.id != GuildConstant.id @@ -660,7 +673,8 @@ class ModLog: channel_id=Channels.message_log, timestamp_override=after.edited_at ) - async def on_raw_message_edit(self, event: RawMessageUpdateEvent): + async def on_raw_message_edit(self, event: RawMessageUpdateEvent) -> None: + """Log raw message edit event to message change log.""" try: channel = self.bot.get_channel(int(event.data["channel_id"])) message = await channel.get_message(event.message_id) @@ -729,6 +743,7 @@ class ModLog: ) -def setup(bot): +def setup(bot: Bot) -> None: + """Mod log cog load.""" bot.add_cog(ModLog(bot)) log.info("Cog loaded: ModLog") diff --git a/bot/cogs/verification.py b/bot/cogs/verification.py index 56fcd63eb..2cc372afe 100644 --- a/bot/cogs/verification.py +++ b/bot/cogs/verification.py @@ -29,18 +29,18 @@ If you'd like to unsubscribe from the announcement notifications, simply send `! class Verification: - """ - User verification and role self-management - """ + """User verification and role self-management.""" def __init__(self, bot: Bot): self.bot = bot @property def mod_log(self) -> ModLog: + """Get currently loaded ModLog cog instance.""" return self.bot.get_cog("ModLog") - async def on_message(self, message: Message): + async def on_message(self, message: Message) -> None: + """Check new message event for messages to the checkpoint channel & process.""" if message.author.bot: return # They're a bot, ignore @@ -74,11 +74,8 @@ class Verification: @command(name='accept', aliases=('verify', 'verified', 'accepted'), hidden=True) @without_role(Roles.verified) @in_channel(Channels.verification) - async def accept_command(self, ctx: Context, *_): # We don't actually care about the args - """ - Accept our rules and gain access to the rest of the server - """ - + async def accept_command(self, ctx: Context, *_) -> None: # We don't actually care about the args + """Accept our rules and gain access to the rest of the server.""" log.debug(f"{ctx.author} called !accept. Assigning the 'Developer' role.") await ctx.author.add_roles(Object(Roles.verified), reason="Accepted the rules") try: @@ -97,11 +94,8 @@ class Verification: @command(name='subscribe') @in_channel(Channels.bot) - async def subscribe_command(self, ctx: Context, *_): # We don't actually care about the args - """ - Subscribe to announcement notifications by assigning yourself the role - """ - + async def subscribe_command(self, ctx: Context, *_) -> None: # We don't actually care about the args + """Subscribe to announcement notifications by assigning yourself the role.""" has_role = False for role in ctx.author.roles: @@ -125,11 +119,8 @@ class Verification: @command(name='unsubscribe') @in_channel(Channels.bot) - async def unsubscribe_command(self, ctx: Context, *_): # We don't actually care about the args - """ - Unsubscribe from announcement notifications by removing the role from yourself - """ - + async def unsubscribe_command(self, ctx: Context, *_) -> None: # We don't actually care about the args + """Unsubscribe from announcement notifications by removing the role from yourself.""" has_role = False for role in ctx.author.roles: @@ -152,17 +143,15 @@ class Verification: ) @staticmethod - def __global_check(ctx: Context): - """ - Block any command within the verification channel that is not !accept. - """ - + def __global_check(ctx: Context) -> None: + """Block any command within the verification channel that is not !accept.""" if ctx.channel.id == Channels.verification: return ctx.command.name == "accept" else: return True -def setup(bot): +def setup(bot: Bot) -> None: + """Verification cog load.""" bot.add_cog(Verification(bot)) log.info("Cog loaded: Verification") |