@@ -82,8 +82,7 @@ async def _load(self, connection: Union[asyncpg.Connection, asyncpg.Pool]):
82
82
"""
83
83
rows = await connection .fetch (query )
84
84
return {
85
- row ["entity_id" ]: BlocklistEntity (bot = self .bot , ** dict (row ))
86
- for row in rows
85
+ row ["entity_id" ]: BlocklistEntity (bot = self .bot , ** dict (row )) for row in rows
87
86
}
88
87
89
88
async def load (self , connection : Optional [asyncpg .Connection ] = None ):
@@ -247,9 +246,7 @@ def __init__(self, entry: ConfigHelpEntry, **kwargs):
247
246
self .title = entry .key
248
247
self .description = entry .description
249
248
self .add_field (name = "Default" , value = entry .default , inline = False )
250
- self .add_field (
251
- name = "Example(s)" , value = "\n " .join (entry .examples ), inline = False
252
- )
249
+ self .add_field (name = "Example(s)" , value = "\n " .join (entry .examples ), inline = False )
253
250
self .add_field (
254
251
name = "Notes" ,
255
252
value = "\n " .join (f"- { note } " for note in entry .notes ) or None ,
@@ -278,9 +275,7 @@ def __init__(self, entries: dict[str, Any], active: Optional[bool] = None):
278
275
super ().__init__ (self .config_iterator (entries ), per_page = 20 )
279
276
self .active = active
280
277
281
- async def config_iterator (
282
- self , entries : dict [str , Any ]
283
- ) -> AsyncIterator [str ]:
278
+ async def config_iterator (self , entries : dict [str , Any ]) -> AsyncIterator [str ]:
284
279
for key , entry in entries .items ():
285
280
result = f"**{ key } :** { entry } "
286
281
# Wtf is wrong with me - Noelle
@@ -293,9 +288,7 @@ async def config_iterator(
293
288
294
289
async def format_page (self , menu : ConfigPages , entries : list [str ]):
295
290
pages = []
296
- for _ , entry in enumerate (
297
- entries , start = menu .current_page * self .per_page
298
- ):
291
+ for _ , entry in enumerate (entries , start = menu .current_page * self .per_page ):
299
292
pages .append (f"{ entry } " )
300
293
301
294
menu .embed .description = "\n " .join (pages )
@@ -311,9 +304,7 @@ def __init__(
311
304
active : Optional [bool ] = None ,
312
305
):
313
306
super ().__init__ (ConfigPageSource (entries , active ), ctx = ctx )
314
- self .embed = discord .Embed (
315
- colour = discord .Colour .from_rgb (200 , 168 , 255 )
316
- )
307
+ self .embed = discord .Embed (colour = discord .Colour .from_rgb (200 , 168 , 255 ))
317
308
318
309
319
310
class ConfigOptionFlags (commands .FlagConverter ):
@@ -354,9 +345,7 @@ async def convert(self, ctx: GuildContext, argument: str) -> str:
354
345
raise RuntimeError ("Unable to get Config cog" )
355
346
356
347
if lowered not in cog .config_keys :
357
- raise commands .BadArgument (
358
- self .disambiguate (lowered , cog .config_keys )
359
- )
348
+ raise commands .BadArgument (self .disambiguate (lowered , cog .config_keys ))
360
349
361
350
return lowered
362
351
@@ -380,9 +369,7 @@ class PrefixConverter(commands.Converter):
380
369
async def convert (self , ctx : GuildContext , argument : str ):
381
370
user_id = ctx .bot .user .id # type: ignore # Already logged in by this time
382
371
if argument .startswith ((f"<@{ user_id } >" , f"<@!{ user_id } >" , "r>" )):
383
- raise commands .BadArgument (
384
- "That is a reserved prefix already in use."
385
- )
372
+ raise commands .BadArgument ("That is a reserved prefix already in use." )
386
373
if len (argument ) > 100 :
387
374
raise commands .BadArgument ("That prefix is too long." )
388
375
return argument
@@ -425,10 +412,10 @@ async def get_guild_config(self, guild_id: int) -> Optional[GuildConfig]:
425
412
return config
426
413
427
414
@alru_cache ()
428
- async def get_guild_settings (
429
- self , guild_id : int
430
- ) -> Optional [ GuildSettings ]:
431
- query = "SELECT account_age, guild_age, settings FROM guild_config WHERE id = $1;"
415
+ async def get_guild_settings (self , guild_id : int ) -> Optional [ GuildSettings ]:
416
+ query = (
417
+ "SELECT account_age, guild_age, settings FROM guild_config WHERE id = $1;"
418
+ )
432
419
rows = await self .pool .fetchrow (query , guild_id )
433
420
if rows is None :
434
421
self .get_guild_settings .cache_invalidate (guild_id )
@@ -460,9 +447,7 @@ async def set_guild_settings(
460
447
config_type : ConfigType ,
461
448
ctx : GuildContext ,
462
449
):
463
- current_guild_settings = await self .get_partial_guild_settings (
464
- ctx .guild .id
465
- )
450
+ current_guild_settings = await self .get_partial_guild_settings (ctx .guild .id )
466
451
467
452
# If there are no guild configurations, then we have an issue here
468
453
# we will denote this with an error
@@ -488,20 +473,12 @@ async def set_guild_settings(
488
473
self .get_partial_guild_settings .cache_invalidate (ctx .guild .id )
489
474
490
475
command_type = "Toggled" if config_type == ConfigType .TOGGLE else "Set"
491
- await ctx .send (
492
- f"{ command_type } `{ key } ` from `{ original_value } ` to `{ value } `"
493
- )
476
+ await ctx .send (f"{ command_type } `{ key } ` from `{ original_value } ` to `{ value } `" )
494
477
495
478
### Blocklist utilities
496
479
497
- async def can_be_blocked (
498
- self , ctx : GuildContext , entity : discord .Member
499
- ) -> bool :
500
- if (
501
- entity .id == ctx .author .id
502
- or await self .bot .is_owner (entity )
503
- or entity .bot
504
- ):
480
+ async def can_be_blocked (self , ctx : GuildContext , entity : discord .Member ) -> bool :
481
+ if entity .id == ctx .author .id or await self .bot .is_owner (entity ) or entity .bot :
505
482
return False
506
483
507
484
# Hierarchy check
@@ -602,7 +579,9 @@ async def setup(self, ctx: GuildContext, *, flags: SetupFlags) -> None:
602
579
manage_threads = True ,
603
580
),
604
581
}
605
- lgc_reason = f"{ ctx .author } (ID: { ctx .author .id } ) has created the Rodhaj logs channel"
582
+ lgc_reason = (
583
+ f"{ ctx .author } (ID: { ctx .author .id } ) has created the Rodhaj logs channel"
584
+ )
606
585
607
586
# The rationale behind the restriction of posts is to make sure that
608
587
# people don't create posts of their own, thus messing up the code for the bot
@@ -626,9 +605,7 @@ async def setup(self, ctx: GuildContext, *, flags: SetupFlags) -> None:
626
605
),
627
606
discord .ForumTag (
628
607
name = "Serious" ,
629
- emoji = discord .PartialEmoji (
630
- name = "\U0001f610 "
631
- ), # U+1F610 Neutral Face
608
+ emoji = discord .PartialEmoji (name = "\U0001f610 " ), # U+1F610 Neutral Face
632
609
),
633
610
discord .ForumTag (
634
611
name = "Private" ,
@@ -732,7 +709,9 @@ async def delete(self, ctx: GuildContext) -> None:
732
709
confirm = await ctx .prompt (msg , timeout = 300.0 , delete_after = True )
733
710
if confirm :
734
711
if guild_config is None :
735
- msg = "Could not find the guild config. Perhaps Rodhaj is not set up yet?"
712
+ msg = (
713
+ "Could not find the guild config. Perhaps Rodhaj is not set up yet?"
714
+ )
736
715
await ctx .send (msg )
737
716
return
738
717
@@ -809,9 +788,7 @@ async def config_options(
809
788
await ctx .send (msg )
810
789
return
811
790
812
- pages = ConfigPages (
813
- guild_settings .to_dict (), ctx = ctx , active = flags .active
814
- )
791
+ pages = ConfigPages (guild_settings .to_dict (), ctx = ctx , active = flags .active )
815
792
await pages .start ()
816
793
817
794
@is_manager ()
@@ -823,9 +800,7 @@ async def config_help(
823
800
) -> None :
824
801
"""Shows help information for different configuration options"""
825
802
# Because we are using the converter, all options are guaranteed to be correct
826
- embed = ConfigEntryEmbed (
827
- ConfigHelpEntry (key = key , ** self .options_help [key ])
828
- )
803
+ embed = ConfigEntryEmbed (ConfigHelpEntry (key = key , ** self .options_help [key ]))
829
804
await ctx .send (embed = embed )
830
805
831
806
@is_manager ()
@@ -908,9 +883,7 @@ async def config_set(
908
883
)
909
884
return
910
885
911
- await self .set_guild_settings (
912
- key , value , config_type = ConfigType .SET , ctx = ctx
913
- )
886
+ await self .set_guild_settings (key , value , config_type = ConfigType .SET , ctx = ctx )
914
887
915
888
@is_manager ()
916
889
@commands .guild_only ()
@@ -1044,9 +1017,7 @@ async def prefix_edit(
1044
1017
get_prefix .cache_invalidate (self .bot , ctx .message )
1045
1018
await ctx .send (f"Prefix updated to from `{ old } ` to `{ new } `" )
1046
1019
else :
1047
- await ctx .send (
1048
- "The prefix is not in the list of prefixes for your server"
1049
- )
1020
+ await ctx .send ("The prefix is not in the list of prefixes for your server" )
1050
1021
1051
1022
@is_manager ()
1052
1023
@commands .guild_only ()
@@ -1066,9 +1037,7 @@ async def prefix_delete(
1066
1037
if confirm :
1067
1038
await self .pool .execute (query , prefix , ctx .guild .id )
1068
1039
get_prefix .cache_invalidate (self .bot , ctx .message )
1069
- await ctx .send (
1070
- f"The prefix `{ prefix } ` has been successfully deleted"
1071
- )
1040
+ await ctx .send (f"The prefix `{ prefix } ` has been successfully deleted" )
1072
1041
elif confirm is None :
1073
1042
await ctx .send ("Confirmation timed out. Cancelled deletion..." )
1074
1043
else :
@@ -1081,9 +1050,7 @@ async def prefix_delete(
1081
1050
# 4. Is the author themselves trying to get blocklisted?
1082
1051
# This system must be addressed with care as it is extremely dangerous
1083
1052
# TODO: Add an history command to view past history of entity
1084
- @check_permissions (
1085
- manage_messages = True , manage_roles = True , moderate_members = True
1086
- )
1053
+ @check_permissions (manage_messages = True , manage_roles = True , moderate_members = True )
1087
1054
@commands .guild_only ()
1088
1055
@commands .hybrid_group (name = "blocklist" , fallback = "info" )
1089
1056
async def blocklist (self , ctx : GuildContext ) -> None :
@@ -1092,9 +1059,7 @@ async def blocklist(self, ctx: GuildContext) -> None:
1092
1059
pages = BlocklistPages ([entry for entry in blocklist .values ()], ctx = ctx )
1093
1060
await pages .start ()
1094
1061
1095
- @check_permissions (
1096
- manage_messages = True , manage_roles = True , moderate_members = True
1097
- )
1062
+ @check_permissions (manage_messages = True , manage_roles = True , moderate_members = True )
1098
1063
@commands .guild_only ()
1099
1064
@blocklist .command (name = "add" )
1100
1065
@app_commands .describe (
@@ -1155,15 +1120,11 @@ async def blocklist_add(
1155
1120
)
1156
1121
await ctx .send (f"{ entity .mention } has been blocked" )
1157
1122
1158
- @check_permissions (
1159
- manage_messages = True , manage_roles = True , moderate_members = True
1160
- )
1123
+ @check_permissions (manage_messages = True , manage_roles = True , moderate_members = True )
1161
1124
@commands .guild_only ()
1162
1125
@blocklist .command (name = "remove" )
1163
1126
@app_commands .describe (entity = "The member to remove from the blocklist" )
1164
- async def blocklist_remove (
1165
- self , ctx : GuildContext , entity : discord .Member
1166
- ) -> None :
1127
+ async def blocklist_remove (self , ctx : GuildContext , entity : discord .Member ) -> None :
1167
1128
"""Removes an member from the blocklist"""
1168
1129
if not await self .can_be_blocked (ctx , entity ):
1169
1130
await ctx .send ("Failed to unblock entity" )
0 commit comments