Skip to content

Commit

Permalink
style: format code with Black
Browse files Browse the repository at this point in the history
This commit fixes the style issues introduced in 5210a12 according to the output
from Black.

Details: None
  • Loading branch information
deepsource-autofix[bot] authored Nov 22, 2024
1 parent 5210a12 commit ecee655
Showing 1 changed file with 31 additions and 9 deletions.
40 changes: 31 additions & 9 deletions minato_namikaze/old_outdated/moderation.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,9 @@ async def tempban(
)

until = f'until {format_dt(duration.dt, "F")}'
heads_up_message = f"You have been banned from {ctx.guild.name} {until}. Reason: {reason}"
heads_up_message = (
f"You have been banned from {ctx.guild.name} {until}. Reason: {reason}"
)

try:
await member.send(heads_up_message) # type: ignore # Guarded by AttributeError
Expand Down Expand Up @@ -529,7 +531,9 @@ async def on_tempban_timer_complete(self, timer: Timer):
else:
moderator = f"{moderator} (ID: {mod_id})"

reason = f"Automatic unban from timer made on {timer.created_at} by {moderator}."
reason = (
f"Automatic unban from timer made on {timer.created_at} by {moderator}."
)
await guild.unban(discord.Object(id=member_id), reason=reason)

@commands.command()
Expand Down Expand Up @@ -659,7 +663,8 @@ async def massban(self, ctx: Context, *, args):

# member filters
predicates = [
lambda m: isinstance(m, discord.Member) and can_execute_action(ctx, author, m), # Only if applicable
lambda m: isinstance(m, discord.Member)
and can_execute_action(ctx, author, m), # Only if applicable
lambda m: not m.bot, # No bots
lambda m: m.discriminator != "0000", # No deleted users
]
Expand Down Expand Up @@ -703,7 +708,11 @@ def joined(member, *, offset=now - datetime.timedelta(minutes=args.joined)):
_joined_after_member = await converter.convert(ctx, str(args.joined_after))

def joined_after(member, *, _other=_joined_after_member):
return member.joined_at and _other.joined_at and member.joined_at > _other.joined_at
return (
member.joined_at
and _other.joined_at
and member.joined_at > _other.joined_at
)

predicates.append(joined_after)
if args.joined_before:
Expand All @@ -713,7 +722,11 @@ def joined_after(member, *, _other=_joined_after_member):
)

def joined_before(member, *, _other=_joined_before_member):
return member.joined_at and _other.joined_at and member.joined_at < _other.joined_at
return (
member.joined_at
and _other.joined_at
and member.joined_at < _other.joined_at
)

predicates.append(joined_before)

Expand All @@ -723,7 +736,10 @@ def joined_before(member, *, _other=_joined_before_member):

if args.show:
members = sorted(members, key=lambda m: m.joined_at or now)
fmt = "\n".join(f"{m.id}\tJoined: {m.joined_at}\tCreated: {m.created_at}\t{m}" for m in members)
fmt = "\n".join(
f"{m.id}\tJoined: {m.joined_at}\tCreated: {m.created_at}\t{m}"
for m in members
)
content = f"Current Time: {discord.utils.utcnow()}\nTotal members: {len(members)}\n{fmt}"
file = discord.File(
io.BytesIO(content.encode("utf-8")),
Expand Down Expand Up @@ -847,7 +863,9 @@ async def newusers(self, ctx: Context, *, count: int | None = 5):
if not ctx.guild.chunked:
members = await ctx.guild.chunk(cache=True)

members = sorted(ctx.guild.members, key=lambda m: m.joined_at, reverse=True)[:count]
members = sorted(ctx.guild.members, key=lambda m: m.joined_at, reverse=True)[
:count
]

embed = discord.Embed(title="New Members", colour=discord.Colour.green())

Expand Down Expand Up @@ -885,7 +903,9 @@ async def _regular_user_cleanup_strategy(self, ctx: Context, search):
prefixes = tuple(self.bot.get_guild_prefixes(ctx.guild))

def check(m):
return (m.author == ctx.me or m.content.startswith(prefixes)) and not (m.mentions or m.role_mentions)
return (m.author == ctx.me or m.content.startswith(prefixes)) and not (
m.mentions or m.role_mentions
)

deleted = await ctx.channel.purge(limit=search, check=check, before=ctx.message)
return Counter(m.author.display_name for m in deleted)
Expand Down Expand Up @@ -1065,7 +1085,9 @@ async def _bot(self, ctx: Context, prefix=None, search=100):
"""Removes a bot user's messages and messages with their optional prefix."""

def predicate(m):
return (m.webhook_id is None and m.author.bot) or (prefix and m.content.startswith(prefix))
return (m.webhook_id is None and m.author.bot) or (
prefix and m.content.startswith(prefix)
)

await self.do_removal(ctx, search, predicate)

Expand Down

0 comments on commit ecee655

Please sign in to comment.