Skip to content

Commit 8879c85

Browse files
authored
feat: Support setting forum layout (#1308)
* feat: add forumLayoutType enum * feat: support specifying forum layout on creation
1 parent 585e618 commit 8879c85

File tree

6 files changed

+66
-41
lines changed

6 files changed

+66
-41
lines changed

interactions/__init__.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
ChannelSelectMenu,
9393
ChannelType,
9494
check,
95+
ClientUser,
9596
Color,
9697
COLOR_TYPES,
9798
Colour,
@@ -101,8 +102,6 @@
101102
ComponentContext,
102103
ComponentType,
103104
context_menu,
104-
user_context_menu,
105-
message_context_menu,
106105
ContextMenu,
107106
ContextMenuContext,
108107
Converter,
@@ -131,6 +130,7 @@
131130
File,
132131
FlatUIColors,
133132
FlatUIColours,
133+
ForumLayoutType,
134134
get_components_ids,
135135
global_autocomplete,
136136
GlobalAutoComplete,
@@ -199,6 +199,7 @@
199199
MentionableSelectMenu,
200200
MentionType,
201201
Message,
202+
message_context_menu,
202203
MessageableChannelConverter,
203204
MessageableMixin,
204205
MessageActivity,
@@ -214,7 +215,6 @@
214215
ModalCommand,
215216
ModalContext,
216217
MODEL_TO_CONVERTER,
217-
ClientUser,
218218
NoArgumentConverter,
219219
NSFWLevel,
220220
open_file,
@@ -314,6 +314,7 @@
314314
Typing,
315315
UPLOADABLE_TYPE,
316316
User,
317+
user_context_menu,
317318
UserConverter,
318319
UserFlags,
319320
UserSelectMenu,
@@ -394,6 +395,7 @@
394395
"ChannelType",
395396
"check",
396397
"Client",
398+
"ClientUser",
397399
"Color",
398400
"COLOR_TYPES",
399401
"Colour",
@@ -404,8 +406,6 @@
404406
"ComponentType",
405407
"const",
406408
"context_menu",
407-
"user_context_menu",
408-
"message_context_menu",
409409
"CONTEXT_MENU_NAME_LENGTH",
410410
"ContextMenu",
411411
"ContextMenuContext",
@@ -444,6 +444,7 @@
444444
"File",
445445
"FlatUIColors",
446446
"FlatUIColours",
447+
"ForumLayoutType",
447448
"get_components_ids",
448449
"get_logger",
449450
"global_autocomplete",
@@ -519,6 +520,7 @@
519520
"MentionPrefix",
520521
"MentionType",
521522
"Message",
523+
"message_context_menu",
522524
"MessageableChannelConverter",
523525
"MessageableMixin",
524526
"MessageActivity",
@@ -536,7 +538,6 @@
536538
"ModalCommand",
537539
"ModalContext",
538540
"MODEL_TO_CONVERTER",
539-
"ClientUser",
540541
"NoArgumentConverter",
541542
"NSFWLevel",
542543
"open_file",
@@ -648,6 +649,7 @@
648649
"Typing",
649650
"UPLOADABLE_TYPE",
650651
"User",
652+
"user_context_menu",
651653
"UserConverter",
652654
"UserFlags",
653655
"UserSelectMenu",

interactions/api/http/http_requests/channels.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ async def create_guild_channel(
126126
user_limit: int = 0,
127127
rate_limit_per_user: int = 0,
128128
reason: str | None = None,
129+
**kwargs: dict,
129130
) -> discord_typings.ChannelData:
130131
"""
131132
Create a channel in a guild.
@@ -143,6 +144,7 @@ async def create_guild_channel(
143144
user_limit: The max users that can be in this channel, only for voice
144145
rate_limit_per_user: The time users must wait between sending messages
145146
reason: The reason for creating this channel
147+
kwargs: Additional keyword arguments to pass to the request
146148
147149
Returns:
148150
The created channel object
@@ -157,6 +159,7 @@ async def create_guild_channel(
157159
"nsfw": nsfw,
158160
"parent_id": int(parent_id) if parent_id else None,
159161
"permission_overwrites": list(permission_overwrites) if permission_overwrites else None,
162+
**kwargs,
160163
}
161164
if channel_type in (ChannelType.GUILD_VOICE, ChannelType.GUILD_STAGE_VOICE):
162165
payload.update(

interactions/models/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
ChannelMention,
3737
ChannelSelectMenu,
3838
ChannelType,
39+
ClientUser,
3940
Color,
4041
COLOR_TYPES,
4142
Colour,
@@ -56,6 +57,7 @@
5657
File,
5758
FlatUIColors,
5859
FlatUIColours,
60+
ForumLayoutType,
5961
get_components_ids,
6062
Guild,
6163
GuildBan,
@@ -102,7 +104,6 @@
102104
MessageType,
103105
MFALevel,
104106
Modal,
105-
ClientUser,
106107
NSFWLevel,
107108
open_file,
108109
OverwriteType,
@@ -344,6 +345,7 @@
344345
"ChannelSelectMenu",
345346
"ChannelType",
346347
"check",
348+
"ClientUser",
347349
"Color",
348350
"COLOR_TYPES",
349351
"Colour",
@@ -353,8 +355,6 @@
353355
"ComponentContext",
354356
"ComponentType",
355357
"context_menu",
356-
"user_context_menu",
357-
"message_context_menu",
358358
"ContextMenu",
359359
"ContextMenuContext",
360360
"Converter",
@@ -383,6 +383,7 @@
383383
"File",
384384
"FlatUIColors",
385385
"FlatUIColours",
386+
"ForumLayoutType",
386387
"get_components_ids",
387388
"global_autocomplete",
388389
"GlobalAutoComplete",
@@ -451,6 +452,7 @@
451452
"MentionableSelectMenu",
452453
"MentionType",
453454
"Message",
455+
"message_context_menu",
454456
"MessageableChannelConverter",
455457
"MessageableMixin",
456458
"MessageActivity",
@@ -466,7 +468,6 @@
466468
"ModalCommand",
467469
"ModalContext",
468470
"MODEL_TO_CONVERTER",
469-
"ClientUser",
470471
"NoArgumentConverter",
471472
"NSFWLevel",
472473
"open_file",
@@ -566,6 +567,7 @@
566567
"Typing",
567568
"UPLOADABLE_TYPE",
568569
"User",
570+
"user_context_menu",
569571
"UserConverter",
570572
"UserFlags",
571573
"UserSelectMenu",

interactions/models/discord/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
ComponentType,
8484
DefaultNotificationLevel,
8585
ExplicitContentFilterLevel,
86+
ForumLayoutType,
8687
IntegrationExpireBehaviour,
8788
Intents,
8889
InteractionPermissionTypes,
@@ -202,6 +203,7 @@
202203
"ChannelMention",
203204
"ChannelSelectMenu",
204205
"ChannelType",
206+
"ClientUser",
205207
"Color",
206208
"COLOR_TYPES",
207209
"Colour",
@@ -222,6 +224,7 @@
222224
"File",
223225
"FlatUIColors",
224226
"FlatUIColours",
227+
"ForumLayoutType",
225228
"get_components_ids",
226229
"Guild",
227230
"GuildBan",
@@ -268,7 +271,6 @@
268271
"MessageType",
269272
"MFALevel",
270273
"Modal",
271-
"ClientUser",
272274
"NSFWLevel",
273275
"open_file",
274276
"OverwriteType",

interactions/models/discord/enums.py

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,47 +6,48 @@
66
from interactions.client.const import get_logger
77

88
__all__ = (
9-
"WebSocketOPCode",
10-
"Intents",
11-
"UserFlags",
9+
"ActivityFlag",
10+
"ActivityType",
1211
"ApplicationFlags",
13-
"TeamMembershipState",
14-
"PremiumType",
15-
"MemberFlags",
16-
"MessageType",
17-
"MessageActivityType",
18-
"MessageFlags",
19-
"Permissions",
12+
"AuditLogEventType",
13+
"AutoArchiveDuration",
14+
"ButtonStyle",
15+
"ChannelFlags",
2016
"ChannelType",
21-
"ComponentType",
2217
"CommandType",
23-
"InteractionType",
24-
"ButtonStyle",
25-
"MentionType",
26-
"OverwriteType",
18+
"ComponentType",
2719
"DefaultNotificationLevel",
2820
"ExplicitContentFilterLevel",
21+
"ForumLayoutType",
22+
"IntegrationExpireBehaviour",
23+
"Intents",
24+
"InteractionPermissionTypes",
25+
"InteractionType",
26+
"InviteTargetType",
27+
"MemberFlags",
28+
"MentionType",
29+
"MessageActivityType",
30+
"MessageFlags",
31+
"MessageType",
2932
"MFALevel",
30-
"VerificationLevel",
3133
"NSFWLevel",
34+
"OverwriteType",
35+
"Permissions",
3236
"PremiumTier",
33-
"SystemChannelFlags",
34-
"ChannelFlags",
35-
"VideoQualityMode",
36-
"AutoArchiveDuration",
37-
"ActivityType",
38-
"ActivityFlag",
39-
"Status",
40-
"StagePrivacyLevel",
41-
"IntegrationExpireBehaviour",
42-
"InviteTargetType",
37+
"PremiumType",
4338
"ScheduledEventPrivacyLevel",
44-
"ScheduledEventType",
4539
"ScheduledEventStatus",
46-
"AuditLogEventType",
47-
"InteractionPermissionTypes",
48-
"StickerTypes",
40+
"ScheduledEventType",
41+
"StagePrivacyLevel",
42+
"Status",
4943
"StickerFormatType",
44+
"StickerTypes",
45+
"SystemChannelFlags",
46+
"TeamMembershipState",
47+
"UserFlags",
48+
"VerificationLevel",
49+
"VideoQualityMode",
50+
"WebSocketOPCode",
5051
)
5152

5253

@@ -967,3 +968,11 @@ class StickerFormatType(CursedIntEnum):
967968
APNG = 2
968969
LOTTIE = 3
969970
GIF = 4
971+
972+
973+
class ForumLayoutType(CursedIntEnum):
974+
"""The layout of a forum channel."""
975+
976+
NOT_SET = 0
977+
LIST = 1
978+
GALLERY = 2

interactions/models/discord/guild.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
AuditLogEventType,
3838
AutoModEvent,
3939
AutoModTriggerType,
40+
ForumLayoutType,
4041
)
4142
from .snowflake import to_snowflake, Snowflake_Type, to_optional_snowflake, to_snowflake_list
4243

@@ -895,6 +896,7 @@ async def create_channel(
895896
user_limit: int = 0,
896897
rate_limit_per_user: int = 0,
897898
reason: Absent[Optional[str]] = MISSING,
899+
**kwargs: dict,
898900
) -> "models.TYPE_GUILD_CHANNEL":
899901
"""
900902
Create a guild channel, allows for explicit channel type setting.
@@ -911,6 +913,7 @@ async def create_channel(
911913
user_limit: The max users that can be in this channel, only for voice
912914
rate_limit_per_user: The time users must wait between sending messages
913915
reason: The reason for creating this channel
916+
kwargs: Additional keyword arguments to pass to the channel creation
914917
915918
Returns:
916919
The newly created channel.
@@ -929,6 +932,7 @@ async def create_channel(
929932
user_limit,
930933
rate_limit_per_user,
931934
reason,
935+
**kwargs,
932936
)
933937
return self._client.cache.place_channel_data(channel_data)
934938

@@ -985,6 +989,7 @@ async def create_forum_channel(
985989
category: Union[Snowflake_Type, "models.GuildCategory"] = None,
986990
nsfw: bool = False,
987991
rate_limit_per_user: int = 0,
992+
layout: ForumLayoutType = ForumLayoutType.NOT_SET,
988993
reason: Absent[Optional[str]] = MISSING,
989994
) -> "models.GuildForum":
990995
"""
@@ -998,6 +1003,7 @@ async def create_forum_channel(
9981003
category: The category this forum channel should be within
9991004
nsfw: Should this forum be marked nsfw
10001005
rate_limit_per_user: The time users must wait between sending messages
1006+
layout: The layout of the forum channel
10011007
reason: The reason for creating this channel
10021008
10031009
Returns:
@@ -1013,6 +1019,7 @@ async def create_forum_channel(
10131019
category=category,
10141020
nsfw=nsfw,
10151021
rate_limit_per_user=rate_limit_per_user,
1022+
default_forum_layout=layout,
10161023
reason=reason,
10171024
)
10181025

0 commit comments

Comments
 (0)