@@ -152,13 +152,10 @@ async def on_message_delete(
152
152
emb = None
153
153
if (
154
154
message .guild
155
- and (
156
- (
157
- hasattr (message .channel , "name" )
158
- and message .channel .name != misc .LogChannelName
159
- )
160
- or message .content
161
- )
155
+ and ((
156
+ hasattr (message .channel , "name" )
157
+ and message .channel .name != misc .LogChannelName
158
+ ) or message .content )
162
159
and (channel := misc .get_log_channel (message .guild ))
163
160
):
164
161
emb = logs .log_delete_msg (message )
@@ -186,9 +183,9 @@ async def on_message_edit(
186
183
if after .guild and (before .content != after .content ):
187
184
if misc .scam_check (after .content ):
188
185
await misc .delete_scam_and_notify (after )
189
- if logChannel := misc .get_log_channel (after .guild ):
186
+ if log_channel := misc .get_log_channel (after .guild ):
190
187
emb = logs .log_edit_msg (before , after )
191
- await logChannel .send (embed = emb )
188
+ await log_channel .send (embed = emb )
192
189
return emb
193
190
194
191
@@ -209,9 +206,9 @@ async def on_guild_channel_delete(
209
206
channel : nextcord .abc .GuildChannel ,
210
207
) -> nextcord .Embed | None :
211
208
emb = None
212
- if logChannel := misc .get_log_channel (channel .guild ):
209
+ if log_channel := misc .get_log_channel (channel .guild ):
213
210
emb = logs .log_delete_channel (channel )
214
- await logChannel .send (embed = emb )
211
+ await log_channel .send (embed = emb )
215
212
return emb
216
213
217
214
@@ -220,9 +217,9 @@ async def on_guild_channel_create(
220
217
channel : nextcord .abc .GuildChannel ,
221
218
) -> nextcord .Embed | None :
222
219
emb = None
223
- if logChannel := misc .get_log_channel (channel .guild ):
220
+ if log_channel := misc .get_log_channel (channel .guild ):
224
221
emb = logs .log_create_channel (channel )
225
- await logChannel .send (embed = emb )
222
+ await log_channel .send (embed = emb )
226
223
return emb
227
224
228
225
@@ -399,24 +396,26 @@ async def cmd_stay(ctx: misc.BotContext) -> int:
399
396
async def cmd_av (ctx : misc .BotContext , * , target : str = "" ) -> int :
400
397
if misc .ctx_created_thread (ctx ):
401
398
return - 1
402
- await ctx .send (embed = misc .avatar (misc .get_target (ctx , target ), ctx .message ))
399
+ await ctx .send (embed = misc .avatar (
400
+ misc .get_target (ctx , target ), ctx .message ,
401
+ ))
403
402
return 1
404
403
405
404
406
405
@BeardlessBot .command (name = "info" ) # type: ignore[arg-type]
407
406
async def cmd_info (ctx : misc .BotContext , * , target : str = "" ) -> int :
408
407
if misc .ctx_created_thread (ctx ) or not ctx .guild :
409
408
return - 1
410
- infoTarget : nextcord .Member | str
409
+ info_target : nextcord .Member | str
411
410
if ctx .message .mentions :
412
411
assert isinstance (ctx .message .mentions [0 ], nextcord .Member )
413
- infoTarget = ctx .message .mentions [0 ]
412
+ info_target = ctx .message .mentions [0 ]
414
413
elif target :
415
- infoTarget = target
414
+ info_target = target
416
415
else :
417
416
assert isinstance (ctx .author , nextcord .Member )
418
- infoTarget = ctx .author
419
- await ctx .send (embed = misc .info (infoTarget , ctx .message ))
417
+ info_target = ctx .author
418
+ await ctx .send (embed = misc .info (info_target , ctx .message ))
420
419
return 1
421
420
422
421
@@ -572,8 +571,8 @@ async def cmd_animals(ctx: misc.BotContext) -> int:
572
571
),
573
572
inline = False ,
574
573
)
575
- for animalName in misc .AnimalList :
576
- emb .add_field (name = "!" + animalName , value = "_ _" )
574
+ for animal_name in misc .AnimalList :
575
+ emb .add_field (name = "!" + animal_name , value = "_ _" )
577
576
await ctx .send (embed = emb )
578
577
return 1
579
578
@@ -615,7 +614,7 @@ async def cmd_dog(ctx: misc.BotContext, *, breed: str = "") -> int:
615
614
return - 1
616
615
assert ctx .invoked_with is not None
617
616
try :
618
- dogUrl = await misc .get_dog (
617
+ url = await misc .get_dog (
619
618
breed .lower () if ctx .invoked_with .lower () != "moose" else "moose" ,
620
619
)
621
620
except (misc .AnimalException , ValueError , KeyError ) as e :
@@ -626,13 +625,13 @@ async def cmd_dog(ctx: misc.BotContext, *, breed: str = "") -> int:
626
625
"Please inform my creator and he'll see what's going on." ,
627
626
))
628
627
return 0
629
- if dogUrl .startswith (("Dog breeds: " , "Breed not found" )):
630
- await ctx .send (dogUrl )
631
- return int (dogUrl .startswith ("Dog breeds: " ))
632
- dogBreed = "Hound" if "hound" in dogUrl else dogUrl .split ("/" )[- 2 ]
628
+ if url .startswith (("Dog breeds: " , "Breed not found" )):
629
+ await ctx .send (url )
630
+ return int (url .startswith ("Dog breeds: " ))
631
+ dog_breed = "Hound" if "hound" in url else url .split ("/" )[- 2 ]
633
632
emb = misc .bb_embed (
634
- "Random " + dogBreed .replace ("main" , "moose" ).title (),
635
- ).set_image (url = dogUrl )
633
+ "Random " + dog_breed .replace ("main" , "moose" ).title (),
634
+ ).set_image (url = url )
636
635
await ctx .send (embed = emb )
637
636
return 1
638
637
@@ -674,51 +673,53 @@ async def cmd_mute(
674
673
) -> int :
675
674
if misc .ctx_created_thread (ctx ) or not ctx .guild :
676
675
return - 1
677
- if not (
678
- muteTarget := await misc . process_mute_target ( ctx , target , BeardlessBot )
679
- ):
676
+ if not (mute_target := await misc . process_mute_target (
677
+ ctx , target , BeardlessBot ,
678
+ )) :
680
679
return 0
681
680
role = await misc .create_muted_role (ctx .guild )
682
- duration , reason , mTime = misc .process_mute_duration (duration , additional )
681
+ duration , reason , mute_time = misc .process_mute_duration (
682
+ duration , additional ,
683
+ )
683
684
try :
684
- await muteTarget .add_roles (role )
685
+ await mute_target .add_roles (role )
685
686
except nextcord .Forbidden as e :
686
687
misc .log_exception (e , ctx )
687
688
await ctx .send (misc .HierarchyMsg )
688
689
return 0
689
690
addendum = (" for " + duration + "." ) if duration is not None else "."
690
691
emb = misc .bb_embed (
691
- "Beardless Bot Mute" , "Muted " + muteTarget .mention + addendum ,
692
+ "Beardless Bot Mute" , "Muted " + mute_target .mention + addendum ,
692
693
).set_author (name = ctx .author , icon_url = misc .fetch_avatar (ctx .author ))
693
694
if reason :
694
695
emb .add_field (name = "Mute Reason:" , value = reason , inline = False )
695
696
await ctx .send (embed = emb )
696
697
if channel := misc .get_log_channel (ctx .guild ):
697
- await channel .send (
698
- embed = logs . log_mute ( muteTarget , ctx .message , duration ) ,
699
- )
700
- if mTime :
701
- # autounmute(muteTarget , ctx, mTime , role, addendum)
698
+ await channel .send (embed = logs . log_mute (
699
+ mute_target , ctx .message , duration ,
700
+ ))
701
+ if mute_time :
702
+ # autounmute(mute_target , ctx, mute_time , role, addendum)
702
703
# TODO: use on_close() to make mute times persist through restarts
703
704
# https://github.com/LevBernstein/BeardlessBot/issues/44
704
705
# Autounmute
705
706
logging .info (
706
707
"Muted %s/%i%s Muter: %s/%i. Guild: %s" ,
707
- muteTarget .name ,
708
- muteTarget .id ,
708
+ mute_target .name ,
709
+ mute_target .id ,
709
710
addendum ,
710
711
ctx .author .name ,
711
712
ctx .author .id ,
712
713
ctx .guild .name ,
713
714
)
714
- await asyncio .sleep (mTime )
715
- await muteTarget .remove_roles (role )
715
+ await asyncio .sleep (mute_time )
716
+ await mute_target .remove_roles (role )
716
717
logging .info (
717
- "Autounmuted %s after waiting%s" , muteTarget .name , addendum ,
718
+ "Autounmuted %s after waiting%s" , mute_target .name , addendum ,
718
719
)
719
720
if channel := misc .get_log_channel (ctx .guild ):
720
721
assert isinstance (ctx .author , nextcord .Member )
721
- await channel .send (embed = logs .log_unmute (muteTarget , ctx .author ))
722
+ await channel .send (embed = logs .log_unmute (mute_target , ctx .author ))
722
723
return 1
723
724
724
725
@@ -736,21 +737,21 @@ async def cmd_unmute(
736
737
elif target :
737
738
converter = commands .MemberConverter ()
738
739
try :
739
- mutedMember = await converter .convert (ctx , target )
740
+ muted_member = await converter .convert (ctx , target )
740
741
except commands .MemberNotFound as e :
741
742
misc .log_exception (e , ctx )
742
743
report = "Invalid target! Target must be a mention or user ID."
743
744
else :
744
745
try :
745
- await mutedMember .remove_roles (role )
746
+ await muted_member .remove_roles (role )
746
747
except nextcord .Forbidden as e :
747
748
misc .log_exception (e , ctx )
748
749
report = misc .HierarchyMsg
749
750
else :
750
- report = f"Unmuted { mutedMember .mention } ."
751
+ report = f"Unmuted { muted_member .mention } ."
751
752
if channel := misc .get_log_channel (ctx .guild ):
752
753
await channel .send (
753
- embed = logs .log_unmute (mutedMember , ctx .author ),
754
+ embed = logs .log_unmute (muted_member , ctx .author ),
754
755
)
755
756
else :
756
757
report = f"Invalid target, { ctx .author .mention } ."
@@ -766,7 +767,7 @@ async def cmd_purge(
766
767
return - 1
767
768
assert hasattr (ctx .author , "guild_permissions" )
768
769
if ctx .author .guild_permissions .manage_messages :
769
- if num is None or not num .isnumeric () or ((mNum := int (num )) < 0 ):
770
+ if num is None or not num .isnumeric () or ((limit := int (num )) < 0 ):
770
771
await ctx .send (embed = misc .bb_embed (
771
772
"Beardless Bot Purge" , "Invalid message number!" ,
772
773
))
@@ -776,7 +777,7 @@ async def cmd_purge(
776
777
nextcord .TextChannel | nextcord .VoiceChannel | nextcord .Thread ,
777
778
)
778
779
await ctx .channel .purge (
779
- limit = mNum + 1 , check = lambda msg : not msg .pinned ,
780
+ limit = limit + 1 , check = lambda msg : not msg .pinned ,
780
781
)
781
782
return 1
782
783
await ctx .send (embed = misc .bb_embed (
@@ -864,7 +865,7 @@ async def cmd_spar(
864
865
await ctx .send (embed = misc .SparPinsEmbed )
865
866
return 0
866
867
report = brawl .BadRegion .format (author )
867
- tooRecent : int | None = None
868
+ too_recent : int | None = None
868
869
role : nextcord .Role | None = None
869
870
if (region := region .lower ()) in {"usw" , "use" }:
870
871
region = region [:2 ] + "-" + region [2 ]
@@ -880,13 +881,15 @@ async def cmd_spar(
880
881
pings [region ] = int (time ())
881
882
report = f"{ role .mention } come spar { author } "
882
883
else :
883
- tooRecent = value
884
- if role and tooRecent :
885
- hours , seconds = divmod (SparCooldown - (int (time ()) - tooRecent ), 3600 )
884
+ too_recent = value
885
+ if role and too_recent :
886
+ hours , seconds = divmod (
887
+ SparCooldown - (int (time ()) - too_recent ), 3600 ,
888
+ )
886
889
minutes , seconds = divmod (seconds , 60 )
887
890
report = brawl .ping_msg (author , hours , minutes , seconds )
888
891
await ctx .send (report )
889
- if additional and role and not tooRecent :
892
+ if additional and role and not too_recent :
890
893
await ctx .send (f"Additional info: \" { additional } \" " .replace ("@" , "" ))
891
894
return 1
892
895
@@ -908,17 +911,19 @@ async def cmd_brawl(ctx: misc.BotContext) -> int:
908
911
async def cmd_brawlclaim (ctx : misc .BotContext , url_or_id : str = "None" ) -> int :
909
912
if misc .ctx_created_thread (ctx ) or not BrawlKey :
910
913
return - 1
911
- brawlId = (
914
+ brawl_id = (
912
915
int (url_or_id )
913
916
if url_or_id .isnumeric ()
914
917
else await brawl .get_brawl_id (BrawlKey , url_or_id )
915
918
)
916
- if brawlId is not None :
917
- brawl .claim_profile (ctx .author .id , brawlId )
919
+ if brawl_id is not None :
920
+ brawl .claim_profile (ctx .author .id , brawl_id )
918
921
report = "Profile claimed."
919
922
else :
920
923
report = "Invalid profile URL/Brawlhalla ID! " + brawl .BadClaim
921
- await ctx .send (embed = misc .bb_embed ("Beardless Bot Brawlhalla Rank" , report ))
924
+ await ctx .send (embed = misc .bb_embed (
925
+ "Beardless Bot Brawlhalla Rank" , report ,
926
+ ))
922
927
return 1
923
928
924
929
@@ -928,34 +933,36 @@ async def cmd_brawlrank(ctx: misc.BotContext, *, target: str = "") -> int:
928
933
return - 1
929
934
# TODO: write valid target method; no need for this copy paste
930
935
# have it return target, report
931
- rankTarget : misc .TargetTypes | None = misc .get_target (ctx , target )
936
+ rank_target : misc .TargetTypes | None = misc .get_target (ctx , target )
932
937
report = "Invalid target!"
933
- if isinstance (rankTarget , str ):
934
- rankTarget = misc .member_search (ctx .message , rankTarget )
935
- if rankTarget :
938
+ if isinstance (rank_target , str ):
939
+ rank_target = misc .member_search (ctx .message , rank_target )
940
+ if rank_target :
936
941
try :
937
- emb = await brawl .get_rank (rankTarget , BrawlKey )
942
+ emb = await brawl .get_rank (rank_target , BrawlKey )
938
943
except RequestError as e :
939
944
misc .log_exception (e , ctx )
940
945
report = brawl .RequestLimit
941
946
else :
942
947
await ctx .send (embed = emb )
943
948
return 1
944
- await ctx .send (embed = misc .bb_embed ("Beardless Bot Brawlhalla Rank" , report ))
949
+ await ctx .send (embed = misc .bb_embed (
950
+ "Beardless Bot Brawlhalla Rank" , report ,
951
+ ))
945
952
return 0
946
953
947
954
948
955
@BeardlessBot .command (name = "brawlstats" ) # type: ignore[arg-type]
949
956
async def cmd_brawlstats (ctx : misc .BotContext , * , target : str = "" ) -> int :
950
957
if misc .ctx_created_thread (ctx ) or not ctx .guild or not BrawlKey :
951
958
return - 1
952
- statsTarget : misc .TargetTypes | None = misc .get_target (ctx , target )
959
+ stats_target : misc .TargetTypes | None = misc .get_target (ctx , target )
953
960
report = "Invalid target!"
954
- if isinstance (statsTarget , str ):
955
- statsTarget = misc .member_search (ctx .message , statsTarget )
956
- if statsTarget :
961
+ if isinstance (stats_target , str ):
962
+ stats_target = misc .member_search (ctx .message , stats_target )
963
+ if stats_target :
957
964
try :
958
- emb = await brawl .get_stats (statsTarget , BrawlKey )
965
+ emb = await brawl .get_stats (stats_target , BrawlKey )
959
966
except RequestError as e :
960
967
misc .log_exception (e , ctx )
961
968
report = brawl .RequestLimit
@@ -972,20 +979,22 @@ async def cmd_brawlstats(ctx: misc.BotContext, *, target: str = "") -> int:
972
979
async def cmd_brawlclan (ctx : misc .BotContext , * , target : str = "" ) -> int :
973
980
if misc .ctx_created_thread (ctx ) or not ctx .guild or not BrawlKey :
974
981
return - 1
975
- clanTarget : misc .TargetTypes | None = misc .get_target (ctx , target )
982
+ clan_target : misc .TargetTypes | None = misc .get_target (ctx , target )
976
983
report = "Invalid target!"
977
- if isinstance (clanTarget , str ):
978
- clanTarget = misc .member_search (ctx .message , clanTarget )
979
- if clanTarget :
984
+ if isinstance (clan_target , str ):
985
+ clan_target = misc .member_search (ctx .message , clan_target )
986
+ if clan_target :
980
987
try :
981
- emb = await brawl .get_clan (clanTarget , BrawlKey )
988
+ emb = await brawl .get_clan (clan_target , BrawlKey )
982
989
except RequestError as e :
983
990
misc .log_exception (e , ctx )
984
991
report = brawl .RequestLimit
985
992
else :
986
993
await ctx .send (embed = emb )
987
994
return 1
988
- await ctx .send (embed = misc .bb_embed ("Beardless Bot Brawlhalla Clan" , report ))
995
+ await ctx .send (embed = misc .bb_embed (
996
+ "Beardless Bot Brawlhalla Clan" , report ,
997
+ ))
989
998
return 0
990
999
991
1000
0 commit comments