aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar kosayoda <[email protected]>2020-07-16 13:10:28 +0800
committerGravatar kosayoda <[email protected]>2020-07-16 13:10:28 +0800
commit76b8e4625e853bcc96c946fa408c2267e78dbc72 (patch)
tree47332a55e460f1ac1952ce824a1c62c93b054781
parentAdd method to check if user is allowed to mention in reminders. (diff)
Add generator that converts IDs to Role or Member objects.
-rw-r--r--bot/cogs/reminders.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/bot/cogs/reminders.py b/bot/cogs/reminders.py
index aefc4a359..ab47f3b11 100644
--- a/bot/cogs/reminders.py
+++ b/bot/cogs/reminders.py
@@ -130,6 +130,13 @@ class Reminders(Cog):
else:
return True, ""
+ def get_mentionables_from_ids(self, mention_ids: t.List[str]) -> t.Iterator[Mentionable]:
+ """Converts Role and Member ids to their corresponding objects if possible."""
+ guild = self.bot.get_guild(Guild.id)
+ for mention_id in mention_ids:
+ if (mentionable := (guild.get_member(mention_id) or guild.get_role(mention_id))):
+ yield mentionable
+
def schedule_reminder(self, reminder: dict) -> None:
"""A coroutine which sends the reminder once the time is reached, and cancels the running task."""
reminder_id = reminder["id"]