1111from datahandler .configHandle import ConfigHandle
1212from datahandler .userHandle import UserHandle
1313from datahandler .commandrights import read_rights_of
14- from button_views .leaderboard_buttons import LeaderboardButtons
14+ from button_views .leaderboard_buttons import LeaderboardButtons , SortBy
1515
1616import datetime
1717import time
@@ -344,9 +344,7 @@ async def decVoiceXP(self, ctx, userID, amount):
344344 amount = voiceXP
345345 voiceXP -= int (amount )
346346 self .uh .setUserVoice (userID , voiceXP )
347- message += (
348- f"Decreases user { str (self .bot .get_user (int (userID )))} voiceXP by { amount } . VoiceXP is set to { voiceXP } ."
349- )
347+ message += f"Decreases user { str (self .bot .get_user (int (userID )))} voiceXP by { amount } . VoiceXP is set to { voiceXP } ."
350348 log_message = (
351349 f"User { ctx .author } decreases user "
352350 + f"{ str (self .bot .get_user (int (userID )))} voiceXP by { amount } to { voiceXP } ."
@@ -384,9 +382,7 @@ async def incVoiceXP(self, ctx, userID, amount):
384382 voiceXP = self .uh .getUserVoice (userID )
385383 voiceXP += int (amount )
386384 self .uh .setUserVoice (userID , voiceXP )
387- message += (
388- f"Increases user { str (self .bot .get_user (int (userID )))} voiceXP by { amount } . VoiceXP is set to { voiceXP } ."
389- )
385+ message += f"Increases user { str (self .bot .get_user (int (userID )))} voiceXP by { amount } . VoiceXP is set to { voiceXP } ."
390386 log_message = (
391387 f"User { ctx .author } increases user "
392388 + f"{ str (self .bot .get_user (int (userID )))} voiceXP by { amount } to { voiceXP } ."
@@ -423,8 +419,7 @@ async def setTextXP(self, ctx, userID, amount):
423419 self .uh .addNewDataEntry (userID )
424420 self .uh .setUserText (userID , amount )
425421 message += (
426- f"Set user { str (self .bot .get_user (int (userID )))} "
427- + f"textXP to { amount } ."
422+ f"Set user { str (self .bot .get_user (int (userID )))} " + f"textXP to { amount } ."
428423 )
429424 log_message = (
430425 f"User { ctx .author } set user "
@@ -463,7 +458,7 @@ async def decTextXP(self, ctx, userID, amount):
463458 else :
464459 textXP = self .uh .getUserText (userID )
465460 if int (amount ) > textXP :
466- amount = textXP
461+ amount = textXP
467462 textXP -= int (amount )
468463 self .uh .setUserText (userID , textXP )
469464 message += (
@@ -505,7 +500,7 @@ async def incTextXP(self, ctx, userID, amount):
505500 )
506501 self .uh .addNewDataEntry (userID )
507502 textXP = self .uh .getUserText (userID )
508- textXP += int (amount )
503+ textXP += int (amount )
509504 self .uh .setUserText (userID , textXP )
510505 message += (
511506 f"Increase user { str (self .bot .get_user (int (userID )))} "
@@ -589,9 +584,7 @@ async def decTextCount(self, ctx, userID, amount):
589584 amount = textCount
590585 textCount -= int (amount )
591586 self .uh .setUserTextCount (userID , textCount )
592- message += (
593- f"Decreases user { str (self .bot .get_user (int (userID )))} TextCount by { amount } . TextCount is set to { textCount } ."
594- )
587+ message += f"Decreases user { str (self .bot .get_user (int (userID )))} TextCount by { amount } . TextCount is set to { textCount } ."
595588 log_message = (
596589 f"User { ctx .author } decreases user "
597590 + f"{ str (self .bot .get_user (int (userID )))} textCount by { amount } to { textCount } ."
@@ -629,9 +622,7 @@ async def incTextCount(self, ctx, userID, amount):
629622 textCount = self .uh .getUserTextCount (userID )
630623 textCount += int (amount )
631624 self .uh .setUserTextCount (userID , textCount )
632- message += (
633- f"Increases user { str (self .bot .get_user (int (userID )))} TextCount by { amount } . TextCount is set to { textCount } ."
634- )
625+ message += f"Increases user { str (self .bot .get_user (int (userID )))} TextCount by { amount } . TextCount is set to { textCount } ."
635626 log_message = (
636627 f"User { ctx .author } increases user "
637628 + f"{ str (self .bot .get_user (int (userID )))} textCount by { amount } to { textCount } ."
@@ -838,9 +829,7 @@ async def textunban(self, ctx, userID):
838829 f"User { ctx .author .mention } textunbaned { user .mention } "
839830 )
840831 else :
841- await ctx .send (
842- content = "ERROR: User has no textban." , delete_after = 3600
843- )
832+ await ctx .send (content = "ERROR: User has no textban." , delete_after = 3600 )
844833
845834 """
846835 # When give star of the week should be queued
@@ -993,9 +982,7 @@ async def getLevel(self, ctx, *inputs):
993982 title = f"{ member .nick } ({ member .name } )" , color = 12008408
994983 )
995984 embed .set_thumbnail (url = avatar_url )
996- embed .add_field (
997- name = "TIME" , value = f"{ round (int (voiceXP )/ 30.0 ,1 )} " , inline = True
998- )
985+ embed .add_field (name = "TIME" , value = f"{ round (int (voiceXP )/ 30.0 ,1 )} " , inline = True )
999986 embed .add_field (name = "TEXT" , value = f"{ str (textCount )} " , inline = True )
1000987 embed .add_field (
1001988 name = "EXP" ,
@@ -1012,7 +999,7 @@ async def getLevel(self, ctx, *inputs):
1012999
10131000 @commands .command (name = "top" , brief = "Sends an interactive rank list." )
10141001 @isInChannelCommand (* channel_userLeaderboard )
1015- async def leaderboard (self , ctx ):
1002+ async def leaderboard (self , ctx , * args ):
10161003 """
10171004 Spawns an interactive leaderboard in the "⏫level" via the command 'top'.
10181005 Displays the first 10 member with the highest XP total.
@@ -1032,15 +1019,22 @@ async def leaderboard(self, ctx):
10321019
10331020 Creates a leaderboard and posts it with the emojis to manipulate it.
10341021 """
1035- await self .utils .log (f"+top by { ctx .author } " , 1 ) # Notify Mods
1022+ await self .utils .log (f"+top { args } by { ctx .author } " , 1 ) # Notify Mods
10361023 # Create leaderboard
1037- text = f"{ self .utils .getLeaderboardPageBy (0 ,0 )} { ctx .author .mention } "
1038- message = await ctx .send (
1039- text , view = LeaderboardButtons (self .utils ), delete_after = 86400
1040- )
1041- # reactionsarr = ["⏫", "⬅", "➡", "⏰", "💌"]
1042- # for emoji in reactionsarr:
1043- # await message.add_reaction(emoji)
1024+ if len (args ) > 0 and str (args [0 ]).isdigit ():
1025+ timeFrame = int (args [0 ])
1026+ text = self .utils .getTempLeaderboardPageBy (
1027+ 0 , SortBy .VOICE_TEXT , timeFrame = timeFrame
1028+ )
1029+ else :
1030+ timeFrame = None
1031+ text = self .utils .getLeaderboardPageBy (0 , 0 )
1032+ if text :
1033+ await ctx .send (
1034+ text + str (ctx .author .mention ),
1035+ view = LeaderboardButtons (self .utils , timeFrame = timeFrame ),
1036+ delete_after = 86400 ,
1037+ )
10441038 await ctx .message .delete ()
10451039
10461040 @commands .command (name = "quote" , brief = "Sends an unique inspirational quote." )
0 commit comments