From a0440713875573dd2e3f7d01586f2fd7672e4e3f Mon Sep 17 00:00:00 2001 From: Conatum Date: Tue, 19 Oct 2021 19:42:43 +0300 Subject: [PATCH] style (settings): Don't display deleted channels. Hides deleted or inexistent channels in the formatted settings. --- bot/settings/setting_types.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bot/settings/setting_types.py b/bot/settings/setting_types.py index e362034b..25a63faa 100644 --- a/bot/settings/setting_types.py +++ b/bot/settings/setting_types.py @@ -295,13 +295,17 @@ class Channel(SettingType): @classmethod def _format_data(cls, id: int, data: Optional[int], **kwargs): """ - Retrieve an artificially created channel mention. - If the channel does not exist, this will show up as invalid-channel. + Retrieve the channel mention, if the channel still exists. + If the channel no longer exists, or cannot be seen by the client, returns None. """ if data is None: return None else: - return "<#{}>".format(data) + channel = client.get_channel(data) + if channel: + return channel.mention + else: + return None class VoiceChannel(Channel):