discordaio.channel

Contains all related Channel Discord objects

Classes

class discordaio.channel.Channel(id: int = None, type: int = 0, guild_id: int = None, position: int = None, permission_overwrites: List[discordaio.channel.Overwrite] = [], name: str = None, topic: str = None, nsfw: bool = False, last_message_id: int = None, bitrate: int = None, user_limit: int = None, recipients: List[discordaio.user.User] = [], icon: str = None, owner_id: int = None, application_id: int = None, parent_id: int = None, last_pin_timestamp: int = None)[source]

Represents a guild or DM channel within Discord.

New in version 0.2.0.

id

the id of this channel

type

the value_type of channel

guild_id

the id of the guild

position

sorting position of the channel

permission_overwrites

explicit permission overwrites for members and roles

name

the name of the channel (2-100 characters)

topic the channel topic
Type:0-1024 characters
nsfw

if the channel is nsfw

last_message_id

the id of the last message sent in this channel (may not point to an existing or valid message)

bitrate

the bitrate (in bits) of the voice channel

user_limit

the user limit of the voice channel

recipients

the recipients of the DM

icon

icon hash

owner_id

id of the DM creator

application_id application id of the group DM creator if it is bot-created
parent_id

id of the parent category for a channel

last_pin_timestamp

timestamp when the last pinned message was pinned

Inheritance

Inheritance diagram of Channel
await bulk_delete_messages(ids: List[T])[source]

Delete multiple messages in a single request. This endpoint can only be used on guild channels and requires the MANAGE_MESSAGES permission.

This endpoint will not delete messages older than 2 weeks, and will fail if any message provided is older than that.

New in version 0.3.0.

await create_invite(max_age: int, max_uses=0, temporary=False, unique=False) → discordaio.invite.Invite[source]

Create a new invite object for the channel. Only usable for guild channels. Requires the CREATE_INSTANT_INVITE permission.

New in version 0.3.0.

await delete()[source]

Deletes the channel.

New in version 0.3.0.

await delete_permission(overwrite_id)[source]

Delete a channel permission overwrite for a user or role in a channel. Only usable for guild channels. Requires the MANAGE_ROLES permission.

New in version 0.3.0.

await delete_pinned_message(message_id)[source]

Delete a pinned message. Requires the MANAGE_MESSAGES permission.

New in version 0.3.0.

await get_invites() → List[discordaio.invite.Invite][source]

Returns a list of invite objects (with invite metadata) for the channel. Only usable for guild channels. Requires the MANAGE_CHANNELS permission.

New in version 0.3.0.

await get_message(message_id) → discordaio.channel.ChannelMessage[source]

Gets a specific channel message.

await get_messages(limit: int = None, around: int = None, before: int = None, after: int = None) → List[discordaio.channel.ChannelMessage][source]

Gets channel messages

New in version 0.3.0.

await get_pinned_messages() → List[discordaio.channel.ChannelMessage][source]

Returns all pinned messages in the channel as an array of message objects.

New in version 0.3.0.

mention() → str[source]

Returns formatted channel mention.

New in version 0.3.0.

await pin_message(message_id)[source]

Pin a message in a channel. Requires the MANAGE_MESSAGES permission.

New in version 0.3.0.

await refresh() → discordaio.channel.Channel[source]

Returns a “refreshed” channel instance, may be used to make sure you have the latest state of the channel.

New in version 0.3.0.

Example

channel = await channel.refresh()

Returns:The requested channel.
await send_message(msg: str, tts=False)[source]

New in version 0.3.0.

Parameters:
  • msg – The message to send. If it’s over 2000 chars it will be splitted.
  • tts – Wether to send it as a tts message.

TODO: Add embed and files.

await typing()[source]

Start typing.

New in version 0.3.0.

await update() → discordaio.channel.Channel[source]

Updates the channel using the current channel instance properties.

New in version 0.3.0.

Returns:The updated channel.
class discordaio.channel.ChannelMessage(id=None, channel_id=None, author: discordaio.user.User = None, content: str = None, timestamp: int = None, edited_timestamp: int = None, tts: bool = False, mention_everyone: bool = False, mentions: List[discordaio.user.User] = [], mention_roles: List[discordaio.role.Role] = [], attachments: List[discordaio.channel.Attachment] = [], embeds: List[discordaio.channel.Embed] = [], reactions: List[discordaio.channel.Reaction] = [], nonce: int = None, pinned=False, webhook_id=None, type=None, activity=<discordaio.channel.MessageActivity object>, application=<discordaio.channel.MessageApplication object>)[source]

Represents a message sent in a channel within Discord.

New in version 0.2.0.

Note

The author object follows the structure of the User object, but is only a valid user in the case where the message is generated by a user or bot user. If the message is generated by a Webhook, the author object corresponds to the webhook’s id, username, and avatar. You can tell if a message is generated by a webhook by checking for the webhook_id on the message object.

id

id of the message

channel_id

id of the channel the message was sent in

author

the author of this message (not guaranteed to be a valid user, see below)

content

contents of the message

timestamp

timestamp when this message was sent

edited_timestamp

timestamp when this message was edited (or null if never)

tts

whether this was a TTS message

mention_everyone

whether this message mentions everyone

mentions

objects users specifically mentioned in the message

mention_roles

object ids roles specifically mentioned in this message

attachments

objects any attached files

embeds

objects any embedded content

reactions

objects reactions to the message

nonce

used for validating a message was sent

pinned whether this message is pinned
webhook_id

if the message is generated by a webhook, this is the webhook’s id

type

type of message

activity

activity object sent with Rich Presence-related chat embeds

application

application object sent with Rich Presence-related chat embeds

Inheritance

Inheritance diagram of ChannelMessage
await delete()[source]

Delete a message. If operating on a guild channel and trying to delete a message that was not sent by the current user, this endpoint requires the MANAGE_MESSAGES permission

await delete_all_reactions()[source]

Deletes all reactions on a message. This endpoint requires the ‘MANAGE_MESSAGES’ permission to be present on the current user.

await delete_own_reaction(emoji_id)[source]

Delete a reaction the bot has made for the message

await delete_user_reaction(user_id, emoji_id)[source]

Deletes another user’s reaction. This endpoint requires the ‘MANAGE_MESSAGES’ permission to be present on the current user.

await get_reactions(emoji_id, before: int = None, after: int = None, limit: int = None) → List[discordaio.user.User][source]

Get a list of users that reacted with this emoji.

await update() → discordaio.channel.ChannelMessage[source]

Updates a previously sent message with the current instance properties (content). You can only edit messages that have been sent by the current user. Returns a message object. Fires a Message Update Gateway event.

TODO: Add embed support

class discordaio.channel.Overwrite(id=None, type=None, allow=None, deny=None)[source]

Represents a Overwrite object.

New in version 0.2.0.

id

role or user id

Type:int
type

either “role” or “member”

Type:str
allow

permission bit set

Type:int
deny

permission bit set

Type:int

Inheritance

Inheritance diagram of Overwrite
class discordaio.channel.MessageActivity(type: int = None, party_id: int = None)[source]

Represents a Message Activity.

New in version 0.2.0.

type

type of message activity

party_id

party_id from a Rich Presence event

Inheritance

Inheritance diagram of MessageActivity
class discordaio.channel.MessageApplication(id=None, cover_image=None, description=None, icon=None, name=None)[source]

Represents a Message Application.

New in version 0.2.0.

id

id of the application

Type:int
cover_image

id of the embed’s image asset

Type:str
description

application’s description

Type:str
icon

id of the application’s icon

Type:str
name

name of the application

Type:str

Inheritance

Inheritance diagram of MessageApplication
class discordaio.channel.Reaction(count: int = None, me: bool = False, emoji: discordaio.emoji.Emoji = None)[source]

Represents a Reaction.

New in version 0.2.0.

count

times this emoji has been used to react

me

whether the current user reacted using this emoji

emoji emoji information

Inheritance

Inheritance diagram of Reaction
class discordaio.channel.Embed(title=None, type=None, description=None, url=None, timestamp=None, color=None, footer=<discordaio.channel.EmbedFooter object>, image=<discordaio.channel.EmbedImage object>, thumbnail=<discordaio.channel.EmbedThumbnail object>, video=<discordaio.channel.EmbedVideo object>, provider=<discordaio.channel.EmbedProvider object>, author=<discordaio.channel.EmbedAuthor object>, fields=[])[source]

Represents a discord Embed

New in version 0.2.0.

title

title of embed

Type:str
type

type of embed (always “rich” for webhook embeds)

Type:str
description

description of embed

Type:str
url

url of embed

Type:str
timestamp

timestamp of embed content

Type:int
color

color code of the embed

Type:int
footer

footer information

Type:EmbedFooter
image

image information

Type:EmbedImage
thumbnail

thumbnail information

Type:EmbedThumbnail
video

video information

Type:EmbedVideo
provider

provider information

Type:EmbedProvider
author

author information

Type:EmbedAuthor
fields

fields information

Type:list of EmbedField

Inheritance

Inheritance diagram of Embed
class discordaio.channel.EmbedThumbnail(url=None, proxy_url=None, height=None, width=None)[source]

Represents a embed thumbnail object

New in version 0.2.0.

url

source url of thumbnail (only supports http(s) and attachments)

Type:str
proxy_url

a proxied url of the thumbnail

Type:str
height

height of thumbnail

Type:int
width

width of thumbnail

Type:int

Inheritance

Inheritance diagram of EmbedThumbnail
class discordaio.channel.EmbedVideo(url=None, height=None, width=None)[source]

Represents a embed video

New in version 0.2.0.

url

source url of video

Type:str
height

height of video

Type:int
width

width of video

Type:int

Inheritance

Inheritance diagram of EmbedVideo
class discordaio.channel.EmbedImage(url=None, proxy_url=None, height=None, width=None)[source]

Represents a embed image

New in version 0.2.0.

url

source url of image (only supports http(s) and attachments)

Type:str
proxy_url

a proxied url of the image

Type:str
height

height of image

Type:int
width

width of image

Type:int

Inheritance

Inheritance diagram of EmbedImage
class discordaio.channel.EmbedProvider(name=None, url=None)[source]

Represents a embed provider

New in version 0.2.0.

name

name of provider

Type:str
url

url of provider

Type:str

Inheritance

Inheritance diagram of EmbedProvider
class discordaio.channel.EmbedAuthor(name=None, url=None, icon_url=None, proxy_icon_url=None)[source]

Represents a embed author

New in version 0.2.0.

name

name of author

Type:str
url

url of author

Type:str
icon_url

url of author icon (only supports http(s) and attachments)

Type:str
proxy_icon_url

a proxied url of author icon

Type:str

Inheritance

Inheritance diagram of EmbedAuthor
class discordaio.channel.EmbedFooter(text=None, icon_url=None, proxy_icon_url=None)[source]

Represents a embed footer

New in version 0.2.0.

text

footer text

Type:str
icon_url

url of footer icon (only supports http(s) and attachments)

Type:str
proxy_icon_url

a proxied url of footer icon

Type:str

Inheritance

Inheritance diagram of EmbedFooter
class discordaio.channel.EmbedField(name=None, value=None, inline=False)[source]

Represents a embed field

New in version 0.2.0.

name

name of the field

Type:str
value

value of the field

Type:str
inline

whether or not this field should display inline

Type:bool

Inheritance

Inheritance diagram of EmbedField
class discordaio.channel.Attachment(id=None, filename=None, size=None, url=None, proxy_url=None, height=None, width=None)[source]

Represents a attachment

New in version 0.2.0.

id

attachment id

Type:int
filename

name of file attached

Type:str
size

size of file in bytes

Type:int
url

source url of file

Type:str
proxy_url

a proxied url of file

Type:str
height

height of file (if image)

Type:int
width

width of file (if image)

Type:int

Inheritance

Inheritance diagram of Attachment