Skip to content

arged responses#3418

Open
lorenzo132 wants to merge 10 commits intodevelopmentfrom
users/lorenzo132/arged-responses
Open

arged responses#3418
lorenzo132 wants to merge 10 commits intodevelopmentfrom
users/lorenzo132/arged-responses

Conversation

@lorenzo132
Copy link
Member

This add a args feature, for example if your arg is called argreply

You can do: `?reply Hello, read the following: {argreply}

This add a args feature, for example if your arg is called `argreply`

You can do: `?reply Hello, read the following: {argreply}
@lorenzo132 lorenzo132 mentioned this pull request Dec 13, 2025
2 tasks
@lorenzo132 lorenzo132 changed the title Users/lorenzo132/arged responses arged responses Dec 13, 2025
martinbndr
martinbndr previously approved these changes Dec 13, 2025
@StephenDaDev StephenDaDev removed the request for review from ModmailTest December 14, 2025 01:34
StephenDaDev
StephenDaDev previously approved these changes Dec 14, 2025
@lorenzo132 lorenzo132 dismissed stale reviews from StephenDaDev and martinbndr via fed5044 December 14, 2025 02:42
StephenDaDev
StephenDaDev previously approved these changes Dec 14, 2025
@StephenDaDev StephenDaDev added the changelog Changes in PR have been added to draft release that will be used for the changelog on the next ver. label Dec 18, 2025

This comment was marked as spam.

Copilot AI review requested due to automatic review settings January 16, 2026 12:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 10 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +568 to +569
if name not in self.bot.args:
embed = create_not_found_embed(name, self.bot.args.keys(), "Arg")
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The args command uses direct name lookup without resolving through aliases like the snippet command does with _resolve_snippet. This creates an inconsistency where snippets can be accessed via their aliases but args cannot. Consider adding a _resolve_arg method similar to _resolve_snippet to provide consistent behavior.

Copilot uses AI. Check for mistakes.
cogs/modmail.py Outdated

When `{prefix}args` is used by itself, this will retrieve
a list of args that are currently set. `{prefix}args name` will show what the
arg point to.
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description for the args command docstring says "arg point to" which is grammatically incorrect. It should be "arg points to" (singular verb agreement).

Suggested change
arg point to.
arg points to.

Copilot uses AI. Check for mistakes.
To create an arg:
- `{prefix}args add arg-name A value.`

You can use your arg in a reply with `{arg-name}`.
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation states "You can use your arg in a reply with {arg-name}" but doesn't mention that args only work in certain reply commands (reply, freply, fareply, fpreply, fpareply) and not in others (areply, preply, pareply). Consider updating the documentation to clarify which commands support args to avoid user confusion.

Suggested change
You can use your arg in a reply with `{arg-name}`.
You can use your arg in supported reply commands (`
reply`, `freply`, `fareply`, `fpreply`, `fpareply`) with `{arg-name}`. Args are
not available in `areply`, `preply`, or `pareply`.

Copilot uses AI. Check for mistakes.
if not self.bot.args:
embed = discord.Embed(
color=self.bot.error_color,
description="You dont have any args at the moment.",
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent contraction usage: "dont" should be "don't" with an apostrophe.

Suggested change
description="You dont have any args at the moment.",
description="You don't have any args at the moment.",

Copilot uses AI. Check for mistakes.
Comment on lines +1727 to 1730
**self.bot.args,
channel=ctx.channel,
recipient=ctx.thread.recipient,
author=ctx.message.author,
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the freply, fareply, fpreply, and fpareply commands, args are added before the built-in variables (channel, recipient, author). This means that if an arg is named "channel", "recipient", or "author", it will be overridden by the built-in variables, potentially causing unexpected behavior. Consider either adding args after the built-in variables (so built-in variables take precedence) or documenting this behavior and warning users not to use reserved names.

Copilot uses AI. Check for mistakes.
martinbndr
martinbndr previously approved these changes Jan 16, 2026
StephenDaDev
StephenDaDev previously approved these changes Feb 28, 2026
Signed-off-by: lorenzo132 <50767078+lorenzo132@users.noreply.github.com>
@lorenzo132 lorenzo132 dismissed stale reviews from StephenDaDev and martinbndr via d683a42 March 1, 2026 19:38
@martinbndr martinbndr requested a review from StephenDaDev March 2, 2026 10:29
Copy link
Member

@sebkuip sebkuip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some issues in this PR that need to be addressed beforehand.

"""

if self.bot.args:
msg = UnseenFormatter().format(msg, **self.bot.args)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no check for total message length after applying args. If I make an arg that's very long (I tested with a long part of lorem ipsum) then make a long reply plus the arg going over the limit, I just get an "unknown error". The bot logs show it goes over the limit.
As per the docs (screenshot below), the total length of an embed cannot exceed 6000 characters, and the descritpion may only be 4096 characters long. Please add a check to give a human error.

Image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the result of a long message
Image

Image

description=f'`{name}` has been renamed to "{value}".',
)
else:
embed = create_not_found_embed(name, self.bot.args.keys(), "Arg")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For readability, this might be better fit as a guard clause at the start of the function. So

if name not in self.bot.args:
    return await ctx.send(embed=create_not_found_embed(name, self.bot.args.keys(), "Arg"))

or alternatively

if name not in self.bot.args:
    embed = create_not_found_embed(name, self.bot.args.keys(), "Arg")
    return await ctx.send(embed=embed)

{prefix}args add name value
```
"""
if name in self.bot.args:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also check that there is no conflict with the keywords from formatreply (channel, recipient and author). Currently this causes a silent fail without error. See screenshots.

Image Image

"""

if self.bot.args:
msg = UnseenFormatter().format(msg, **self.bot.args)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace this formatter to be consistent with how formatreply works (using self.bot.formater.format())
This is done correctly in the formatreply command.


def process_help_msg(self, help_: str):
return help_.format(prefix=self.context.clean_prefix) if help_ else "No help message."
return help_.replace("{prefix}", self.context.clean_prefix) if help_ else "No help message."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this being changed out? As far as I'm aware, the format() call was working just fine. If really needed, please elaborate why this is changed out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog Changes in PR have been added to draft release that will be used for the changelog on the next ver.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants