Skip to content

arged responses#3418

Open
lorenzo132 wants to merge 14 commits into
developmentfrom
users/lorenzo132/arged-responses
Open

arged responses#3418
lorenzo132 wants to merge 14 commits into
developmentfrom
users/lorenzo132/arged-responses

Conversation

@lorenzo132

Copy link
Copy Markdown
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
Comment thread cogs/modmail.py
Comment thread cogs/modmail.py
@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
martinbndr
martinbndr previously approved these changes Mar 2, 2026
@martinbndr
martinbndr requested a review from StephenDaDev March 2, 2026 10:29
StephenDaDev
StephenDaDev previously approved these changes Mar 4, 2026

@sebkuip sebkuip left a comment

Copy link
Copy Markdown
Member

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.

Comment thread cogs/modmail.py
Comment thread cogs/modmail.py Outdated
Comment thread cogs/modmail.py
Comment thread cogs/modmail.py
Comment thread cogs/utility.py Outdated
@StephenDaDev StephenDaDev removed the changelog Changes in PR have been added to draft release that will be used for the changelog on the next ver. label Jun 15, 2026
@StephenDaDev

Copy link
Copy Markdown
Member

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

@lorenzo132
lorenzo132 dismissed stale reviews from StephenDaDev and martinbndr via 041b23e June 15, 2026 16:53
@lorenzo132
lorenzo132 requested review from StephenDaDev, martinbndr and sebkuip and removed request for martinbndr June 15, 2026 16:54
martinbndr
martinbndr previously approved these changes Jun 20, 2026

@martinbndr martinbndr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me

StephenDaDev
StephenDaDev previously approved these changes Jul 13, 2026

@StephenDaDev StephenDaDev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

seems fine w/ changes

@sebkuip sebkuip left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I found some bugs, and some typos. Please have these fixed. Thanks!

Comment thread cogs/modmail.py Outdated

@sebkuip sebkuip Jul 13, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Small typo here, pointed out by copilot. "don't" is missing it's apostrophe

Comment thread cogs/modmail.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would change this text to See"{self.bot.prefix}help args add" for how to add an arg.

Comment thread cogs/modmail.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Needs a comma after "simply"

Comment thread cogs/modmail.py Outdated

if self.bot.args:
msg = UnseenFormatter().format(msg, **self.bot.args)
msg = self.bot.formatter.format(msg, **self.bot.args)

@sebkuip sebkuip Jul 13, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.
Image
Image

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

Formatreply correctly works and doesn't cause issues

@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 Jul 13, 2026
Copilot AI review requested due to automatic review settings July 18, 2026 22:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 1 comment.

Comments suppressed due to low confidence (2)

cogs/modmail.py:1726

  • In the reply command, running SafeFormatter.format() on every message when any args exist will replace any unknown {...} placeholders with "<Invalid>" (per SafeFormatter.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 use freply for 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.",
            )

Comment thread cogs/modmail.py
Copilot AI review requested due to automatic review settings July 18, 2026 23:00
@lorenzo132
lorenzo132 dismissed stale reviews from StephenDaDev and martinbndr via 8d97f94 July 18, 2026 23:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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_edit stores the new value without commands.clean_content, while args_add uses clean_content. This makes edits behave differently than adds and can reintroduce mentions/markdown that add would 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.args alongside explicit channel=..., recipient=..., author=... can raise TypeError: got multiple values for keyword argument if 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.args together with explicit channel/recipient/author can throw TypeError if 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.args together with explicit channel/recipient/author can throw TypeError if 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.args together with explicit channel/recipient/author can throw TypeError if 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,

Comment thread core/models.py
Comment on lines +391 to +395
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():
Comment thread cogs/modmail.py
Comment on lines +552 to +556
To create an arg:
- `{prefix}args add arg-name A value.`

You can use your arg in a reply with `{arg-name}`.
"""
Comment thread cogs/modmail.py
Comment on lines +650 to +656
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)
Comment thread cogs/modmail.py
Comment on lines +730 to +736
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)
Comment thread cogs/modmail.py
)
return await ctx.send(embed=embed)

embeds = [discord.Embed(color=self.bot.main_color) for _ in range((len(self.bot.args) // 10) + 1)]
Comment thread cogs/modmail.py
Comment on lines +1725 to +1727
if self.bot.args:
msg = UnseenFormatter().format(msg, **self.bot.args)

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