mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-07 03:38:53 -05:00
Tell the command caller when bot was unable to send warn (#3653)
This commit is contained in:
parent
b9e2e1098f
commit
d9db03bca3
@ -361,19 +361,30 @@ class Warnings(commands.Cog):
|
|||||||
|
|
||||||
await warning_points_add_check(self.config, ctx, user, current_point_count)
|
await warning_points_add_check(self.config, ctx, user, current_point_count)
|
||||||
dm = await self.config.guild(ctx.guild).toggle_dm()
|
dm = await self.config.guild(ctx.guild).toggle_dm()
|
||||||
|
dm_failed = False
|
||||||
if dm:
|
if dm:
|
||||||
em = discord.Embed(
|
em = discord.Embed(
|
||||||
title=_("Warning from {user}").format(user=ctx.author),
|
title=_("Warning from {user}").format(user=ctx.author),
|
||||||
description=reason_type["description"],
|
description=reason_type["description"],
|
||||||
)
|
)
|
||||||
em.add_field(name=_("Points"), value=str(reason_type["points"]))
|
em.add_field(name=_("Points"), value=str(reason_type["points"]))
|
||||||
with contextlib.suppress(discord.HTTPException):
|
try:
|
||||||
await user.send(
|
await user.send(
|
||||||
_("You have received a warning in {guild_name}.").format(
|
_("You have received a warning in {guild_name}.").format(
|
||||||
guild_name=ctx.guild.name
|
guild_name=ctx.guild.name
|
||||||
),
|
),
|
||||||
embed=em,
|
embed=em,
|
||||||
)
|
)
|
||||||
|
except discord.HTTPException:
|
||||||
|
dm_failed = True
|
||||||
|
|
||||||
|
if dm_failed:
|
||||||
|
await ctx.send(
|
||||||
|
_(
|
||||||
|
"A warning for {user} has been issued,"
|
||||||
|
" but I wasn't able to send them a warn message."
|
||||||
|
).format(user=user.mention)
|
||||||
|
)
|
||||||
|
|
||||||
toggle_channel = await self.config.guild(guild).toggle_channel()
|
toggle_channel = await self.config.guild(guild).toggle_channel()
|
||||||
if toggle_channel:
|
if toggle_channel:
|
||||||
@ -384,16 +395,21 @@ class Warnings(commands.Cog):
|
|||||||
em.add_field(name=_("Points"), value=str(reason_type["points"]))
|
em.add_field(name=_("Points"), value=str(reason_type["points"]))
|
||||||
warn_channel = self.bot.get_channel(await self.config.guild(guild).warn_channel())
|
warn_channel = self.bot.get_channel(await self.config.guild(guild).warn_channel())
|
||||||
if warn_channel:
|
if warn_channel:
|
||||||
channel = warn_channel
|
|
||||||
await ctx.tick()
|
|
||||||
else:
|
|
||||||
channel = ctx.channel
|
|
||||||
if channel.permissions_for(guild.me).send_messages:
|
if channel.permissions_for(guild.me).send_messages:
|
||||||
with contextlib.suppress(discord.HTTPException):
|
with contextlib.suppress(discord.HTTPException):
|
||||||
await channel.send(
|
await channel.send(
|
||||||
|
_("{user} has been warned.").format(user=user.mention), embed=em,
|
||||||
|
)
|
||||||
|
|
||||||
|
if not dm_failed:
|
||||||
|
if warn_channel:
|
||||||
|
await ctx.tick()
|
||||||
|
else:
|
||||||
|
await ctx.send(
|
||||||
_("{user} has been warned.").format(user=user.mention), embed=em
|
_("{user} has been warned.").format(user=user.mention), embed=em
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
if not dm_failed:
|
||||||
await ctx.tick()
|
await ctx.tick()
|
||||||
try:
|
try:
|
||||||
reason_msg = _(
|
reason_msg = _(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user