Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add forum/media channel create methods #1629

Draft
wants to merge 2 commits into
base: unstable
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions interactions/models/discord/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1600,6 +1600,84 @@ async def create_stage_channel(
reason=reason,
)

async def create_forum_channel(
self,
name: str,
topic: Absent[Optional[str]] = MISSING,
position: Absent[Optional[int]] = MISSING,
permission_overwrites: Absent[
Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]
] = MISSING,
bitrate: int = 64000,
user_limit: int = 0,
reason: Absent[Optional[str]] = MISSING,
) -> "GuildForum":
"""
Create a guild forum channel within this category.

Args:
name: The name of the channel
topic: The topic of the channel
position: The position of the channel in the channel list
permission_overwrites: Permission overwrites to apply to the channel
bitrate: The bitrate of this channel, only for voice
user_limit: The max users that can be in this channel, only for voice
reason: The reason for creating this channel

Returns:
The newly created forum channel.

"""
return await self.create_channel(
channel_type=ChannelType.GUILD_FORUM,
name=name,
topic=topic,
position=position,
permission_overwrites=permission_overwrites,
bitrate=bitrate,
user_limit=user_limit,
reason=reason,
)

async def create_media_channel(
self,
name: str,
topic: Absent[Optional[str]] = MISSING,
position: Absent[Optional[int]] = MISSING,
permission_overwrites: Absent[
Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]
] = MISSING,
bitrate: int = 64000,
user_limit: int = 0,
reason: Absent[Optional[str]] = MISSING,
) -> "GuildMedia":
"""
Create a guild media channel within this category.

Args:
name: The name of the channel
topic: The topic of the channel
position: The position of the channel in the channel list
permission_overwrites: Permission overwrites to apply to the channel
bitrate: The bitrate of this channel, only for voice
user_limit: The max users that can be in this channel, only for voice
reason: The reason for creating this channel

Returns:
The newly created media channel.

"""
return await self.create_channel(
channel_type=ChannelType.GUILD_MEDIA,
name=name,
topic=topic,
position=position,
permission_overwrites=permission_overwrites,
bitrate=bitrate,
user_limit=user_limit,
reason=reason,
)


@attrs.define(eq=False, order=False, hash=False, kw_only=True)
class GuildNews(GuildChannel, MessageableMixin, InvitableMixin, ThreadableMixin, WebhookMixin):
Expand Down
84 changes: 84 additions & 0 deletions interactions/models/discord/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,90 @@
reason=reason,
)

async def create_forum_channel(

Check warning on line 1207 in interactions/models/discord/guild.py

View workflow job for this annotation

GitHub Actions / runner / Pre-commit actions

Redefinition of unused `create_forum_channel` from line 1027

Check warning on line 1207 in interactions/models/discord/guild.py

View workflow job for this annotation

GitHub Actions / runner / Pre-commit actions

Redefinition of unused `create_forum_channel` from line 1027
self,
name: str,
topic: Absent[Optional[str]] = MISSING,
position: Absent[Optional[int]] = MISSING,
permission_overwrites: Absent[
Union[dict, "models.PermissionOverwrite", List[Union[dict, "models.PermissionOverwrite"]]]
] = MISSING,
category: Absent[Union[Snowflake_Type, "models.GuildCategory"]] = MISSING,
bitrate: int = 64000,
user_limit: int = 0,
reason: Absent[Optional[str]] = MISSING,
) -> "models.GuildForum":
"""
Create a guild forum channel.

Args:
name: The name of the channel
topic: The topic of the channel
position: The position of the channel in the channel list
permission_overwrites: Permission overwrites to apply to the channel
category: The category this channel should be within
bitrate: The bitrate of this channel, only for voice
user_limit: The max users that can be in this channel, only for voice
reason: The reason for creating this channel

Returns:
The newly created forum channel.

"""
return await self.create_channel(
channel_type=ChannelType.GUILD_FORUM,
name=name,
topic=topic,
position=position,
permission_overwrites=permission_overwrites,
category=category,
bitrate=bitrate,
user_limit=user_limit,
reason=reason,
)

async def create_media_channel(
self,
name: str,
topic: Absent[Optional[str]] = MISSING,
position: Absent[Optional[int]] = MISSING,
permission_overwrites: Absent[
Union[dict, "models.PermissionOverwrite", List[Union[dict, "models.PermissionOverwrite"]]]
] = MISSING,
category: Absent[Union[Snowflake_Type, "models.GuildCategory"]] = MISSING,
bitrate: int = 64000,
user_limit: int = 0,
reason: Absent[Optional[str]] = MISSING,
) -> "models.GuildMedia":
"""
Create a guild media channel.

Args:
name: The name of the channel
topic: The topic of the channel
position: The position of the channel in the channel list
permission_overwrites: Permission overwrites to apply to the channel
category: The category this channel should be within
bitrate: The bitrate of this channel, only for voice
user_limit: The max users that can be in this channel, only for voice
reason: The reason for creating this channel

Returns:
The newly created media channel.

"""
return await self.create_channel(
channel_type=ChannelType.GUILD_MEDIA,
name=name,
topic=topic,
position=position,
permission_overwrites=permission_overwrites,
category=category,
bitrate=bitrate,
user_limit=user_limit,
reason=reason,
)

async def create_category(
self,
name: str,
Expand Down
Loading