Skip to content

Add ability to disable mention on thread creation. #2951

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

Merged
merged 4 commits into from
Mar 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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