Skip to content

Commit

Permalink
Merge branch 'dev-01' of https://github.com/Jerrie-Aries/modmail into…
Browse files Browse the repository at this point in the history
… Jerrie-Aries-dev-01
  • Loading branch information
fourjr committed Mar 7, 2021
2 parents 41d5593 + 270483f commit ae88073
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
6 changes: 5 additions & 1 deletion cogs/modmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,11 @@ async def move(self, ctx, *, arguments):

if self.bot.config["thread_move_notify_mods"]:
mention = self.bot.config["mention"]
await thread.channel.send(f"{mention}, thread has been moved.")
if mention is not None:
msg = f"{mention}, thread has been moved."
else:
msg = "Thread has been moved."
await thread.channel.send(msg)

sent_emoji, _ = await self.bot.retrieve_emoji()
await self.bot.add_reaction(ctx.message, sent_emoji)
Expand Down
26 changes: 23 additions & 3 deletions cogs/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,20 +674,40 @@ async def ping(self, ctx):

@commands.command()
@checks.has_permissions(PermissionLevel.ADMINISTRATOR)
async def mention(self, ctx, *mention: Union[discord.Role, discord.Member]):
async def mention(self, ctx, *mention: Union[discord.Role, discord.Member, str]):
"""
Change what the bot mentions at the start of each thread.
Type only `{prefix}mention` to retrieve your current "mention" message.
`{prefix}mention disable` to disable mention.
`{prefix}mention reset` to reset it to default value.
"""
# TODO: ability to disable mention.
current = self.bot.config["mention"]

if not mention:
embed = discord.Embed(
title="Current mention:", color=self.bot.main_color, description=str(current)
)
elif (
len(mention) == 1
and isinstance(mention[0], str)
and mention[0].lower() in ["disable", "reset"]
):
option = mention[0].lower()
if option == "disable":
embed = discord.Embed(
description=f"Disabled mention on thread creation.", color=self.bot.main_color,
)
self.bot.config["mention"] = None
else:
embed = discord.Embed(
description="`mention` is reset to default.", color=self.bot.main_color,
)
self.bot.config.remove("mention")
await self.bot.config.update()
else:
for m in mention:
if not isinstance(m, (discord.Role, discord.Member)):
raise commands.BadArgument(f'Role or Member "{m}" not found.')
mention = " ".join(i.mention for i in mention)
embed = discord.Embed(
title="Changed mention!",
Expand Down

0 comments on commit ae88073

Please sign in to comment.