@@ -953,15 +953,15 @@ async def blocked(self, ctx):
953953 else :
954954 try :
955955 user = await self .bot .fetch_user (id_ )
956- users .append ((str ( user ) , reason ))
956+ users .append ((user . mention , reason ))
957957 except discord .NotFound :
958- pass
958+ users . append (( id_ , reason ))
959959
960960 if users :
961961 embed = embeds [0 ]
962962
963963 for mention , reason in users :
964- line = mention + f" - ` { reason or 'No reason provided' } ` \n "
964+ line = mention + f" - { reason or 'No Reason Provided' } \n "
965965 if len (embed .description ) + len (line ) > 2048 :
966966 embed = discord .Embed (
967967 title = "Blocked Users (Continued)" ,
@@ -1008,20 +1008,18 @@ async def blocked_whitelist(self, ctx, *, user: User = None):
10081008 self .bot .blocked_whitelisted_users .append (str (user .id ))
10091009
10101010 if str (user .id ) in self .bot .blocked_users :
1011- msg = self .bot .blocked_users .get (str (user .id ))
1012- if msg is None :
1013- msg = ""
1011+ msg = self .bot .blocked_users .get (str (user .id )) or ""
10141012 self .bot .blocked_users .pop (str (user .id ))
10151013
10161014 await self .bot .config .update ()
10171015
10181016 if msg .startswith ("System Message: " ):
10191017 # If the user is blocked internally (for example: below minimum account age)
10201018 # Show an extended message stating the original internal message
1021- reason = msg [16 :].strip ().rstrip ("." ) or "no reason"
1019+ reason = msg [16 :].strip ().rstrip ("." )
10221020 embed = discord .Embed (
10231021 title = "Success" ,
1024- description = f"{ mention } was previously blocked internally due to "
1022+ description = f"{ mention } was previously blocked internally for "
10251023 f'"{ reason } ". { mention } is now whitelisted.' ,
10261024 color = self .bot .main_color ,
10271025 )
@@ -1051,8 +1049,6 @@ async def block(
10511049 `duration` may be a simple "human-readable" time text. See `{prefix}help close` for examples.
10521050 """
10531051
1054- reason = ""
1055-
10561052 if user is None :
10571053 thread = ctx .thread
10581054 if thread :
@@ -1064,8 +1060,6 @@ async def block(
10641060
10651061 mention = getattr (user , "mention" , f"`{ user .id } `" )
10661062
1067- moderator = ctx .author .name
1068-
10691063 if str (user .id ) in self .bot .blocked_whitelisted_users :
10701064 embed = discord .Embed (
10711065 title = "Error" ,
@@ -1074,53 +1068,38 @@ async def block(
10741068 )
10751069 return await ctx .send (embed = embed )
10761070
1071+ reason = f"by { escape_markdown (ctx .author .name )} #{ ctx .author .discriminator } "
1072+
10771073 if after is not None :
1078- reason = f"{ after .arg } by { moderator } "
1079- if reason .startswith ("System Message: " ):
1080- raise commands .BadArgument (
1081- "The reason cannot start with `System Message:`."
1082- )
10831074 if "%" in reason :
10841075 raise commands .BadArgument ('The reason contains illegal character "%".' )
1076+ if after .arg :
1077+ reason += f" for `{ after .arg } `"
10851078 if after .dt > after .now :
1086- reason = f"{ reason } % { after .dt .isoformat ()} % by { moderator } "
1079+ reason + = f" until { after .dt .isoformat ()} "
10871080
1088- if not reason :
1089- reason = f"Blocked by { moderator } "
1081+ reason += "."
10901082
1091- extend = f" for `{ reason } `" if reason is not None else ""
10921083 msg = self .bot .blocked_users .get (str (user .id ))
10931084 if msg is None :
10941085 msg = ""
10951086
1096- if (
1097- str (user .id ) not in self .bot .blocked_users
1098- or reason is not None
1099- or msg .startswith ("System Message: " )
1100- ):
1101- if str (user .id ) in self .bot .blocked_users :
1102-
1103- old_reason = msg .strip ().rstrip ("." ) or f"Blocked by { moderator } "
1104- embed = discord .Embed (
1105- title = "Success" ,
1106- description = f"{ mention } was previously blocked for "
1107- f'"{ old_reason } ". { mention } is now blocked{ extend } .' ,
1108- color = self .bot .main_color ,
1109- )
1110- else :
1111- embed = discord .Embed (
1112- title = "Success" ,
1113- color = self .bot .main_color ,
1114- description = f"{ mention } is now blocked{ extend } ." ,
1115- )
1116- self .bot .blocked_users [str (user .id )] = reason
1117- await self .bot .config .update ()
1087+ if str (user .id ) in self .bot .blocked_users and msg :
1088+ old_reason = msg .strip ().rstrip ("." )
1089+ embed = discord .Embed (
1090+ title = "Success" ,
1091+ description = f"{ mention } was previously blocked "
1092+ f'{ old_reason } .\n { mention } is now blocked { reason } ' ,
1093+ color = self .bot .main_color ,
1094+ )
11181095 else :
11191096 embed = discord .Embed (
1120- title = "Error " ,
1121- color = self .bot .error_color ,
1122- description = f"{ mention } is already blocked. " ,
1097+ title = "Success " ,
1098+ color = self .bot .main_color ,
1099+ description = f"{ mention } is now blocked { reason } " ,
11231100 )
1101+ self .bot .blocked_users [str (user .id )] = reason
1102+ await self .bot .config .update ()
11241103
11251104 return await ctx .send (embed = embed )
11261105
@@ -1156,12 +1135,12 @@ async def unblock(self, ctx, *, user: User = None):
11561135 reason = msg [16 :].strip ().rstrip ("." ) or "no reason"
11571136 embed = discord .Embed (
11581137 title = "Success" ,
1159- description = f"{ mention } was previously blocked internally due to "
1160- f'" { reason } ". { mention } is no longer blocked.' ,
1138+ description = f"{ mention } was previously blocked internally "
1139+ f'{ reason } . \n { mention } is no longer blocked.' ,
11611140 color = self .bot .main_color ,
11621141 )
11631142 embed .set_footer (
1164- text = "However, if the original system block reason still apply , "
1143+ text = "However, if the original system block reason still applies , "
11651144 f"{ name } will be automatically blocked again. Use "
11661145 f'"{ self .bot .prefix } blocked whitelist { user .id } " to whitelist the user.'
11671146 )
0 commit comments