Skip to content

Commit 8db612b

Browse files
committed
formatting
1 parent 1a238b3 commit 8db612b

10 files changed

+249
-78
lines changed

Pipfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ isodate = "~=0.6.0"
1717
motor = "~=2.4.0"
1818
natural = "~=0.2.0"
1919
parsedatetime = "~=2.6"
20-
pymongo = {version = "*", extras = ['srv']} # Required by motor
20+
pymongo = {extras = ["srv"], version = "*"} # Required by motor
2121
python-dateutil = "~=2.8.1"
2222
python-dotenv = "~=0.18.0"
2323
uvloop = {version = ">=0.15.2", markers = "sys_platform != 'win32'"}

bot.py

+38-11
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,8 @@ def command_perm(self, command_name: str) -> PermissionLevel:
506506
logger.debug("Command %s not found.", command_name)
507507
return PermissionLevel.INVALID
508508
level = next(
509-
(check.permission_level for check in command.checks if hasattr(check, "permission_level")), None,
509+
(check.permission_level for check in command.checks if hasattr(check, "permission_level")),
510+
None,
510511
)
511512
if level is None:
512513
logger.debug("Command %s does not have a permission level.", command_name)
@@ -609,7 +610,13 @@ async def on_ready(self):
609610

610611
if self.config.get("data_collection"):
611612
self.metadata_loop = tasks.Loop(
612-
self.post_metadata, seconds=0, minutes=0, hours=1, count=None, reconnect=True, loop=None,
613+
self.post_metadata,
614+
seconds=0,
615+
minutes=0,
616+
hours=1,
617+
count=None,
618+
reconnect=True,
619+
loop=None,
613620
)
614621
self.metadata_loop.before_loop(self.before_post_metadata)
615622
self.metadata_loop.start()
@@ -762,7 +769,8 @@ def check_manual_blocked(self, author: discord.Member) -> bool:
762769
end_time = re.search(r"%([^%]+?)%", blocked_reason)
763770
if end_time is not None:
764771
logger.warning(
765-
r"Deprecated time message for user %s, block and unblock again to update.", author.name,
772+
r"Deprecated time message for user %s, block and unblock again to update.",
773+
author.name,
766774
)
767775

768776
if end_time is not None:
@@ -783,7 +791,11 @@ async def _process_blocked(self, message):
783791
return False
784792

785793
async def is_blocked(
786-
self, author: discord.User, *, channel: discord.TextChannel = None, send_message: bool = False,
794+
self,
795+
author: discord.User,
796+
*,
797+
channel: discord.TextChannel = None,
798+
send_message: bool = False,
787799
) -> typing.Tuple[bool, str]:
788800

789801
member = self.guild.get_member(author.id)
@@ -814,7 +826,9 @@ async def is_blocked(
814826
if send_message:
815827
await channel.send(
816828
embed=discord.Embed(
817-
title="Message not sent!", description=new_reason, color=self.error_color,
829+
title="Message not sent!",
830+
description=new_reason,
831+
color=self.error_color,
818832
)
819833
)
820834
return True
@@ -913,7 +927,8 @@ async def process_dm_modmail(self, message: discord.Message) -> None:
913927
description=self.config["disabled_current_thread_response"],
914928
)
915929
embed.set_footer(
916-
text=self.config["disabled_current_thread_footer"], icon_url=self.guild.icon_url,
930+
text=self.config["disabled_current_thread_footer"],
931+
icon_url=self.guild.icon_url,
917932
)
918933
logger.info("A message was blocked from %s due to disabled Modmail.", message.author)
919934
await self.add_reaction(message, blocked_emoji)
@@ -1274,14 +1289,18 @@ async def on_raw_reaction_add(self, payload):
12741289
await message.remove_reaction(payload.emoji, member)
12751290
await message.add_reaction(emoji_fmt) # bot adds as well
12761291

1277-
if self.config["dm_disabled"] in (DMDisabled.NEW_THREADS, DMDisabled.ALL_THREADS,):
1292+
if self.config["dm_disabled"] in (
1293+
DMDisabled.NEW_THREADS,
1294+
DMDisabled.ALL_THREADS,
1295+
):
12781296
embed = discord.Embed(
12791297
title=self.config["disabled_new_thread_title"],
12801298
color=self.error_color,
12811299
description=self.config["disabled_new_thread_response"],
12821300
)
12831301
embed.set_footer(
1284-
text=self.config["disabled_new_thread_footer"], icon_url=self.guild.icon_url,
1302+
text=self.config["disabled_new_thread_footer"],
1303+
icon_url=self.guild.icon_url,
12851304
)
12861305
logger.info(
12871306
"A new thread using react to contact was blocked from %s due to disabled Modmail.",
@@ -1340,7 +1359,9 @@ async def on_member_remove(self, member):
13401359
if thread:
13411360
if self.config["close_on_leave"]:
13421361
await thread.close(
1343-
closer=member.guild.me, message=self.config["close_on_leave_reason"], silent=True,
1362+
closer=member.guild.me,
1363+
message=self.config["close_on_leave_reason"],
1364+
silent=True,
13441365
)
13451366
else:
13461367
embed = discord.Embed(
@@ -1523,7 +1544,9 @@ async def autoupdate(self):
15231544
commit_data = data["data"]
15241545
user = data["user"]
15251546
embed.set_author(
1526-
name=user["username"] + " - Updating Bot", icon_url=user["avatar_url"], url=user["url"],
1547+
name=user["username"] + " - Updating Bot",
1548+
icon_url=user["avatar_url"],
1549+
url=user["url"],
15271550
)
15281551

15291552
embed.set_footer(text=f"Updating Modmail v{self.version} " f"-> v{latest.version}")
@@ -1552,7 +1575,11 @@ async def autoupdate(self):
15521575
pass
15531576

15541577
command = "git pull"
1555-
proc = await asyncio.create_subprocess_shell(command, stderr=PIPE, stdout=PIPE,)
1578+
proc = await asyncio.create_subprocess_shell(
1579+
command,
1580+
stderr=PIPE,
1581+
stdout=PIPE,
1582+
)
15561583
err = await proc.stderr.read()
15571584
err = err.decode("utf-8").rstrip()
15581585
res = await proc.stdout.read()

cogs/modmail.py

+61-23
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ async def setup(self, ctx):
5050

5151
if self.bot.modmail_guild is None:
5252
embed = discord.Embed(
53-
title="Error", description="Modmail functioning guild not found.", color=self.bot.error_color,
53+
title="Error",
54+
description="Modmail functioning guild not found.",
55+
color=self.bot.error_color,
5456
)
5557
return await ctx.send(embed=embed)
5658

@@ -182,7 +184,9 @@ async def snippet_raw(self, ctx, *, name: str.lower):
182184
else:
183185
val = truncate(escape_code_block(val), 2048 - 7)
184186
embed = discord.Embed(
185-
title=f'Raw snippet - "{name}":', description=f"```\n{val}```", color=self.bot.main_color,
187+
title=f'Raw snippet - "{name}":',
188+
description=f"```\n{val}```",
189+
color=self.bot.main_color,
186190
)
187191

188192
return await ctx.send(embed=embed)
@@ -204,7 +208,9 @@ async def snippet_add(self, ctx, name: str.lower, *, value: commands.clean_conte
204208
"""
205209
if name in self.bot.snippets:
206210
embed = discord.Embed(
207-
title="Error", color=self.bot.error_color, description=f"Snippet `{name}` already exists.",
211+
title="Error",
212+
color=self.bot.error_color,
213+
description=f"Snippet `{name}` already exists.",
208214
)
209215
return await ctx.send(embed=embed)
210216

@@ -228,7 +234,9 @@ async def snippet_add(self, ctx, name: str.lower, *, value: commands.clean_conte
228234
await self.bot.config.update()
229235

230236
embed = discord.Embed(
231-
title="Added snippet", color=self.bot.main_color, description="Successfully created snippet.",
237+
title="Added snippet",
238+
color=self.bot.main_color,
239+
description="Successfully created snippet.",
232240
)
233241
return await ctx.send(embed=embed)
234242

@@ -445,7 +453,8 @@ async def notify(self, ctx, *, user_or_role: Union[discord.Role, User, str.lower
445453

446454
if mention in mentions:
447455
embed = discord.Embed(
448-
color=self.bot.error_color, description=f"{mention} is already going to be mentioned.",
456+
color=self.bot.error_color,
457+
description=f"{mention} is already going to be mentioned.",
449458
)
450459
else:
451460
mentions.append(mention)
@@ -480,7 +489,8 @@ async def unnotify(self, ctx, *, user_or_role: Union[discord.Role, User, str.low
480489

481490
if mention not in mentions:
482491
embed = discord.Embed(
483-
color=self.bot.error_color, description=f"{mention} does not have a pending notification.",
492+
color=self.bot.error_color,
493+
description=f"{mention} does not have a pending notification.",
484494
)
485495
else:
486496
mentions.remove(mention)
@@ -516,7 +526,8 @@ async def subscribe(self, ctx, *, user_or_role: Union[discord.Role, User, str.lo
516526

517527
if mention in mentions:
518528
embed = discord.Embed(
519-
color=self.bot.error_color, description=f"{mention} is already subscribed to this thread.",
529+
color=self.bot.error_color,
530+
description=f"{mention} is already subscribed to this thread.",
520531
)
521532
else:
522533
mentions.append(mention)
@@ -551,13 +562,15 @@ async def unsubscribe(self, ctx, *, user_or_role: Union[discord.Role, User, str.
551562

552563
if mention not in mentions:
553564
embed = discord.Embed(
554-
color=self.bot.error_color, description=f"{mention} is not subscribed to this thread.",
565+
color=self.bot.error_color,
566+
description=f"{mention} is not subscribed to this thread.",
555567
)
556568
else:
557569
mentions.remove(mention)
558570
await self.bot.config.update()
559571
embed = discord.Embed(
560-
color=self.bot.main_color, description=f"{mention} is now unsubscribed from this thread.",
572+
color=self.bot.main_color,
573+
description=f"{mention} is now unsubscribed from this thread.",
561574
)
562575
return await ctx.send(embed=embed)
563576

@@ -684,7 +697,8 @@ async def logs(self, ctx, *, user: User = None):
684697

685698
if not any(not log["open"] for log in logs):
686699
embed = discord.Embed(
687-
color=self.bot.error_color, description="This user does not have any previous logs.",
700+
color=self.bot.error_color,
701+
description="This user does not have any previous logs.",
688702
)
689703
return await ctx.send(embed=embed)
690704

@@ -711,7 +725,8 @@ async def logs_closed_by(self, ctx, *, user: User = None):
711725

712726
if not embeds:
713727
embed = discord.Embed(
714-
color=self.bot.error_color, description="No log entries have been found for that query.",
728+
color=self.bot.error_color,
729+
description="No log entries have been found for that query.",
715730
)
716731
return await ctx.send(embed=embed)
717732

@@ -730,7 +745,9 @@ async def logs_delete(self, ctx, key_or_link: str):
730745

731746
if not success:
732747
embed = discord.Embed(
733-
title="Error", description=f"Log entry `{key}` not found.", color=self.bot.error_color,
748+
title="Error",
749+
description=f"Log entry `{key}` not found.",
750+
color=self.bot.error_color,
734751
)
735752
else:
736753
embed = discord.Embed(
@@ -783,7 +800,8 @@ async def logs_search(self, ctx, limit: Optional[int] = None, *, query):
783800

784801
if not embeds:
785802
embed = discord.Embed(
786-
color=self.bot.error_color, description="No log entries have been found for that query.",
803+
color=self.bot.error_color,
804+
description="No log entries have been found for that query.",
787805
)
788806
return await ctx.send(embed=embed)
789807

@@ -994,7 +1012,10 @@ async def contact(
9941012

9951013
else:
9961014
thread = await self.bot.threads.create(
997-
recipient=user, creator=ctx.author, category=category, manual_trigger=manual_trigger,
1015+
recipient=user,
1016+
creator=ctx.author,
1017+
category=category,
1018+
manual_trigger=manual_trigger,
9981019
)
9991020
if thread.cancelled:
10001021
return
@@ -1008,7 +1029,11 @@ async def contact(
10081029
else:
10091030
description = f"{ctx.author.name} has opened a Modmail thread."
10101031

1011-
em = discord.Embed(title="New Thread", description=description, color=self.bot.main_color,)
1032+
em = discord.Embed(
1033+
title="New Thread",
1034+
description=description,
1035+
color=self.bot.main_color,
1036+
)
10121037
if self.bot.config["show_timestamp"]:
10131038
em.timestamp = datetime.utcnow()
10141039
em.set_footer(icon_url=ctx.author.avatar_url)
@@ -1050,7 +1075,8 @@ async def blocked(self, ctx):
10501075
end_time = re.search(r"%([^%]+?)%", reason)
10511076
if end_time is not None:
10521077
logger.warning(
1053-
r"Deprecated time message for user %s, block and unblock again to update.", id_,
1078+
r"Deprecated time message for user %s, block and unblock again to update.",
1079+
id_,
10541080
)
10551081

10561082
if end_time is not None:
@@ -1081,7 +1107,8 @@ async def blocked(self, ctx):
10811107
end_time = re.search(r"%([^%]+?)%", reason)
10821108
if end_time is not None:
10831109
logger.warning(
1084-
r"Deprecated time message for role %s, block and unblock again to update.", id_,
1110+
r"Deprecated time message for role %s, block and unblock again to update.",
1111+
id_,
10851112
)
10861113

10871114
if end_time is not None:
@@ -1103,7 +1130,9 @@ async def blocked(self, ctx):
11031130
line = mention + f" - {reason or 'No Reason Provided'}\n"
11041131
if len(embed.description) + len(line) > 2048:
11051132
embed = discord.Embed(
1106-
title="Blocked Users (Continued)", color=self.bot.main_color, description=line,
1133+
title="Blocked Users (Continued)",
1134+
color=self.bot.main_color,
1135+
description=line,
11071136
)
11081137
embeds.append(embed)
11091138
else:
@@ -1120,7 +1149,9 @@ async def blocked(self, ctx):
11201149
line = mention + f" - {reason or 'No Reason Provided'}\n"
11211150
if len(embed.description) + len(line) > 2048:
11221151
embed = discord.Embed(
1123-
title="Blocked Roles (Continued)", color=self.bot.main_color, description=line,
1152+
title="Blocked Roles (Continued)",
1153+
color=self.bot.main_color,
1154+
description=line,
11241155
)
11251156
embeds.append(embed)
11261157
else:
@@ -1180,7 +1211,9 @@ async def blocked_whitelist(self, ctx, *, user: User = None):
11801211
)
11811212
else:
11821213
embed = discord.Embed(
1183-
title="Success", color=self.bot.main_color, description=f"{mention} is now whitelisted.",
1214+
title="Success",
1215+
color=self.bot.main_color,
1216+
description=f"{mention} is now whitelisted.",
11841217
)
11851218

11861219
return await ctx.send(embed=embed)
@@ -1258,7 +1291,9 @@ async def block(
12581291
)
12591292
else:
12601293
embed = discord.Embed(
1261-
title="Success", color=self.bot.main_color, description=f"{mention} is now blocked {reason}",
1294+
title="Success",
1295+
color=self.bot.main_color,
1296+
description=f"{mention} is now blocked {reason}",
12621297
)
12631298

12641299
if isinstance(user_or_role, discord.Role):
@@ -1321,7 +1356,9 @@ async def unblock(self, ctx, *, user_or_role: Union[User, Role] = None):
13211356
await self.bot.config.update()
13221357

13231358
embed = discord.Embed(
1324-
title="Success", color=self.bot.main_color, description=f"{mention} is no longer blocked.",
1359+
title="Success",
1360+
color=self.bot.main_color,
1361+
description=f"{mention} is no longer blocked.",
13251362
)
13261363
else:
13271364
embed = discord.Embed(
@@ -1378,7 +1415,8 @@ async def repair(self, ctx):
13781415

13791416
# Search cache for channel
13801417
user_id, thread = next(
1381-
((k, v) for k, v in self.bot.threads.cache.items() if v.channel == ctx.channel), (-1, None),
1418+
((k, v) for k, v in self.bot.threads.cache.items() if v.channel == ctx.channel),
1419+
(-1, None),
13821420
)
13831421
if thread is not None:
13841422
logger.debug("Found thread with tempered ID.")

0 commit comments

Comments
 (0)