dico.model.channel module

class dico.model.channel.Channel(client, resp, *, guild_id=None)

Bases: DiscordObjectBase

Represents a Discord channel.

Refer https://discord.com/developers/docs/resources/channel#channel-object-channel-structure for attributes of the channel object.

TYPING

alias of Union[int, str, Snowflake, Channel]

RESPONSE

alias of Union[Channel, Awaitable[Channel]]

RESPONSE_AS_LIST

alias of Union[List[Channel], Awaitable[List[Channel]]]

modify(**kwargs)

Modifies channel.

Note

**kwargs varies depending on the channel type.

Returns:

Channel

property edit

Alias of modify().

delete(*, reason=None)

Deletes channel.

Parameters:

reason (Optional[str]) – Reason of the action.

Returns:

Channel

create_message(*args, **kwargs)

Creates message.

Note

  • FileIO object passed to file or files parameter will be automatically closed when requesting, therefore it is recommended to pass file path.

Warning

  • You must pass at least one of content or embed or file or files parameter.

  • You can’t use file and files at the same time.

Parameters:
  • content (Optional[str]) – Content of the message.

  • embed (Optional[Union[Embed, dict]]) – Embed of the message.

  • embeds (Optional[List[Union[Embed, dict]]]) – List of embeds of the message.

  • file (Optional[Union[io.FileIO, pathlib.Path, str]]) – File of the message.

  • files (Optional[List[Union[io.FileIO, pathlib.Path, str]]]) – Files of the message.

  • tts (Optional[bool]) – Whether to speak message.

  • allowed_mentions (Optional[Union[AllowedMentions, dict]]) – AllowedMentions to use for this request.

  • message_reference (Optional[Union[Message, MessageReference, dict]]) – Message to reply.

  • component (Optional[Union[dict, Component]]) – Component of the message.

  • components (Optional[List[Union[dict, Component]]]) – List of components of the message.

  • sticker (Optional[Sticker]) – Sticker of the message.

  • stickers (Optional[List[Sticker]]) – Stickers of the message. Up to 3.

Returns:

Message

property send

Alias of create_message().

bulk_delete_messages(*messages, reason=None)

Bulk deletes messages.

Parameters:
  • messages – Messages to delete.

  • reason (Optional[str]) – Reason of the action.

edit_permissions(overwrite, *, reason=None)

Edits permissions.

Parameters:
  • overwrite (Overwrite) – Permission overwrite to edit.

  • reason (Optional[str]) – Reason of the action.

request_invites()

Requests channel invites.

Returns:

List[Invite]

create_invite(**kwargs)

Creates channel invite.

Parameters:
  • max_age (Optional[int]) – Maximum age of the invite.

  • max_uses (Optional[int]) – Maximum use count of the invite.

  • temporary (Optional[bool]) – Whether this invite is temporary, meaning user will be kicked if role is not added.

  • unique (Optional[bool]) – Whether this invite is unique, meaning new code will be generated even if there is invite with same options.

  • target_type (Optional[Union[int, InviteTargetTypes]]) – Target type of the voice channel invite.

  • target_user – Target user of the invite.

  • target_application – Target application of the invite.

  • reason (Optional[str]) – Reason of the action.

Returns:

Invite

delete_permissions(overwrite, *, reason=None)

Deletes permissions.

Parameters:
  • overwrite – Target overwrite to delete. Accepts ID of the user or role.

  • reason (Optional[str]) – Reason of the action.

follow(target_channel)

Follows this channel to target channel. :param target_channel: Channel to receive published messages. :return: FollowedChannel

trigger_typing_indicator()

Triggers <client> is typing... on channel.

request_pinned_messages()

Requests pinned messages.

Returns:

List[Message]

add_recipient(user, access_token, nick)

Adds recipient to the group DM.

Parameters:
  • user – Recipient to add.

  • access_token (str) – OAuth2 access token to use.

  • nick (str) – Nickname to assign.

remove_recipient(user)

Removes recipient from the group DM.

Parameters:

user – Recipient to remove.

start_thread(message=None, *, name, auto_archive_duration, reason=None)

Starts new thread.

Note

If message param is passed, type of thread will be always public regardless of what you’ve set to.

Parameters:
  • message – Message to create thread from.

  • name (str) – Name of the thread.

  • auto_archive_duration (int) – When to archive thread in minutes.

  • reason (Optional[str]) – Reason of the action.

Returns:

Channel

join_thread()

Joins to thread.

add_thread_member(user)

Adds member to thread.

Parameters:

user – User to add.

leave_thread()

Leaves thread.

remove_thread_member(user)

Removes member from thread.

Parameters:

user – User to remove.

list_thread_members()

Returns list of members in thread.

Returns:

List[ThreadMember]

list_public_archived_threads(*, before=None, limit=None)

Returns list of public archived threads in channel.

Parameters:
  • before (Optional[Union[str, datetime.datetime]]) – Timestamp to show threads before.

  • limit (Optional[int]) – Limit of the number of the threads.

Returns:

ListThreadsResponse

list_private_archived_threads(*, before=None, limit=None)

Returns list of private archived threads in channel.

Parameters:
  • before (Optional[Union[str, datetime.datetime]]) – Timestamp to show threads before.

  • limit (Optional[int]) – Limit of the number of the threads.

Returns:

ListThreadsResponse

list_joined_private_archived_threads(*, before=None, limit=None)

Returns list of private archived threads that bot joined in channel.

Parameters:
  • before (Optional[Union[str, datetime.datetime]]) – Timestamp to show threads before.

  • limit (Optional[int]) – Limit of the number of the threads.

Returns:

ListThreadsResponse

archive(locked=False)

Archives thread.

Parameters:

locked (bool) – whether to lock thread or not.

to_position_param(position=None, lock_permissions=None, parent=None)

Exports channel object to dict as position parameter format.

Parameters:
  • position (Optional[int]) – Position of the channel.

  • lock_permissions (Optional[bool]) – Whether to lock permissions.

  • parent – Parent category of the channel.

Returns:

dict

to_welcome_screen_channel(description, emoji=None)

Exports channel object to welcome screen object.

Parameters:
  • description (str) – Description of the channel.

  • emoji – Emoji to use.

Returns:

WelcomeScreenChannel

property mention

The string that mentions channel.

property guild

Guild that channel belongs to if applicable.

is_messageable()

Checks if channel is able to send messages.

Returns:

bool

is_thread_channel()

Checks if channel is a thread.

Returns:

bool

raw
id
client
class dico.model.channel.ChannelTypes(value)

Bases: TypeBase

Types of the channel.

GUILD_TEXT = 0
DM = 1
GUILD_VOICE = 2
GROUP_DM = 3
GUILD_CATEGORY = 4
GUILD_NEWS = 5
GUILD_STORE = 6
GUILD_NEWS_THREAD = 10
GUILD_PUBLIC_THREAD = 11
GUILD_PRIVATE_THREAD = 12
GUILD_STAGE_VOICE = 13
GUILD_DIRECTORY = 14
GUILD_FORUM = 15
class dico.model.channel.VideoQualityModes(value)

Bases: TypeBase

Types of the video quality modes.

AUTO = 1
FULL = 2
class dico.model.channel.ChannelFlags(*args, **kwargs)

Bases: FlagBase

PINNED = 2
REQUIRE_TAG = 16
class dico.model.channel.SortOrderTypes(value)

Bases: TypeBase

LATEST_ACTIVITY = 0
CREATION_DATE = 1
class dico.model.channel.ForumLayoutTypes(value)

Bases: TypeBase

NOT_SET = 0
LIST_VIEW = 1
GALLERY_VIEW = 2
class dico.model.channel.SendOnlyChannel(client, channel_id)

Bases: object

Internal class representing temporary messageable channel.

send(*args, **kwargs)
class dico.model.channel.Message(client, resp, *, guild_id=None, webhook_token=None, interaction_token=None, original_response=False)

Bases: DiscordObjectBase

Represents a Discord message.

Refer https://discord.com/developers/docs/resources/channel#message-object for attributes of the channel object.

TYPING

alias of Union[int, str, Snowflake, Message]

RESPONSE

alias of Union[Message, Awaitable[Message]]

RESPONSE_AS_LIST

alias of Union[List[Message], Awaitable[List[Message]]]

reply(content=None, **kwargs)

Replies to the message.

Parameters:
  • content (Optional[str]) – Content of the message.

  • embed (Optional[Union[Embed, dict]]) – Embed of the message.

  • embeds (Optional[List[Union[Embed, dict]]]) – List of embeds of the message.

  • file (Optional[Union[io.FileIO, pathlib.Path, str]]) – File of the message.

  • files (Optional[List[Union[io.FileIO, pathlib.Path, str]]]) – Files of the message.

  • tts (Optional[bool]) – Whether to speak message.

  • allowed_mentions (Optional[Union[AllowedMentions, dict]]) – AllowedMentions to use for this request.

  • component (Optional[Union[dict, Component]]) – Component of the message.

  • components (Optional[List[Union[dict, Component]]]) – List of components of the message.

  • sticker (Optional[Sticker]) – Sticker of the message.

  • stickers (Optional[List[Sticker]]) – Stickers of the message. Up to 3.

Returns:

Message

edit(**kwargs)

Edits message.

Parameters:
  • content (Optional[str]) – Content to edit.

  • embed (Optional[Union[Embed, dict]]) – Embed to edit.

  • embeds (Optional[List[Union[Embed, dict]]]) – Embeds to edit.

  • file (Optional[FILE_TYPE]) – File to add.

  • files (Optional[List[FILE_TYPE]]) – Files to add.

  • allowed_mentions (Optional[Union[AllowedMentions, dict]]) – Allowed mentions of the message.

  • attachments (Optional[List[Union[Attachment, dict]]]) – Attachments to keep.

  • component (Optional[Union[dict, Component]]) – Component of the message to edit.

  • components (Optional[List[Union[dict, Component]]]) – Components of the message to edit.

Returns:

Message

delete(*, reason=None)

Deletes message.

Parameters:

reason (Optional[str]) – Reason of the action.

crosspost()

Crossposts message.

Returns:

Message

create_reaction(emoji)

Creates reaction.

Parameters:

emoji (Union[str, Emoji]) – Emoji for creating reaction.

delete_reaction(emoji, user='@me')

Deletes reaction.

Parameters:
  • emoji (Union[str, Emoji]) – Emoji of the reaction to delete.

  • user – User to delete reaction of. Default “@me” which is the bot itself.

pin(*, reason=None)

Pins message.

Parameters:

reason (Optional[str]) – Reason of the action.

unpin(*, reason=None)

Unpins message.

Parameters:

reason (Optional[str]) – Reason of the action.

start_thread(*, name, auto_archive_duration, reason=None)

Starts new thread.

Parameters:
  • name (str) – Name of the thread.

  • auto_archive_duration (int) – When to archive thread in minutes.

  • reason (Optional[str]) – Reason of the action.

Returns:

Channel

property guild

Guild this message belongs to.

property channel

Channel this message belongs to.

raw
id
client
class dico.model.channel.MessageTypes(value)

Bases: TypeBase

Types of the message.

DEFAULT = 0
RECIPIENT_ADD = 1
RECIPIENT_REMOVE = 2
CALL = 3
CHANNEL_NAME_CHANGE = 4
CHANNEL_ICON_CHANGE = 5
CHANNEL_PINNED_MESSAGE = 6
GUILD_MEMBER_JOIN = 7
USER_PREMIUM_GUILD_SUBSCRIPTION = 8
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1 = 9
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2 = 10
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3 = 11
CHANNEL_FOLLOW_ADD = 12
GUILD_DISCOVERY_DISQUALIFIED = 14
GUILD_DISCOVERY_REQUALIFIED = 15
GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING = 16
GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING = 17
THREAD_CREATED = 18
REPLY = 19
APPLICATION_COMMAND = 20
THREAD_STARTER_MESSAGE = 21
GUILD_INVITE_REMINDER = 22
CONTEXT_MENU_COMMAND = 23
AUTO_MODERATION_ACTION = 24
class dico.model.channel.MessageActivity(resp)

Bases: object

Represents Message Activity.

Variables:
classmethod optional(resp)
class dico.model.channel.MessageActivityTypes(value)

Bases: TypeBase

Types of the message activity.

JOIN = 1
SPECTATE = 2
LISTEN = 3
JOIN_REQUEST = 5
class dico.model.channel.MessageFlags(*args, **kwargs)

Bases: FlagBase

Flags of the message.

CROSSPOSTED = 1
IS_CROSSPOST = 2
SUPPRESS_EMBEDS = 4
SOURCE_MESSAGE_DELETED = 8
URGENT = 16
HAS_THREAD = 32
EPHEMERAL = 64
LOADING = 128
FAILED_TO_MENTION_SOME_ROLES_IN_THREAD = 256
class dico.model.channel.MessageReference(resp)

Bases: object

Represents Message Reference object.

Variables:
  • ~.message_id (Optiona[Snowflake]) – ID of the message to refer.

  • ~.channel_id (Optiona[Snowflake]) – ID of the channel of the message to refer.

  • ~.guild_id (Optiona[Snowflake]) – ID of the guild of the message to refer.

  • ~.fail_if_not_exists (bool) – Whether to raise error if message to refer does not exist.

to_dict()

Exports the instance to dict.

Returns:

dict

classmethod from_message(message, fail_if_not_exists=True)

Creates instance from message to refer.

Parameters:
  • message (Message) – Message to refer.

  • fail_if_not_exists (bool) – Whether to raise error if message to refer does not exist.

Returns:

MessageReference

classmethod from_id(**kwargs)

Alias of MessageReference(…). This is for internal usage.

Returns:

MessageReference

class dico.model.channel.FollowedChannel(client, resp)

Bases: object

Represents Followed Channel object.

Variables:
  • ~.client (APIClient) – Client of the instance.

  • ~.channel_id (Optional[Snowflake]) – ID of the followed channel.

  • ~.webhook_id (Optional[Snowflake]) – ID of the webhook of the followed channel.

RESPONSE

alias of Union[FollowedChannel, Awaitable[FollowedChannel]]

property channel

Gets channel object from cache.

class dico.model.channel.Reaction(client, resp)

Bases: object

Represents Reaction object.

Variables:
  • ~.count (int) – Count of the reaction.

  • ~.me (bool) – Whether client reacted.

  • emoji (Emoji) – Emoji of the reaction.

class dico.model.channel.Overwrite(user=None, role=None, allow=0, deny=0, **kw)

Bases: CopyableObject

TYPING

alias of Union[int, str, Snowflake, Overwrite]

to_dict()
edit(**kwargs)
classmethod create(resp)
class dico.model.channel.ThreadMetadata(client, resp)

Bases: object

classmethod optional(client, resp)
class dico.model.channel.ThreadMember(client, resp)

Bases: object

RESPONSE

alias of Union[ThreadMember, Awaitable[ThreadMember]]

RESPONSE_AS_LIST

alias of Union[List[ThreadMember], Awaitable[List[ThreadMember]]]

property user
classmethod optional(client, resp)
classmethod create(*args)

This is just a placeholder to prevent AttributeError.

class dico.model.channel.DefaultReaction(resp)

Bases: object

class dico.model.channel.ForumTag(resp)

Bases: object

class dico.model.channel.Embed(*, title=None, description=None, url=None, timestamp=None, color=None, **kwargs)

Bases: CopyableObject

classmethod create(resp)
set_image(url=None, proxy_url=None, height=None, width=None)
set_thumbnail(url=None, proxy_url=None, height=None, width=None)
set_video(url=None, proxy_url=None, height=None, width=None)
set_provider(name=None, url=None)
set_author(name=None, url=None, icon_url=None, proxy_icon_url=None)
add_field(name, value, inline=True)
property remove_field
to_dict()
class dico.model.channel.EmbedThumbnail(resp)

Bases: CopyableObject

to_dict()
classmethod optional(resp)
class dico.model.channel.EmbedVideo(resp)

Bases: CopyableObject

to_dict()
classmethod optional(resp)
class dico.model.channel.EmbedImage(resp)

Bases: CopyableObject

to_dict()
classmethod optional(resp)
class dico.model.channel.EmbedProvider(resp)

Bases: CopyableObject

to_dict()
classmethod optional(resp)
class dico.model.channel.EmbedAuthor(resp)

Bases: CopyableObject

to_dict()
classmethod optional(resp)
class dico.model.channel.EmbedFooter(resp)

Bases: CopyableObject

to_dict()
classmethod optional(resp)
class dico.model.channel.EmbedField(resp)

Bases: CopyableObject

to_dict()
classmethod optional(resp)
class dico.model.channel.Attachment(client, resp)

Bases: object

download()
save(target='')
to_dict()
class dico.model.channel.ChannelMention(resp)

Bases: object

class dico.model.channel.AllowedMentions(*, everyone=False, users=None, roles=None, replied_user=False)

Bases: CopyableObject

to_dict(*, reply=False)
class dico.model.channel.ListThreadsResponse(client, resp)

Bases: object

RESPONSE

alias of Union[ListThreadsResponse, Awaitable[ListThreadsResponse]]