From b000c9173eb1176bae29e7e1874e7faf3ef7914f Mon Sep 17 00:00:00 2001 From: classabbyamp Date: Sat, 28 Jan 2023 19:57:40 -0500 Subject: [PATCH 1/2] common.py: don't error when creating embeds for users without avatars behaviour changed in pycord 2.0: https://docs.pycord.dev/en/stable/api/models.html#discord.User.display_avatar fixes #467 --- CHANGELOG.md | 2 ++ common.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29e8fb8..b55aa43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +### Fixed +- Issue where embeds would not work for users without avatars (#467). ## [2.9.0] - 2023-01-13 diff --git a/common.py b/common.py index 4a6ba8f..3111696 100644 --- a/common.py +++ b/common.py @@ -167,7 +167,7 @@ def embed_factory(ctx: commands.Context) -> discord.Embed: """Creates an embed with neutral colour and standard footer.""" embed = discord.Embed(timestamp=datetime.utcnow(), colour=colours.neutral) if ctx.author: - embed.set_footer(text=str(ctx.author), icon_url=str(ctx.author.avatar.url)) + embed.set_footer(text=str(ctx.author), icon_url=str(ctx.author.display_avatar)) return embed From d7de78e5826afb155eea81f1b1d60995481bbc7c Mon Sep 17 00:00:00 2001 From: classabbyamp Date: Sat, 28 Jan 2023 20:09:38 -0500 Subject: [PATCH 2/2] common.py: use tz-aware datetime for proper timestamp display https://docs.pycord.dev/en/stable/api/data_classes.html#discord.Embed.timestamp --- CHANGELOG.md | 1 + common.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b55aa43..c96e44a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ### Fixed - Issue where embeds would not work for users without avatars (#467). +- Issue where embeds would show the wrong timezone. ## [2.9.0] - 2023-01-13 diff --git a/common.py b/common.py index 3111696..15145ca 100644 --- a/common.py +++ b/common.py @@ -12,7 +12,7 @@ import enum import json import re import traceback -from datetime import datetime +from datetime import datetime, timezone from pathlib import Path from types import SimpleNamespace from typing import Union @@ -165,7 +165,7 @@ class GlobalChannelConverter(commands.IDConverter): def embed_factory(ctx: commands.Context) -> discord.Embed: """Creates an embed with neutral colour and standard footer.""" - embed = discord.Embed(timestamp=datetime.utcnow(), colour=colours.neutral) + embed = discord.Embed(timestamp=datetime.now(timezone.utc), colour=colours.neutral) if ctx.author: embed.set_footer(text=str(ctx.author), icon_url=str(ctx.author.display_avatar)) return embed