-
-
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
71a8f54
041b23e
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -25,6 +25,10 @@ | |||||
| logger = getLogger(__name__) | ||||||
|
|
||||||
|
|
||||||
| # Arg names reserved by formatreply commands (channel, recipient, author). | ||||||
| RESERVED_ARG_NAMES = {"channel", "recipient", "author"} | ||||||
|
|
||||||
|
|
||||||
| class Modmail(commands.Cog): | ||||||
| """Commands directly related to Modmail functionality.""" | ||||||
|
|
||||||
|
|
@@ -209,7 +213,7 @@ async def snippet(self, ctx, *, name: str.lower = None): | |||||
|
|
||||||
| When `{prefix}snippet` is used by itself, this will retrieve | ||||||
| a list of snippets that are currently set. `{prefix}snippet-name` will show what the | ||||||
| snippet point to. | ||||||
| snippet points to. | ||||||
|
|
||||||
| To create a snippet: | ||||||
| - `{prefix}snippet add snippet-name A pre-defined text.` | ||||||
|
|
@@ -535,6 +539,214 @@ 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") | ||||||
|
lorenzo132 marked this conversation as resolved.
|
||||||
| 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.", |
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 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
Uh oh!
There was an error while loading. Please reload this page.