Skip to content

Commit 57d8e64

Browse files
committed
feat(implement:Forums): Fixed general crash when forum channel posts are created
1 parent 5363e3f commit 57d8e64

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

discord/automod.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ def from_dict(cls, data: Dict[str, Any]) -> AutoModTriggerMetadata:
284284
if presets:
285285
self.presets = data['presets']
286286
else:
287-
self.keyword_filter = data['keyword_filter']
287+
self.keyword_filter = data.get('keyword_filter', None)
288288
return self
289289

290290

discord/channel.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,6 +1909,17 @@ async def leave(self):
19091909
await self._state.http.leave_group(self.id)
19101910

19111911

1912+
class ForumChannel(Hashable):
1913+
def __init__(self, *, state, guild, data) -> None:
1914+
self._state = state
1915+
self.guild = guild
1916+
self.id = int(data['id'])
1917+
self._posts = {}
1918+
1919+
def _add_thread(self, thread: ThreadChannel) -> None:
1920+
self._posts[thread.id] = thread
1921+
1922+
19121923
class PartialMessageable(abc.Messageable, Hashable):
19131924
"""Represents a partial messageable to aid with working messageable channels when
19141925
only a channel ID are present.
@@ -2016,6 +2027,8 @@ def _channel_factory(channel_type):
20162027
return StageChannel, value
20172028
elif value is ChannelType.public_thread:
20182029
return ThreadChannel, value
2030+
elif value is ChannelType.forum_channel:
2031+
return ForumChannel, value
20192032
else:
20202033
return None, value
20212034

discord/ext/commands/bot.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,19 @@
3333
import sys
3434
import traceback
3535
import types
36-
from typing import Optional, Union, Pattern, Match, AnyStr, Callable, Awaitable, Any
36+
from typing import (
37+
Optional,
38+
Union,
39+
Dict,
40+
Pattern,
41+
Match,
42+
AnyStr,
43+
Callable,
44+
Awaitable,
45+
Any,
46+
Iterable,
47+
Mapping
48+
)
3749

3850
import discord
3951

@@ -619,7 +631,7 @@ def remove_cog(self, name):
619631
cog._eject(self)
620632

621633
@property
622-
def cogs(self):
634+
def cogs(self) -> Dict[str, Cog]:
623635
"""Mapping[:class:`str`, :class:`Cog`]: A read-only mapping of cog name to cog."""
624636
return types.MappingProxyType(self.__cogs)
625637

docs/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,5 @@
176176
html_static_path = ['_static']
177177

178178
def setup(app: 'App'):
179-
app.add_css_file('style.css')
179+
app.setup_extension("sphinxext.opengraph")
180+
app.add_css_file('style.css')

0 commit comments

Comments
 (0)