@@ -82,7 +82,8 @@ 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 )) for row in rows
85
+ row ["entity_id" ]: BlocklistEntity (bot = self .bot , ** dict (row ))
86
+ for row in rows
86
87
}
87
88
88
89
async def load (self , connection : Optional [asyncpg .Connection ] = None ):
@@ -246,7 +247,9 @@ def __init__(self, entry: ConfigHelpEntry, **kwargs):
246
247
self .title = entry .key
247
248
self .description = entry .description
248
249
self .add_field (name = "Default" , value = entry .default , inline = False )
249
- self .add_field (name = "Example(s)" , value = "\n " .join (entry .examples ), inline = False )
250
+ self .add_field (
251
+ name = "Example(s)" , value = "\n " .join (entry .examples ), inline = False
252
+ )
250
253
self .add_field (
251
254
name = "Notes" ,
252
255
value = "\n " .join (f"- { note } " for note in entry .notes ) or None ,
@@ -275,7 +278,9 @@ def __init__(self, entries: dict[str, Any], active: Optional[bool] = None):
275
278
super ().__init__ (self .config_iterator (entries ), per_page = 20 )
276
279
self .active = active
277
280
278
- async def config_iterator (self , entries : dict [str , Any ]) -> AsyncIterator [str ]:
281
+ async def config_iterator (
282
+ self , entries : dict [str , Any ]
283
+ ) -> AsyncIterator [str ]:
279
284
for key , entry in entries .items ():
280
285
result = f"**{ key } :** { entry } "
281
286
# Wtf is wrong with me - Noelle
@@ -288,7 +293,9 @@ async def config_iterator(self, entries: dict[str, Any]) -> AsyncIterator[str]:
288
293
289
294
async def format_page (self , menu : ConfigPages , entries : list [str ]):
290
295
pages = []
291
- for _ , entry in enumerate (entries , start = menu .current_page * self .per_page ):
296
+ for _ , entry in enumerate (
297
+ entries , start = menu .current_page * self .per_page
298
+ ):
292
299
pages .append (f"{ entry } " )
293
300
294
301
menu .embed .description = "\n " .join (pages )
@@ -304,7 +311,9 @@ def __init__(
304
311
active : Optional [bool ] = None ,
305
312
):
306
313
super ().__init__ (ConfigPageSource (entries , active ), ctx = ctx )
307
- self .embed = discord .Embed (colour = discord .Colour .from_rgb (200 , 168 , 255 ))
314
+ self .embed = discord .Embed (
315
+ colour = discord .Colour .from_rgb (200 , 168 , 255 )
316
+ )
308
317
309
318
310
319
class ConfigOptionFlags (commands .FlagConverter ):
@@ -345,7 +354,9 @@ async def convert(self, ctx: GuildContext, argument: str) -> str:
345
354
raise RuntimeError ("Unable to get Config cog" )
346
355
347
356
if lowered not in cog .config_keys :
348
- raise commands .BadArgument (self .disambiguate (lowered , cog .config_keys ))
357
+ raise commands .BadArgument (
358
+ self .disambiguate (lowered , cog .config_keys )
359
+ )
349
360
350
361
return lowered
351
362
@@ -369,7 +380,9 @@ class PrefixConverter(commands.Converter):
369
380
async def convert (self , ctx : GuildContext , argument : str ):
370
381
user_id = ctx .bot .user .id # type: ignore # Already logged in by this time
371
382
if argument .startswith ((f"<@{ user_id } >" , f"<@!{ user_id } >" , "r>" )):
372
- raise commands .BadArgument ("That is a reserved prefix already in use." )
383
+ raise commands .BadArgument (
384
+ "That is a reserved prefix already in use."
385
+ )
373
386
if len (argument ) > 100 :
374
387
raise commands .BadArgument ("That prefix is too long." )
375
388
return argument
@@ -412,10 +425,10 @@ async def get_guild_config(self, guild_id: int) -> Optional[GuildConfig]:
412
425
return config
413
426
414
427
@alru_cache ()
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
- )
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;"
419
432
rows = await self .pool .fetchrow (query , guild_id )
420
433
if rows is None :
421
434
self .get_guild_settings .cache_invalidate (guild_id )
@@ -447,7 +460,9 @@ async def set_guild_settings(
447
460
config_type : ConfigType ,
448
461
ctx : GuildContext ,
449
462
):
450
- current_guild_settings = await self .get_partial_guild_settings (ctx .guild .id )
463
+ current_guild_settings = await self .get_partial_guild_settings (
464
+ ctx .guild .id
465
+ )
451
466
452
467
# If there are no guild configurations, then we have an issue here
453
468
# we will denote this with an error
@@ -473,12 +488,20 @@ async def set_guild_settings(
473
488
self .get_partial_guild_settings .cache_invalidate (ctx .guild .id )
474
489
475
490
command_type = "Toggled" if config_type == ConfigType .TOGGLE else "Set"
476
- await ctx .send (f"{ command_type } `{ key } ` from `{ original_value } ` to `{ value } `" )
491
+ await ctx .send (
492
+ f"{ command_type } `{ key } ` from `{ original_value } ` to `{ value } `"
493
+ )
477
494
478
495
### Blocklist utilities
479
496
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 :
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
+ ):
482
505
return False
483
506
484
507
# Hierarchy check
@@ -579,9 +602,7 @@ async def setup(self, ctx: GuildContext, *, flags: SetupFlags) -> None:
579
602
manage_threads = True ,
580
603
),
581
604
}
582
- lgc_reason = (
583
- f"{ ctx .author } (ID: { ctx .author .id } ) has created the Rodhaj logs channel"
584
- )
605
+ lgc_reason = f"{ ctx .author } (ID: { ctx .author .id } ) has created the Rodhaj logs channel"
585
606
586
607
# The rationale behind the restriction of posts is to make sure that
587
608
# people don't create posts of their own, thus messing up the code for the bot
@@ -605,7 +626,9 @@ async def setup(self, ctx: GuildContext, *, flags: SetupFlags) -> None:
605
626
),
606
627
discord .ForumTag (
607
628
name = "Serious" ,
608
- emoji = discord .PartialEmoji (name = "\U0001f610 " ), # U+1F610 Neutral Face
629
+ emoji = discord .PartialEmoji (
630
+ name = "\U0001f610 "
631
+ ), # U+1F610 Neutral Face
609
632
),
610
633
discord .ForumTag (
611
634
name = "Private" ,
@@ -635,7 +658,9 @@ async def setup(self, ctx: GuildContext, *, flags: SetupFlags) -> None:
635
658
name = "rodhaj" , overwrites = rodhaj_overwrites , position = 0
636
659
)
637
660
logging_channel = await rodhaj_category .create_text_channel (
638
- name = flags .log_name or "rodhaj-logs" , reason = lgc_reason , position = 0
661
+ name = flags .log_name or "rodhaj-logs" ,
662
+ reason = lgc_reason ,
663
+ position = 0 ,
639
664
)
640
665
lgc_webhook = await logging_channel .create_webhook (
641
666
name = "Rodhaj Ticket Logs" , avatar = avatar_bytes
@@ -707,9 +732,7 @@ async def delete(self, ctx: GuildContext) -> None:
707
732
confirm = await ctx .prompt (msg , timeout = 300.0 , delete_after = True )
708
733
if confirm :
709
734
if guild_config is None :
710
- msg = (
711
- "Could not find the guild config. Perhaps Rodhaj is not set up yet?"
712
- )
735
+ msg = "Could not find the guild config. Perhaps Rodhaj is not set up yet?"
713
736
await ctx .send (msg )
714
737
return
715
738
@@ -786,7 +809,9 @@ async def config_options(
786
809
await ctx .send (msg )
787
810
return
788
811
789
- pages = ConfigPages (guild_settings .to_dict (), ctx = ctx , active = flags .active )
812
+ pages = ConfigPages (
813
+ guild_settings .to_dict (), ctx = ctx , active = flags .active
814
+ )
790
815
await pages .start ()
791
816
792
817
@is_manager ()
@@ -798,7 +823,9 @@ async def config_help(
798
823
) -> None :
799
824
"""Shows help information for different configuration options"""
800
825
# Because we are using the converter, all options are guaranteed to be correct
801
- embed = ConfigEntryEmbed (ConfigHelpEntry (key = key , ** self .options_help [key ]))
826
+ embed = ConfigEntryEmbed (
827
+ ConfigHelpEntry (key = key , ** self .options_help [key ])
828
+ )
802
829
await ctx .send (embed = embed )
803
830
804
831
@is_manager ()
@@ -829,7 +856,8 @@ async def config_set_age(
829
856
type : Literal ["guild" , "account" ],
830
857
* ,
831
858
duration : Annotated [
832
- FriendlyTimeResult , UserFriendlyTime (commands .clean_content , default = "…" )
859
+ FriendlyTimeResult ,
860
+ UserFriendlyTime (commands .clean_content , default = "…" ),
833
861
],
834
862
) -> None :
835
863
"""Sets an minimum duration for age-related options
@@ -880,7 +908,9 @@ async def config_set(
880
908
)
881
909
return
882
910
883
- await self .set_guild_settings (key , value , config_type = ConfigType .SET , ctx = ctx )
911
+ await self .set_guild_settings (
912
+ key , value , config_type = ConfigType .SET , ctx = ctx
913
+ )
884
914
885
915
@is_manager ()
886
916
@commands .guild_only ()
@@ -890,7 +920,11 @@ async def config_set(
890
920
value = "Boolean option to set the configuration" ,
891
921
)
892
922
async def config_toggle (
893
- self , ctx : GuildContext , key : Annotated [str , ConfigKeyConverter ], * , value : bool
923
+ self ,
924
+ ctx : GuildContext ,
925
+ key : Annotated [str , ConfigKeyConverter ],
926
+ * ,
927
+ value : bool ,
894
928
) -> None :
895
929
"""Toggles an boolean option for configuration
896
930
@@ -1010,7 +1044,9 @@ async def prefix_edit(
1010
1044
get_prefix .cache_invalidate (self .bot , ctx .message )
1011
1045
await ctx .send (f"Prefix updated to from `{ old } ` to `{ new } `" )
1012
1046
else :
1013
- await ctx .send ("The prefix is not in the list of prefixes for your server" )
1047
+ await ctx .send (
1048
+ "The prefix is not in the list of prefixes for your server"
1049
+ )
1014
1050
1015
1051
@is_manager ()
1016
1052
@commands .guild_only ()
@@ -1030,7 +1066,9 @@ async def prefix_delete(
1030
1066
if confirm :
1031
1067
await self .pool .execute (query , prefix , ctx .guild .id )
1032
1068
get_prefix .cache_invalidate (self .bot , ctx .message )
1033
- await ctx .send (f"The prefix `{ prefix } ` has been successfully deleted" )
1069
+ await ctx .send (
1070
+ f"The prefix `{ prefix } ` has been successfully deleted"
1071
+ )
1034
1072
elif confirm is None :
1035
1073
await ctx .send ("Confirmation timed out. Cancelled deletion..." )
1036
1074
else :
@@ -1043,7 +1081,9 @@ async def prefix_delete(
1043
1081
# 4. Is the author themselves trying to get blocklisted?
1044
1082
# This system must be addressed with care as it is extremely dangerous
1045
1083
# TODO: Add an history command to view past history of entity
1046
- @check_permissions (manage_messages = True , manage_roles = True , moderate_members = True )
1084
+ @check_permissions (
1085
+ manage_messages = True , manage_roles = True , moderate_members = True
1086
+ )
1047
1087
@commands .guild_only ()
1048
1088
@commands .hybrid_group (name = "blocklist" , fallback = "info" )
1049
1089
async def blocklist (self , ctx : GuildContext ) -> None :
@@ -1052,7 +1092,9 @@ async def blocklist(self, ctx: GuildContext) -> None:
1052
1092
pages = BlocklistPages ([entry for entry in blocklist .values ()], ctx = ctx )
1053
1093
await pages .start ()
1054
1094
1055
- @check_permissions (manage_messages = True , manage_roles = True , moderate_members = True )
1095
+ @check_permissions (
1096
+ manage_messages = True , manage_roles = True , moderate_members = True
1097
+ )
1056
1098
@commands .guild_only ()
1057
1099
@blocklist .command (name = "add" )
1058
1100
@app_commands .describe (
@@ -1113,11 +1155,15 @@ async def blocklist_add(
1113
1155
)
1114
1156
await ctx .send (f"{ entity .mention } has been blocked" )
1115
1157
1116
- @check_permissions (manage_messages = True , manage_roles = True , moderate_members = True )
1158
+ @check_permissions (
1159
+ manage_messages = True , manage_roles = True , moderate_members = True
1160
+ )
1117
1161
@commands .guild_only ()
1118
1162
@blocklist .command (name = "remove" )
1119
1163
@app_commands .describe (entity = "The member to remove from the blocklist" )
1120
- async def blocklist_remove (self , ctx : GuildContext , entity : discord .Member ) -> None :
1164
+ async def blocklist_remove (
1165
+ self , ctx : GuildContext , entity : discord .Member
1166
+ ) -> None :
1121
1167
"""Removes an member from the blocklist"""
1122
1168
if not await self .can_be_blocked (ctx , entity ):
1123
1169
await ctx .send ("Failed to unblock entity" )
0 commit comments