@@ -99,6 +99,9 @@ def __init__(self, bot: Red):
9999 "default_time" : 0 ,
100100 "dm" : False ,
101101 "show_mod" : False ,
102+ "mute_show_extra" : False ,
103+ "mute_extra_embed_title" : "Message from staff" ,
104+ "mute_extra_embed_contents" : "Please set me" ,
102105 }
103106 self .config .register_global (schema_version = 0 )
104107 self .config .register_guild (** default_guild )
@@ -584,6 +587,8 @@ async def _send_dm_notification(
584587 if not reason :
585588 reason = _ ("No reason provided." )
586589
590+ mute_show_extra = await self .config .guild (guild ).mute_show_extra ()
591+
587592 if await self .bot .embed_requested (user ):
588593 em = discord .Embed (
589594 title = title ,
@@ -597,6 +602,14 @@ async def _send_dm_notification(
597602 em .add_field (name = _ ("Guild" ), value = guild .name , inline = False )
598603 if show_mod :
599604 em .add_field (name = _ ("Moderator" ), value = moderator_str )
605+ if mute_show_extra :
606+ extra_embed_title = await self .config .guild (guild ).mute_extra_embed_title ()
607+ extra_embed_contents = await self .config .guild (guild ).mute_extra_embed_contents ()
608+ em .add_field (
609+ name = bold (extra_embed_title , escape_formatting = False ),
610+ value = extra_embed_contents ,
611+ inline = False ,
612+ )
600613 try :
601614 await user .send (embed = em )
602615 except discord .Forbidden :
@@ -611,6 +624,10 @@ async def _send_dm_notification(
611624 else ""
612625 )
613626 message += f"\n { bold (_ ('Guild:' ))} { guild .name } "
627+ if mute_show_extra :
628+ extra_embed_title = await self .config .guild (guild ).mute_extra_embed_title ()
629+ extra_embed_contents = await self .config .guild (guild ).mute_extra_embed_contents ()
630+ message += f"\n { bold (extra_embed_title )} : { extra_embed_contents } "
614631 try :
615632 await user .send (message )
616633 except discord .Forbidden :
@@ -821,6 +838,64 @@ async def showmoderator(self, ctx, true_or_false: bool):
821838 )
822839 )
823840
841+ @muteset .group ()
842+ @commands .guild_only ()
843+ async def dm (self , ctx : commands .Context ):
844+ """Settings for the optional extra field in mute DMs."""
845+
846+ @dm .command (name = "muteshowextrafield" )
847+ async def dm_muteshowextrafield (self , ctx : commands .Context , enabled : bool = None ):
848+ """Toggle whether to show an extra customizable field when muting.
849+
850+ This can be used to add additional information for the muted user, such as a mute appeal link.
851+ """
852+ guild = ctx .guild
853+ if enabled is None :
854+ setting = await self .config .guild (guild ).mute_show_extra ()
855+ await ctx .send (
856+ _ ("The extra embed field is currently set to: {setting}" ).format (setting = setting )
857+ )
858+ return
859+ await self .config .guild (guild ).mute_show_extra .set (enabled )
860+ if enabled :
861+ await ctx .send (
862+ _ (
863+ "An extra field will be shown when muting. Configure it with "
864+ "`{prefix}muteset dm muteextrafieldtitle` and "
865+ "`{prefix}muteset dm muteextrafieldcontents`"
866+ ).format (prefix = ctx .prefix )
867+ )
868+ else :
869+ await ctx .send (_ ("An extra field will no longer be shown when muting." ))
870+
871+ @dm .command (name = "muteextrafieldtitle" )
872+ async def dm_muteextrafieldtitle (self , ctx : commands .Context , * , title : str ) -> None :
873+ """Set the title for the optional extra embed field on mute.
874+
875+ Cannot be over 252 characters long.
876+ """
877+ guild = ctx .guild
878+ if len (title ) > 252 :
879+ await ctx .send (_ ("Embed title cannot be over 252 characters long." ))
880+ else :
881+ await self .config .guild (guild ).mute_extra_embed_title .set (title )
882+ await ctx .send (_ ("Embed title has been set to `{title}`" ).format (title = title ))
883+
884+ @dm .command (name = "muteextrafieldcontents" )
885+ async def dm_muteextrafieldcontents (self , ctx : commands .Context , * , contents : str ) -> None :
886+ """Set the contents for the optional extra embed field on mute.
887+
888+ Cannot be over 1024 characters long.
889+ """
890+ guild = ctx .guild
891+ if len (contents ) > 1024 :
892+ await ctx .send (_ ("Embed contents cannot be over 1024 characters long." ))
893+ else :
894+ await self .config .guild (guild ).mute_extra_embed_contents .set (contents )
895+ await ctx .send (
896+ _ ("Embed contents has been set to `{contents}`" ).format (contents = contents )
897+ )
898+
824899 @muteset .command (name = "settings" , aliases = ["showsettings" ])
825900 @commands .mod_or_permissions (manage_channels = True )
826901 async def show_mutes_settings (self , ctx : commands .Context ):
@@ -832,18 +907,29 @@ async def show_mutes_settings(self, ctx: commands.Context):
832907 mute_role = ctx .guild .get_role (data ["mute_role" ])
833908 notification_channel = ctx .guild .get_channel (data ["notification_channel" ])
834909 default_time = timedelta (seconds = data ["default_time" ])
910+ mute_show_extra = data ["mute_show_extra" ]
911+ mute_extra_embed_title = data ["mute_extra_embed_title" ]
912+ mute_extra_embed_contents = data ["mute_extra_embed_contents" ]
835913 msg = _ (
836914 "Mute Role: {role}\n "
837915 "Notification Channel: {channel}\n "
838916 "Default Time: {time}\n "
839917 "Send DM: {dm}\n "
840- "Show moderator: {show_mod}"
918+ "Show moderator: {show_mod}\n "
919+ "Show optional information field in embed: {mute_show_extra}\n "
920+ "Title of the optional extra field: {mute_extra_embed_title}\n "
921+ "Contents of the optional extra field: {mute_extra_embed_contents}"
841922 ).format (
842923 role = mute_role .mention if mute_role else _ ("None" ),
843924 channel = notification_channel .mention if notification_channel else _ ("None" ),
844925 time = humanize_timedelta (timedelta = default_time ) if default_time else _ ("None" ),
845926 dm = data ["dm" ],
846927 show_mod = data ["show_mod" ],
928+ mute_show_extra = mute_show_extra ,
929+ mute_extra_embed_title = mute_extra_embed_title if mute_extra_embed_title else _ ("None" ),
930+ mute_extra_embed_contents = (
931+ mute_extra_embed_contents if mute_extra_embed_contents else _ ("None" )
932+ ),
847933 )
848934 await ctx .maybe_send_embed (msg )
849935
0 commit comments