Channels
CategoryChannel
Represents the GUILD_CATEGORY
channel type
children(self)
Yields all of the GuildChannels
that belong to this category
Source code in snekcord\objects\channelobject.py
def children(self):
"""Yields all of the `GuildChannels` that belong to this category"""
for channel in self.state:
if channel.parent_id == self.id:
yield channel
ChannelType
An enumaration of Discord's channel types
Name | Description |
---|---|
GUILD_TEXT |
A text channel in a Guild |
DM |
A direct message channel |
GUILD_VOICE |
A voice channel in a Guild |
GROUP_DM |
A DM channel with multiple recipients |
GUILD_CATEGORY |
A category channel in a Guild |
GUILD_NEWS |
A news channel in a Guild |
GUILD_STORE |
A store channel in a Guild |
GUILD_NEWS_THREAD |
A news thread channel in a Guild |
GUILD_PUBLIC_THREAD |
A public thread channel in a Guild |
GUILD_PRIVATE_THREAD |
A private thread channel in a Guild |
GUILD_STAGE_VOICE |
A stage channel in a Guild |
DMChannel
close(self)
async
Invokes an API request to close the channel
Source code in snekcord\objects\channelobject.py
async def close(self):
"""Invokes an API request to close the channel"""
await rest.delete_channel.request(
session=self.state.manager.rest,
fmt=dict(channel_id=self.id))
GuildChannel
The base class for all channels that belong to a Guild
Attributes:
Name | Type | Description |
---|---|---|
name |
str |
The channel's name |
guild_id |
Snowflake |
The id of the guild that the channel belongs to |
position |
int |
The channel's position |
nsfw |
bool |
|
parent_id |
Snowflake |
The id of the channel's parent/category |
type |
ChannelType |
The channel's type |
guild
property
readonly
The Guild
that the channel belongs to
Warning
This propery relies on the guild cache so it could return None
mention
property
readonly
The channel in mention format, equivalent to f'<#{self.id}>'
parent
property
readonly
The channel's parent/category
Warning
This propery relies on the channel cache so it could return None
delete(self)
async
Invokes an API request to delete the channel
Source code in snekcord\objects\channelobject.py
async def delete(self):
"""Invokes an API request to delete the channel"""
await rest.delete_channel.request(
session=self.state.manager.rest,
fmt=dict(channel_id=self.id))
modify(self, **kwargs)
async
Invokes an API request to modify the channel
Arguments:
Name | Type | Channel Types |
---|---|---|
name |
str |
All |
type |
ChannelType |
GUILD_TEXT , GUILD_NEWS |
position |
int |
All |
topic |
str |
GUILD_TEXT , GUILD_NEWS |
nsfw |
bool |
GUILD_TEXT , GUILD_NEWS , GUILD_STORE |
slowmode |
int |
GUILD_TEXT |
bitrate |
int |
GUILD_VOICE |
user_limit |
int |
GUILD_VOICE |
parent |
SnowflakeLike |
GUILD_TEXT , GUILD_NEWS , GUILD_STORE , GUILD_VOICE |
rtc_region |
str |
GUILD_VOICE |
Note
Discord only supports conversion between GUILD_TEXT
and GUILD_NEWS
channel types
Returns:
Type | Description |
---|---|
GuildChannel |
The modified channel |
Source code in snekcord\objects\channelobject.py
async def modify(self, **kwargs):
"""Invokes an API request to modify the channel
**Arguments:**
| Name | Type | Channel Types |
| ------------ | --------------- | -------------------------------------------------------- |
| `name` | `str` | `All` |
| `type` | `ChannelType` | `GUILD_TEXT`, `GUILD_NEWS` |
| `position` | `int` | `All` |
| `topic` | `str` | `GUILD_TEXT`, `GUILD_NEWS` |
| `nsfw` | `bool` | `GUILD_TEXT`, `GUILD_NEWS`, `GUILD_STORE` |
| `slowmode` | `int` | `GUILD_TEXT` |
| `bitrate` | `int` | `GUILD_VOICE` |
| `user_limit` | `int` | `GUILD_VOICE` |
| `parent` | `SnowflakeLike` | `GUILD_TEXT`, `GUILD_NEWS`, `GUILD_STORE`, `GUILD_VOICE` |
| `rtc_region` | `str` | `GUILD_VOICE` |
note:
Discord only supports conversion between `GUILD_TEXT` and `GUILD_NEWS`
channel types
Returns:
GuildChannel: The modified channel
""" # noqa: E501
keys = _guild_channel_modification_keys(self.type)
if self.type in (ChannelType.GUILD_TEXT, ChannelType.GUILD_NEWS,
ChannelType.GUILD_STORE):
try:
kwargs['parent_id'] = Snowflake.try_snowflake(
kwargs.pop('parent'))
except KeyError:
pass
if self.type is ChannelType.GUILD_TEXT:
try:
kwargs['rate_limit_per_user'] = kwargs.pop('slowmode')
except KeyError:
pass
_validate_keys(f'{self.__class__.__name__}.modify',
kwargs, (), keys)
data = await rest.modify_channel.request(
session=self.state.manager.rest,
fmt=dict(channel_id=self.id),
json=kwargs)
return self.state.upsert(data)
TextChannel
Represents the GUILD_TEXT
channel type
Attributes:
Name | Type | Description |
---|---|---|
messages |
MessageState |
The channel's message state |
topic |
str |
The channel's topic |
slowmode |
int |
The amount of time you have to wait between sending sucessive messages in the channel |
last_message_id |
Snowflake |
The id of the last message sent in the channel |
last_message
property
readonly
The last message sent in the channel
Warning
This property relies on the message cache so it could return None
pins(self)
async
Invokes an API request to get the pinned messages in the channel
Returns:
Type | Description |
---|---|
list[Message] |
The pinned messages in the channel |
Source code in snekcord\objects\channelobject.py
async def pins(self):
"""Invokes an API request to get the pinned messages
in the channel
Returns:
list[Message]: The pinned messages in the channel
"""
data = await rest.get_pinned_messages.request(
session=self.state.manager.rest,
fmt=dict(channel_id=self.id))
return self.messages.upsert_many(data)
typing(self)
async
Invokes an API request to trigger the typing indicator in the channel
Source code in snekcord\objects\channelobject.py
async def typing(self):
"""Invokes an API request to trigger the typing indicator
in the channel
"""
await rest.trigger_typing_indicator.request(
session=self.state.manager.rest,
fmt=dict(channel_id=self.id))
VoiceChannel
Represents the GUILD_VOICE
channel type
Attributes:
Name | Type | Description |
---|---|---|
bitrate |
int |
The channel's bitrate |
user_limit |
int |
The maximum amount of people who can be in this channel at once |