arged responses#3418
Conversation
This add a args feature, for example if your arg is called `argreply`
You can do: `?reply Hello, read the following: {argreply}
fed5044
sebkuip
left a comment
There was a problem hiding this comment.
There are some issues in this PR that need to be addressed beforehand.
|
I discussed this with Lorenzo and removed this from this update to allow additional time for corrections while still working towards the important changes in 4.3.0 |
sebkuip
left a comment
There was a problem hiding this comment.
I found some bugs, and some typos. Please have these fixed. Thanks!
There was a problem hiding this comment.
Small typo here, pointed out by copilot. "don't" is missing it's apostrophe
There was a problem hiding this comment.
I would change this text to See"{self.bot.prefix}help args add" for how to add an arg.
|
|
||
| if self.bot.args: | ||
| msg = UnseenFormatter().format(msg, **self.bot.args) | ||
| msg = self.bot.formatter.format(msg, **self.bot.args) |
There was a problem hiding this comment.
The system breaks when an arg with a . character in the name is added. It tries to resolve it as an attribute causing either an <invalid> or an error to appear.
Using a string as an arg causes no reply and a silent error.


Using a forbidden arg causes an <invalid> to appear (here I did ?r testing {channel.name})

Formatreply correctly works and doesn't cause issues
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
cogs/modmail.py:1726
- In the
replycommand, runningSafeFormatter.format()on every message when any args exist will replace any unknown{...}placeholders with"<Invalid>"(perSafeFormatter.get_field), changing existing reply behavior for messages that include braces. Consider only substituting placeholders that match defined args, leaving other braces untouched (users can usefreplyfor full variable formatting).
if self.bot.args:
msg = self.bot.formatter.format(msg, **self.bot.args)
cogs/modmail.py:587
- Typo/grammar: "You dont have any args" should use an apostrophe ("don't").
embed = discord.Embed(
color=self.bot.error_color,
description="You dont have any args at the moment.",
)
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Comments suppressed due to low confidence (5)
cogs/modmail.py:688
args_editstores the new value withoutcommands.clean_content, whileargs_addusesclean_content. This makes edits behave differently than adds and can reintroduce mentions/markdown thataddwould have sanitized.
@args.command(name="edit")
@checks.has_permissions(PermissionLevel.SUPPORTER)
async def args_edit(self, ctx, name: str.lower, *, value):
"""
Edit an arg.
cogs/modmail.py:1762
- Passing
**self.bot.argsalongside explicitchannel=...,recipient=...,author=...can raiseTypeError: got multiple values for keyword argumentif the config already contains any reserved keys (e.g. from manual edits or older data). Build a single kwargs dict and let the reserved keys override.
msg = self.bot.formatter.format(
msg,
**self.bot.args,
channel=ctx.channel,
recipient=ctx.thread.recipient,
cogs/modmail.py:1800
- Same reserved-key collision risk as
freply: expanding**self.bot.argstogether with explicitchannel/recipient/authorcan throwTypeErrorif those keys exist in config. Merge into a single dict so reserved values overwrite safely.
msg = self.bot.formatter.format(
msg,
**self.bot.args,
channel=ctx.channel,
recipient=ctx.thread.recipient,
cogs/modmail.py:1838
- Same reserved-key collision risk as
freply: expanding**self.bot.argstogether with explicitchannel/recipient/authorcan throwTypeErrorif those keys exist in config. Merge into a single dict so reserved values overwrite safely.
msg = self.bot.formatter.format(
msg,
**self.bot.args,
channel=ctx.channel,
recipient=ctx.thread.recipient,
cogs/modmail.py:1876
- Same reserved-key collision risk as
freply: expanding**self.bot.argstogether with explicitchannel/recipient/authorcan throwTypeErrorif those keys exist in config. Merge into a single dict so reserved values overwrite safely.
msg = self.bot.formatter.format(
msg,
**self.bot.args,
channel=ctx.channel,
recipient=ctx.thread.recipient,
| def get_field(self, field_name, args, kwargs): | ||
| """Resolve only complete field names and preserve unknown fields.""" | ||
| if field_name in kwargs: | ||
| return kwargs[field_name], field_name | ||
| if field_name.isdecimal(): |
| To create an arg: | ||
| - `{prefix}args add arg-name A value.` | ||
|
|
||
| You can use your arg in a reply with `{arg-name}`. | ||
| """ |
| if len(name) > 120: | ||
| embed = discord.Embed( | ||
| title="Error", | ||
| color=self.bot.error_color, | ||
| description="Arg names cannot be longer than 120 characters.", | ||
| ) | ||
| return await ctx.send(embed=embed) |
| if len(value) > 120: | ||
| embed = discord.Embed( | ||
| title="Error", | ||
| color=self.bot.error_color, | ||
| description="Arg names cannot be longer than 120 characters.", | ||
| ) | ||
| return await ctx.send(embed=embed) |
| ) | ||
| return await ctx.send(embed=embed) | ||
|
|
||
| embeds = [discord.Embed(color=self.bot.main_color) for _ in range((len(self.bot.args) // 10) + 1)] |
| if self.bot.args: | ||
| msg = UnseenFormatter().format(msg, **self.bot.args) | ||
|
|
This add a args feature, for example if your arg is called
argreplyYou can do: `?reply Hello, read the following: {argreply}