Skip to content

Commit 4054c51

Browse files
committed
Ability to disable mention on thread creation.
1 parent 7b2e63d commit 4054c51

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

cogs/utility.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,20 +674,41 @@ async def ping(self, ctx):
674674

675675
@commands.command()
676676
@checks.has_permissions(PermissionLevel.ADMINISTRATOR)
677-
async def mention(self, ctx, *mention: Union[discord.Role, discord.Member]):
677+
async def mention(self, ctx, *mention: Union[discord.Role, discord.Member, str]):
678678
"""
679679
Change what the bot mentions at the start of each thread.
680680
681681
Type only `{prefix}mention` to retrieve your current "mention" message.
682+
`{prefix}mention disable` to disable mention.
683+
`{prefix}mention reset` to reset it to default value.
682684
"""
683-
# TODO: ability to disable mention.
684685
current = self.bot.config["mention"]
685-
686686
if not mention:
687687
embed = discord.Embed(
688688
title="Current mention:", color=self.bot.main_color, description=str(current)
689689
)
690+
elif (
691+
len(mention) == 1
692+
and isinstance(mention[0], str)
693+
and mention[0] in ["disable", "reset"]
694+
):
695+
option = mention[0]
696+
if option == "disable":
697+
embed = discord.Embed(
698+
description=f"Disabled mention on thread creation.",
699+
color=self.bot.main_color,
700+
)
701+
self.bot.config["mention"] = None
702+
else:
703+
embed = discord.Embed(
704+
description="`mention` had been reset to default.", color=self.bot.main_color,
705+
)
706+
self.bot.config.remove("mention")
707+
await self.bot.config.update()
690708
else:
709+
for m in mention:
710+
if not isinstance(m, (discord.Role, discord.Member)):
711+
raise commands.BadArgument(f'Role or Member "{m}" not found.')
691712
mention = " ".join(i.mention for i in mention)
692713
embed = discord.Embed(
693714
title="Changed mention!",

0 commit comments

Comments
 (0)