add in dming context to warned users

This commit is contained in:
Brandon Silva 2022-09-21 15:52:47 -04:00
parent f9a21d4d77
commit ecfb1a1c33
1 changed files with 19 additions and 0 deletions

View File

@ -34,6 +34,7 @@ class Warnings_Custom(commands.Cog):
"reasons": {},
"allow_custom_reasons": False,
"allow_context": False,
"allow_context_dm": False,
"toggle_dm": True,
"show_mod": False,
"warn_channel": None,
@ -136,6 +137,20 @@ class Warnings_Custom(commands.Cog):
else:
await ctx.send(_("Context has been disabled."))
@warningset.command()
@commands.guild_only()
async def allowcontextdm(self, ctx: commands.Context, allowed: bool):
"""Enable or disable sending context of warnings to warned user.
Send DM and Allow Context must also be enabled for this to take effect.
"""
guild = ctx.guild
await self.config.guild(guild).allow_context_dm.set(allowed)
if allowed:
await ctx.send(_("DMing context has been enabled."))
else:
await ctx.send(_("DMing context has been disabled."))
@warningset.command()
@commands.guild_only()
async def senddm(self, ctx: commands.Context, true_or_false: bool):
@ -481,6 +496,10 @@ class Warnings_Custom(commands.Cog):
description=reason_type["description"],
)
em.add_field(name=_("Points"), value=str(reason_type["points"]))
if await self.config.guild(guild).allow_context_dm() and context != "":
em.add_field(name="Context", value=context)
try:
await user.send(
_("You have received a warning in {guild_name}.").format(guild_name=ctx.guild.name),