aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/holidays/halloween/candy_collection.py
diff options
context:
space:
mode:
authorGravatar Izan <[email protected]>2021-12-30 23:41:58 +0000
committerGravatar Izan <[email protected]>2021-12-30 23:41:58 +0000
commit17bcd45c68f144f3b88fdfdf05bd0db654c0322e (patch)
treead07a6a449a322165d7246699908256c2df7a047 /bot/exts/holidays/halloween/candy_collection.py
parentMigrate to `og_blurple` (diff)
parentMerge pull request #994 from python-discord/logging-in-AoC-completer-task (diff)
Merge remote-tracking branch 'origin/main' into main
# Conflicts: # bot/exts/holidays/halloween/candy_collection.py
Diffstat (limited to 'bot/exts/holidays/halloween/candy_collection.py')
-rw-r--r--bot/exts/holidays/halloween/candy_collection.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/bot/exts/holidays/halloween/candy_collection.py b/bot/exts/holidays/halloween/candy_collection.py
index 079d900d..729bbc97 100644
--- a/bot/exts/holidays/halloween/candy_collection.py
+++ b/bot/exts/holidays/halloween/candy_collection.py
@@ -83,6 +83,11 @@ class CandyCollection(commands.Cog):
# if its not a candy or skull, and it is one of 10 most recent messages,
# proceed to add a skull/candy with higher chance
if str(reaction.emoji) not in (EMOJIS["SKULL"], EMOJIS["CANDY"]):
+ # Ensure the reaction is not for a bot's message so users can't spam
+ # reaction buttons like in .help to get candies.
+ if message.author.bot:
+ return
+
recent_message_ids = map(
lambda m: m.id,
await self.hacktober_channel.history(limit=10).flatten()
@@ -182,6 +187,12 @@ class CandyCollection(commands.Cog):
for index, record in enumerate(top_five)
) if top_five else "No Candies"
+ def get_user_candy_score() -> str:
+ for user_id, score in records:
+ if user_id == ctx.author.id:
+ return f"{ctx.author.mention}: {score}"
+ return f"{ctx.author.mention}: 0"
+
e = discord.Embed(colour=discord.Colour.og_blurple())
e.add_field(
name="Top Candy Records",
@@ -189,6 +200,11 @@ class CandyCollection(commands.Cog):
inline=False
)
e.add_field(
+ name="Your Candy Score",
+ value=get_user_candy_score(),
+ inline=False
+ )
+ e.add_field(
name="\u200b",
value="Candies will randomly appear on messages sent. "
"\nHit the candy when it appears as fast as possible to get the candy! "