From f94b00cb48f3763dc3119d28717567ea6dc9e131 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sat, 27 Jun 2020 05:27:47 -0400 Subject: [PATCH] Fix a KeyError for channels with no category in Guild.by_category --- discord/guild.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/discord/guild.py b/discord/guild.py index b675150f9..7e24b4b47 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -412,7 +412,10 @@ class Guild(Hashable): grouped[channel.id] = [] continue - grouped[channel.category_id].append(channel) + try: + grouped[channel.category_id].append(channel) + except KeyError: + grouped[channel.category_id] = [channel] def key(t): k, v = t