-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
arged responses #3418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
arged responses #3418
Changes from all commits
312f137
0bd96b8
fed5044
3972f9c
b3dd8a0
b1136e5
bab4fdb
95751df
f88a000
d683a42
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,7 +16,7 @@ | |||||||||
| from dateutil import parser | ||||||||||
|
|
||||||||||
| from core import checks | ||||||||||
| from core.models import DMDisabled, PermissionLevel, SimilarCategoryConverter, getLogger | ||||||||||
| from core.models import DMDisabled, PermissionLevel, SimilarCategoryConverter, UnseenFormatter, getLogger | ||||||||||
| from core.paginator import EmbedPaginatorSession | ||||||||||
| from core.thread import Thread | ||||||||||
| from core.time import UserFriendlyTime, human_timedelta | ||||||||||
|
|
@@ -535,6 +535,195 @@ async def snippet_rename(self, ctx, name: str.lower, *, value): | |||||||||
| embed = create_not_found_embed(name, self.bot.snippets.keys(), "Snippet") | ||||||||||
| await ctx.send(embed=embed) | ||||||||||
|
|
||||||||||
| @commands.group(invoke_without_command=True) | ||||||||||
| @checks.has_permissions(PermissionLevel.SUPPORTER) | ||||||||||
| async def args(self, ctx, *, name: str.lower = None): | ||||||||||
| """ | ||||||||||
| Create dynamic args for use in replies. | ||||||||||
|
|
||||||||||
| 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 points to. | ||||||||||
|
|
||||||||||
| To create an arg: | ||||||||||
| - `{prefix}args add arg-name A value.` | ||||||||||
|
|
||||||||||
| You can use your arg in a reply with `{arg-name}`. | ||||||||||
| """ | ||||||||||
|
|
||||||||||
| if name is not None: | ||||||||||
| if name == "compact": | ||||||||||
| embeds = [] | ||||||||||
|
|
||||||||||
| for i, names in enumerate(zip_longest(*(iter(sorted(self.bot.args)),) * 15)): | ||||||||||
| description = format_description(i, names) | ||||||||||
| embed = discord.Embed(color=self.bot.main_color, description=description) | ||||||||||
| embed.set_author(name="Args", icon_url=self.bot.get_guild_icon(guild=ctx.guild, size=128)) | ||||||||||
| embeds.append(embed) | ||||||||||
|
|
||||||||||
| session = EmbedPaginatorSession(ctx, *embeds) | ||||||||||
| await session.run() | ||||||||||
| return | ||||||||||
|
|
||||||||||
| if name not in self.bot.args: | ||||||||||
| embed = create_not_found_embed(name, self.bot.args.keys(), "Arg") | ||||||||||
|
Comment on lines
+568
to
+569
|
||||||||||
| else: | ||||||||||
| val = self.bot.args[name] | ||||||||||
| embed = discord.Embed( | ||||||||||
| title=f'Arg - "{name}":', | ||||||||||
| description=val, | ||||||||||
| color=self.bot.main_color, | ||||||||||
| ) | ||||||||||
| return await ctx.send(embed=embed) | ||||||||||
|
|
||||||||||
| if not self.bot.args: | ||||||||||
| embed = discord.Embed( | ||||||||||
| color=self.bot.error_color, | ||||||||||
| description="You dont have any args at the moment.", | ||||||||||
|
||||||||||
| description="You dont have any args at the moment.", | |
| description="You don't have any args at the moment.", |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
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.
| description="You dont have any args at the moment.", | |
| description="You don't have any args at the moment.", |
lorenzo132 marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sebkuip marked this conversation as resolved.
Show resolved
Hide resolved
sebkuip marked this conversation as resolved.
Show resolved
Hide resolved
sebkuip marked this conversation as resolved.
Show resolved
Hide resolved
lorenzo132 marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment.
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)
sebkuip marked this conversation as resolved.
Show resolved
Hide resolved
sebkuip marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
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.
sebkuip marked this conversation as resolved.
Show resolved
Hide resolved
sebkuip marked this conversation as resolved.
Show resolved
Hide resolved
sebkuip marked this conversation as resolved.
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -109,7 +109,7 @@ async def format_cog_help(self, cog, *, no_cog=False): | |
| return embeds | ||
|
|
||
| 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." | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
|
||
sebkuip marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| async def send_bot_help(self, mapping): | ||
| embeds = [] | ||
|
|
||




There was a problem hiding this comment.
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.