From 3e00e7fe8af80654c61ebc08a3ac379b0ff3603d Mon Sep 17 00:00:00 2001
From: Jake <me@jh.gg>
Date: Wed, 20 Sep 2017 21:08:46 -0700
Subject: [PATCH] [guild] use a defaultdict in by_category

---
 discord/guild.py | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/discord/guild.py b/discord/guild.py
index 23eb8ebca..bdb064034 100644
--- a/discord/guild.py
+++ b/discord/guild.py
@@ -27,7 +27,7 @@ DEALINGS IN THE SOFTWARE.
 import copy
 import asyncio
 
-from collections import namedtuple
+from collections import namedtuple, defaultdict
 
 from . import utils
 from .role import Role
@@ -332,17 +332,12 @@ class Guild(Hashable):
         List[Tuple[Optional[:class:`CategoryChannel`], List[:class:`abc.GuildChannel`]]]:
             The categories and their associated channels.
         """
-        grouped = {}
+        grouped = defaultdict(list)
         for channel in self._channels.values():
             if isinstance(channel, CategoryChannel):
                 continue
 
-            try:
-                channels = grouped[channel.category_id]
-            except KeyError:
-                channels = grouped[channel.category_id] = []
-
-            channels.append(channel)
+            grouped[channel.category_id].append(channel)
 
         def key(t):
             k, v = t