aboutsummaryrefslogtreecommitdiff
path: root/question_of_the_day
diff options
context:
space:
mode:
authorArjun Satarkar <me@arjunsatarkar.net>2023-12-22 14:32:58 +0000
committerArjun Satarkar <me@arjunsatarkar.net>2023-12-22 14:32:58 +0000
commitb3cadb61824a3ae07de4ca2d89f405dc979e1326 (patch)
tree3a1b8883012aae7dd7b0ffa27d926ad433585f1c /question_of_the_day
parent970877c52f2722c1cd4ecb47ef1a9edd68f88e88 (diff)
downloadaps-cogs-b3cadb61824a3ae07de4ca2d89f405dc979e1326.tar
aps-cogs-b3cadb61824a3ae07de4ca2d89f405dc979e1326.tar.gz
aps-cogs-b3cadb61824a3ae07de4ca2d89f405dc979e1326.zip
question_of_the_day: switch to using an embed
Diffstat (limited to 'question_of_the_day')
-rw-r--r--question_of_the_day/data/abstract_swirl/README.txt3
-rw-r--r--question_of_the_day/data/abstract_swirl/abstract_swirl_160x160.pngbin0 -> 58787 bytes
-rw-r--r--question_of_the_day/question_of_the_day.py35
3 files changed, 34 insertions, 4 deletions
diff --git a/question_of_the_day/data/abstract_swirl/README.txt b/question_of_the_day/data/abstract_swirl/README.txt
new file mode 100644
index 0000000..985d763
--- /dev/null
+++ b/question_of_the_day/data/abstract_swirl/README.txt
@@ -0,0 +1,3 @@
+Image from https://publicdomainpictures.net/en/view-image.php?image=138773&picture=absztrakt-orveny
+Author: Kevin Phillips
+CC0 (public domain)
diff --git a/question_of_the_day/data/abstract_swirl/abstract_swirl_160x160.png b/question_of_the_day/data/abstract_swirl/abstract_swirl_160x160.png
new file mode 100644
index 0000000..2a8f1ed
--- /dev/null
+++ b/question_of_the_day/data/abstract_swirl/abstract_swirl_160x160.png
Binary files differ
diff --git a/question_of_the_day/question_of_the_day.py b/question_of_the_day/question_of_the_day.py
index bd5f4ea..92335ba 100644
--- a/question_of_the_day/question_of_the_day.py
+++ b/question_of_the_day/question_of_the_day.py
@@ -7,11 +7,13 @@ import redbot.core
import copy
import datetime
import logging
+import pathlib
import random
import time
MAX_QUESTIONS_PER_GUILD = 1000
MAX_QUESTION_SIZE = 500
+ICON_PATH = pathlib.Path("abstract_swirl/abstract_swirl_160x160.png")
class QuestionOfTheDay(commands.Cog):
@@ -325,17 +327,42 @@ class QuestionOfTheDay(commands.Cog):
else:
question_index = random.randrange(0, questions_len)
question = questions[question_index]
+
asked_by = await guild.fetch_member(question["asked_by"])
allowed_mentions = discord.AllowedMentions.none()
allowed_mentions.users = [asked_by]
- message = await channel.send(
- f"**Question of the day:** "
- f"{question['question']}\n"
+
+ embed = discord.Embed(
+ description=question["question"]
+ + "\n"
+ redbot.core.utils.chat_formatting.italics(
- "asked by " + asked_by.mention
+ "asked by" + asked_by.mention
+ )
+ )
+ embed.set_author(
+ name="Question of the Day",
+ icon_url=f"attachment://{ICON_PATH.name}",
+ )
+ footer = f"{questions_len - 1} questions left | "
+ suggestions_count = len(
+ await self.config.guild(guild).suggested_questions()
+ )
+ footer += (
+ f"{suggestions_count} suggestion{'s' if suggestions_count > 1 else ''}"
+ if suggestions_count
+ else "no suggestions yet! use qotd suggest"
+ )
+ embed.set_footer(text=footer)
+
+ message = await channel.send(
+ embed=embed,
+ file=discord.File(
+ redbot.core.data_manager.bundled_data_path(self) / ICON_PATH,
+ ICON_PATH.name,
),
allowed_mentions=allowed_mentions,
)
+
del questions[question_index]
await self.manage_qotd_pins(message)
self.logger.info(f"Posted QOTD for guild {guild.name} ({guild.id}).")