aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2021-08-12 18:44:25 +0100
committerGravatar Chris Lovering <[email protected]>2021-08-12 19:22:42 +0100
commit446c86f54ae92ee0cde9a52f2e3bf09362e0add4 (patch)
tree0d35afbe8980b909d82047362f267a6b922af3fe
parentGive lovefest unsub info in lovecalc footer (diff)
Don't role check if running lovecalc on yourself
This skips the role check if the author is running the love calc command on themselves. We still want to check the the user running against has the role, along with if the author is running it against 2 other people. i have also included info on how to get the lovefest role in the error embed.
-rw-r--r--bot/exts/valentines/lovecalculator.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/bot/exts/valentines/lovecalculator.py b/bot/exts/valentines/lovecalculator.py
index b59e60ad..1cb10e64 100644
--- a/bot/exts/valentines/lovecalculator.py
+++ b/bot/exts/valentines/lovecalculator.py
@@ -12,7 +12,7 @@ from discord.ext import commands
from discord.ext.commands import BadArgument, Cog, clean_content
from bot.bot import Bot
-from bot.constants import Client, Lovefest, Month
+from bot.constants import Channels, Client, Lovefest, Month
from bot.utils.decorators import in_month
log = logging.getLogger(__name__)
@@ -44,15 +44,19 @@ class LoveCalculator(Cog):
Running .love @joe#6000 @chrisjl#2655 will always yield the same result.
Running .love @chrisjl#2655 @joe#6000 will yield the same result as before.
"""
+ if (
+ Lovefest.role_id not in [role.id for role in who.roles]
+ or (whom is not None and Lovefest.role_id not in [role.id for role in whom.roles])
+ ):
+ raise BadArgument(
+ "This command can only be ran against members with the lovefest role! "
+ "This role be can assigned by running "
+ f"`{Client.prefix}lovefest sub` in <#{Channels.community_bot_commands}>."
+ )
+
if whom is None:
whom = ctx.author
- if not all((
- Lovefest.role_id in [role.id for role in who.roles],
- Lovefest.role_id in [role.id for role in whom.roles]
- )):
- raise BadArgument("Both members must have the lovefest role!")
-
def normalize(arg: Member) -> Coroutine:
# This has to be done manually to be applied to usernames
return clean_content(escape_markdown=True).convert(ctx, str(arg))