diff options
author | 2019-10-02 11:55:55 -0700 | |
---|---|---|
committer | 2019-10-02 11:55:55 -0700 | |
commit | d92bc6ec7b0123d098c17ed6c13cbc6497fd0032 (patch) | |
tree | f593175cba93ae1a4bd709e2ccfd6fb2391d01ba | |
parent | Format duration units as a list in management doctsrings (diff) |
Rename parameters to stop shadowing type built-in
Co-Authored-By: scragly <[email protected]>
-rw-r--r-- | bot/cogs/moderation/superstarify.py | 7 | ||||
-rw-r--r-- | bot/cogs/moderation/utils.py | 12 | ||||
-rw-r--r-- | bot/cogs/watchchannels/bigbrother.py | 6 |
3 files changed, 10 insertions, 15 deletions
diff --git a/bot/cogs/moderation/superstarify.py b/bot/cogs/moderation/superstarify.py index ccd163a88..6e7e41c17 100644 --- a/bot/cogs/moderation/superstarify.py +++ b/bot/cogs/moderation/superstarify.py @@ -157,11 +157,8 @@ class Superstarify(Cog): if await utils.has_active_infraction(ctx, member, "superstar"): return - infraction = await utils.post_infraction( - ctx, member, - type='superstar', reason=reason or ('old nick: ' + member.display_name), - expires_at=expiration - ) + reason = reason or ('old nick: ' + member.display_name) + infraction = await utils.post_infraction(ctx, member, 'superstar', reason, expires_at=expiration) forced_nick = self.get_nick(infraction['id'], member.id) expiry_str = format_infraction(infraction["expires_at"]) diff --git a/bot/cogs/moderation/utils.py b/bot/cogs/moderation/utils.py index c8d350b99..e9c879b46 100644 --- a/bot/cogs/moderation/utils.py +++ b/bot/cogs/moderation/utils.py @@ -49,7 +49,7 @@ def proxy_user(user_id: str) -> discord.Object: async def post_infraction( ctx: Context, user: MemberObject, - type: str, + infr_type: str, reason: str, expires_at: datetime = None, hidden: bool = False, @@ -60,7 +60,7 @@ async def post_infraction( "actor": ctx.message.author.id, "hidden": hidden, "reason": reason, - "type": type, + "type": infr_type, "user": user.id, "active": active } @@ -72,7 +72,7 @@ async def post_infraction( except ResponseCodeError as exp: if exp.status == 400 and 'user' in exp.response_json: log.info( - f"{ctx.author} tried to add a {type} infraction to `{user.id}`, " + f"{ctx.author} tried to add a {infr_type} infraction to `{user.id}`, " "but that user id was not found in the database." ) await ctx.send( @@ -87,19 +87,19 @@ async def post_infraction( return response -async def has_active_infraction(ctx: Context, user: MemberObject, type: str) -> bool: +async def has_active_infraction(ctx: Context, user: MemberObject, infr_type: str) -> bool: """Checks if a user already has an active infraction of the given type.""" active_infractions = await ctx.bot.api_client.get( 'bot/infractions', params={ 'active': 'true', - 'type': type, + 'type': infr_type, 'user__id': str(user.id) } ) if active_infractions: await ctx.send( - f":x: According to my records, this user already has a {type} infraction. " + f":x: According to my records, this user already has a {infr_type} infraction. " f"See infraction **#{active_infractions[0]['id']}**." ) return True diff --git a/bot/cogs/watchchannels/bigbrother.py b/bot/cogs/watchchannels/bigbrother.py index c332d80b9..bfbb86a97 100644 --- a/bot/cogs/watchchannels/bigbrother.py +++ b/bot/cogs/watchchannels/bigbrother.py @@ -64,9 +64,7 @@ class BigBrother(WatchChannel, Cog, name="Big Brother"): await ctx.send(":x: The specified user is already being watched.") return - response = await post_infraction( - ctx, user, type='watch', reason=reason, hidden=True - ) + response = await post_infraction(ctx, user, 'watch', reason, hidden=True) if response is not None: self.watched_users[user.id] = response @@ -91,7 +89,7 @@ class BigBrother(WatchChannel, Cog, name="Big Brother"): json={'active': False} ) - await post_infraction(ctx, user, type='watch', reason=f"Unwatched: {reason}", hidden=True, active=False) + await post_infraction(ctx, user, 'watch', f"Unwatched: {reason}", hidden=True, active=False) await ctx.send(f":white_check_mark: Messages sent by {user} will no longer be relayed.") |