Skip to content

Commit

Permalink
Add support for trailing space in prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
raidensakura committed May 28, 2023
1 parent 2cba222 commit 884c845
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ however, insignificant breaking changes do not guarantee a major version bump, s
- Added custom database name detection in `CONNECTION_URI`
- Added dpy and python version info in `?about` embed and credit for contributors
- New config option: `mention_message`, this will include an additional configurable message next to role mention on thread creation. Defaults to None.
- Support for trailing space in `?prefix` command, `?prefix "mm "

### Changed
- Guild icons in embed footers and author urls now have a fixed size of 128. ([PR #3261](https://github.com/modmail-dev/modmail/pull/3261))
Expand Down
12 changes: 9 additions & 3 deletions cogs/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,17 +785,23 @@ async def prefix(self, ctx, *, prefix=None):
Change the prefix of the bot.
Type only `{prefix}prefix` to retrieve your current bot prefix.
Enclose your prefix in doublequotes to include trailing spaces.
Example: `{prefix}prefix "mm "`
"""

current = self.bot.prefix
embed = discord.Embed(title="Current prefix", color=self.bot.main_color, description=f"{current}")
embed = discord.Embed(title="Current prefix", color=self.bot.main_color, description=f"`{current}`")

if prefix is None:
await ctx.send(embed=embed)
else:
pattern = r'"([^"]{1,19})"'
match = re.search(pattern, prefix)

embed.title = "Changed prefix!"
embed.description = f"Set prefix to `{prefix}`"
self.bot.config["prefix"] = prefix
embed.description = f"Set prefix to `{match.group(1) if match else prefix}`"
self.bot.config["prefix"] = match.group(1) if match else prefix
await self.bot.config.update()
await ctx.send(embed=embed)

Expand Down

0 comments on commit 884c845

Please sign in to comment.