mirror of
https://github.com/UiO-Gaming/mustafa.git
synced 2026-11-05 13:56:48 +01:00
speed up /bursdag kommende
This commit is contained in:
1 file changed
+9
-7
@@ -399,18 +399,20 @@ class Birthday(commands.Cog):
|
||||
if not next_birthdays:
|
||||
return await interaction.followup.send(embed=embed_templates.error_warning("Ingen bursdager"))
|
||||
|
||||
# The members intent keeps every member cached, so names can be looked up without an API request each.
|
||||
# The cache is filled when the bot starts, so make sure it's done if the command is used right after
|
||||
if not interaction.guild.chunked:
|
||||
await interaction.guild.chunk()
|
||||
|
||||
birthday_strings = []
|
||||
for user in next_birthdays:
|
||||
user_id, _, next_birthday = user
|
||||
try:
|
||||
discord_user = await interaction.guild.fetch_member(user_id)
|
||||
except (discord.NotFound, discord.HTTPException):
|
||||
continue
|
||||
for user_id, _, next_birthday in next_birthdays:
|
||||
if not (member := interaction.guild.get_member(user_id)):
|
||||
continue # The user has left the server
|
||||
|
||||
next_birthday = misc_utils.localize(next_birthday, self.bot.timezone)
|
||||
timestamp = discord.utils.format_dt(next_birthday, style="D")
|
||||
relative_timestamp = discord.utils.format_dt(next_birthday, style="R")
|
||||
birthday_strings.append(f"* {discord_user.name} - {timestamp} ({relative_timestamp})")
|
||||
birthday_strings.append(f"* {member.name} - {timestamp} ({relative_timestamp})")
|
||||
|
||||
if not birthday_strings:
|
||||
return await interaction.followup.send(embed=embed_templates.error_warning("Ingen bursdager"))
|
||||
|
||||
Reference in new issue
Block a user