fix (rroles): Repair setting error reply.

Modified `error_reply` utility so `kwargs` are passed to `Embed`.
Added `send_args` kwarg to `error_reply`.

Fixed an rroles issue where `UserInputError` handling would fail.
This commit is contained in:
2021-11-07 15:00:04 +02:00
parent 0e62ebdb2b
commit 4c21160b31
2 changed files with 7 additions and 6 deletions

View File

@@ -821,8 +821,8 @@ async def cmd_reactionroles(ctx, flags):
setting = await setting_class.parse(target.messageid, ctx, flags[flag]) setting = await setting_class.parse(target.messageid, ctx, flags[flag])
except UserInputError as e: except UserInputError as e:
return await ctx.error_reply( return await ctx.error_reply(
title="Couldn't save settings!", "{} {}\nNo settings were modified.".format(cross, e.msg),
description="{} {}\nNo settings were modified.".format(cross, e.msg) title="Couldn't save settings!"
) )
else: else:
update_lines.append( update_lines.append(
@@ -861,8 +861,8 @@ async def cmd_reactionroles(ctx, flags):
setting = await setting_class.parse(reaction.reactionid, ctx, flags[flag]) setting = await setting_class.parse(reaction.reactionid, ctx, flags[flag])
except UserInputError as e: except UserInputError as e:
return await ctx.error_reply( return await ctx.error_reply(
"{} {}\nNo reaction roles were modified.".format(cross, e.msg),
title="Couldn't save reaction role settings!", title="Couldn't save reaction role settings!",
description="{} {}\nNo reaction roles were modified.".format(cross, e.msg)
) )
else: else:
update_lines.append( update_lines.append(

View File

@@ -26,21 +26,22 @@ async def embed_reply(ctx, desc, colour=discord.Colour.orange(), **kwargs):
@Context.util @Context.util
async def error_reply(ctx, error_str, **kwargs): async def error_reply(ctx, error_str, send_args={}, **kwargs):
""" """
Notify the user of a user level error. Notify the user of a user level error.
Typically, this will occur in a red embed, posted in the command channel. Typically, this will occur in a red embed, posted in the command channel.
""" """
embed = discord.Embed( embed = discord.Embed(
colour=discord.Colour.red(), colour=discord.Colour.red(),
description=error_str description=error_str,
**kwargs
) )
message = None message = None
try: try:
message = await ctx.ch.send( message = await ctx.ch.send(
embed=embed, embed=embed,
reference=ctx.msg.to_reference(fail_if_not_exists=False), reference=ctx.msg.to_reference(fail_if_not_exists=False),
**kwargs **send_args
) )
ctx.sent_messages.append(message) ctx.sent_messages.append(message)
return message return message