Skip to content

Commit 1a238b3

Browse files
committed
Formatting and final updates to deps
1 parent 0056ad9 commit 1a238b3

File tree

10 files changed

+210
-340
lines changed

10 files changed

+210
-340
lines changed

Pipfile.lock

+133-92
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bot.py

+11-38
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,7 @@ 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")),
510-
None,
509+
(check.permission_level for check in command.checks if hasattr(check, "permission_level")), None,
511510
)
512511
if level is None:
513512
logger.debug("Command %s does not have a permission level.", command_name)
@@ -610,13 +609,7 @@ async def on_ready(self):
610609

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

776768
if end_time is not None:
@@ -791,11 +783,7 @@ async def _process_blocked(self, message):
791783
return False
792784

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

801789
member = self.guild.get_member(author.id)
@@ -826,9 +814,7 @@ async def is_blocked(
826814
if send_message:
827815
await channel.send(
828816
embed=discord.Embed(
829-
title="Message not sent!",
830-
description=new_reason,
831-
color=self.error_color,
817+
title="Message not sent!", description=new_reason, color=self.error_color,
832818
)
833819
)
834820
return True
@@ -927,8 +913,7 @@ async def process_dm_modmail(self, message: discord.Message) -> None:
927913
description=self.config["disabled_current_thread_response"],
928914
)
929915
embed.set_footer(
930-
text=self.config["disabled_current_thread_footer"],
931-
icon_url=self.guild.icon_url,
916+
text=self.config["disabled_current_thread_footer"], icon_url=self.guild.icon_url,
932917
)
933918
logger.info("A message was blocked from %s due to disabled Modmail.", message.author)
934919
await self.add_reaction(message, blocked_emoji)
@@ -1289,18 +1274,14 @@ async def on_raw_reaction_add(self, payload):
12891274
await message.remove_reaction(payload.emoji, member)
12901275
await message.add_reaction(emoji_fmt) # bot adds as well
12911276

1292-
if self.config["dm_disabled"] in (
1293-
DMDisabled.NEW_THREADS,
1294-
DMDisabled.ALL_THREADS,
1295-
):
1277+
if self.config["dm_disabled"] in (DMDisabled.NEW_THREADS, DMDisabled.ALL_THREADS,):
12961278
embed = discord.Embed(
12971279
title=self.config["disabled_new_thread_title"],
12981280
color=self.error_color,
12991281
description=self.config["disabled_new_thread_response"],
13001282
)
13011283
embed.set_footer(
1302-
text=self.config["disabled_new_thread_footer"],
1303-
icon_url=self.guild.icon_url,
1284+
text=self.config["disabled_new_thread_footer"], icon_url=self.guild.icon_url,
13041285
)
13051286
logger.info(
13061287
"A new thread using react to contact was blocked from %s due to disabled Modmail.",
@@ -1359,9 +1340,7 @@ async def on_member_remove(self, member):
13591340
if thread:
13601341
if self.config["close_on_leave"]:
13611342
await thread.close(
1362-
closer=member.guild.me,
1363-
message=self.config["close_on_leave_reason"],
1364-
silent=True,
1343+
closer=member.guild.me, message=self.config["close_on_leave_reason"], silent=True,
13651344
)
13661345
else:
13671346
embed = discord.Embed(
@@ -1544,9 +1523,7 @@ async def autoupdate(self):
15441523
commit_data = data["data"]
15451524
user = data["user"]
15461525
embed.set_author(
1547-
name=user["username"] + " - Updating Bot",
1548-
icon_url=user["avatar_url"],
1549-
url=user["url"],
1526+
name=user["username"] + " - Updating Bot", icon_url=user["avatar_url"], url=user["url"],
15501527
)
15511528

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

15771554
command = "git pull"
1578-
proc = await asyncio.create_subprocess_shell(
1579-
command,
1580-
stderr=PIPE,
1581-
stdout=PIPE,
1582-
)
1555+
proc = await asyncio.create_subprocess_shell(command, stderr=PIPE, stdout=PIPE,)
15831556
err = await proc.stderr.read()
15841557
err = err.decode("utf-8").rstrip()
15851558
res = await proc.stdout.read()

cogs/modmail.py

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

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

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

192188
return await ctx.send(embed=embed)
@@ -208,9 +204,7 @@ async def snippet_add(self, ctx, name: str.lower, *, value: commands.clean_conte
208204
"""
209205
if name in self.bot.snippets:
210206
embed = discord.Embed(
211-
title="Error",
212-
color=self.bot.error_color,
213-
description=f"Snippet `{name}` already exists.",
207+
title="Error", color=self.bot.error_color, description=f"Snippet `{name}` already exists.",
214208
)
215209
return await ctx.send(embed=embed)
216210

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

236230
embed = discord.Embed(
237-
title="Added snippet",
238-
color=self.bot.main_color,
239-
description="Successfully created snippet.",
231+
title="Added snippet", color=self.bot.main_color, description="Successfully created snippet.",
240232
)
241233
return await ctx.send(embed=embed)
242234

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

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

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

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

563552
if mention not in mentions:
564553
embed = discord.Embed(
565-
color=self.bot.error_color,
566-
description=f"{mention} is not subscribed to this thread.",
554+
color=self.bot.error_color, description=f"{mention} is not subscribed to this thread.",
567555
)
568556
else:
569557
mentions.remove(mention)
570558
await self.bot.config.update()
571559
embed = discord.Embed(
572-
color=self.bot.main_color,
573-
description=f"{mention} is now unsubscribed from this thread.",
560+
color=self.bot.main_color, description=f"{mention} is now unsubscribed from this thread.",
574561
)
575562
return await ctx.send(embed=embed)
576563

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

698685
if not any(not log["open"] for log in logs):
699686
embed = discord.Embed(
700-
color=self.bot.error_color,
701-
description="This user does not have any previous logs.",
687+
color=self.bot.error_color, description="This user does not have any previous logs.",
702688
)
703689
return await ctx.send(embed=embed)
704690

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

726712
if not embeds:
727713
embed = discord.Embed(
728-
color=self.bot.error_color,
729-
description="No log entries have been found for that query.",
714+
color=self.bot.error_color, description="No log entries have been found for that query.",
730715
)
731716
return await ctx.send(embed=embed)
732717

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

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

801784
if not embeds:
802785
embed = discord.Embed(
803-
color=self.bot.error_color,
804-
description="No log entries have been found for that query.",
786+
color=self.bot.error_color, description="No log entries have been found for that query.",
805787
)
806788
return await ctx.send(embed=embed)
807789

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

1013995
else:
1014996
thread = await self.bot.threads.create(
1015-
recipient=user,
1016-
creator=ctx.author,
1017-
category=category,
1018-
manual_trigger=manual_trigger,
997+
recipient=user, creator=ctx.author, category=category, manual_trigger=manual_trigger,
1019998
)
1020999
if thread.cancelled:
10211000
return
@@ -1029,11 +1008,7 @@ async def contact(
10291008
else:
10301009
description = f"{ctx.author.name} has opened a Modmail thread."
10311010

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

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

11141087
if end_time is not None:
@@ -1130,9 +1103,7 @@ async def blocked(self, ctx):
11301103
line = mention + f" - {reason or 'No Reason Provided'}\n"
11311104
if len(embed.description) + len(line) > 2048:
11321105
embed = discord.Embed(
1133-
title="Blocked Users (Continued)",
1134-
color=self.bot.main_color,
1135-
description=line,
1106+
title="Blocked Users (Continued)", color=self.bot.main_color, description=line,
11361107
)
11371108
embeds.append(embed)
11381109
else:
@@ -1149,9 +1120,7 @@ async def blocked(self, ctx):
11491120
line = mention + f" - {reason or 'No Reason Provided'}\n"
11501121
if len(embed.description) + len(line) > 2048:
11511122
embed = discord.Embed(
1152-
title="Blocked Roles (Continued)",
1153-
color=self.bot.main_color,
1154-
description=line,
1123+
title="Blocked Roles (Continued)", color=self.bot.main_color, description=line,
11551124
)
11561125
embeds.append(embed)
11571126
else:
@@ -1211,9 +1180,7 @@ async def blocked_whitelist(self, ctx, *, user: User = None):
12111180
)
12121181
else:
12131182
embed = discord.Embed(
1214-
title="Success",
1215-
color=self.bot.main_color,
1216-
description=f"{mention} is now whitelisted.",
1183+
title="Success", color=self.bot.main_color, description=f"{mention} is now whitelisted.",
12171184
)
12181185

12191186
return await ctx.send(embed=embed)
@@ -1291,9 +1258,7 @@ async def block(
12911258
)
12921259
else:
12931260
embed = discord.Embed(
1294-
title="Success",
1295-
color=self.bot.main_color,
1296-
description=f"{mention} is now blocked {reason}",
1261+
title="Success", color=self.bot.main_color, description=f"{mention} is now blocked {reason}",
12971262
)
12981263

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

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

14161379
# Search cache for channel
14171380
user_id, thread = next(
1418-
((k, v) for k, v in self.bot.threads.cache.items() if v.channel == ctx.channel),
1419-
(-1, None),
1381+
((k, v) for k, v in self.bot.threads.cache.items() if v.channel == ctx.channel), (-1, None),
14201382
)
14211383
if thread is not None:
14221384
logger.debug("Found thread with tempered ID.")

0 commit comments

Comments
 (0)