Bases

Bases are objects which represent different objects in the discord API. They minify the code written and can help improve readability in your code!

Embed

class acord.Embed(*, title: str = None, type: Literal['rich', 'image', 'video', 'gifv', 'article', 'link'] = 'rich', description: str = None, url: pydantic.networks.AnyHttpUrl = None, timestamp: datetime.datetime = None, color: acord.bases.embeds.Color = None, footer: acord.bases.embeds.EmbedFooter = None, image: acord.bases.embeds.EmbedImage = None, thumbnail: acord.bases.embeds.EmbedThumbnail = None, video: acord.bases.embeds.EmbedVideo = None, providor: acord.bases.embeds.EmbedProvidor = None, author: acord.bases.embeds.EmbedAuthor = None, fields: List[acord.bases.embeds.EmbedField] = None)

An object representing a discord embed

add_field(**data) None

Add a new field to your embed

Parameters
  • name (str) – Name of field

  • value (str) – Value of field

  • inline (bool) – Whether or not this field should be inline. Defaults to False

characters() int

Counts the total amount of characters in the embed

dict(*args, **kwargs) dict

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

insert_field(index, **data) None

Insert a field at a certain index

Parameters

index (int) – Index to insert field at, e.g. 0 is the start

remove_field(index: int) Optional[acord.bases.embeds.EmbedField]

Remove a field from the embed, Returns field if found, Else raises IndexError.

Parameters

index (int) – Index of field to remove.

set_author(**data) None

Add author on embed

Parameters
  • name (str) – Author name

  • url (str) – URL of author

  • icon_url (str) – A url for the author icon

  • proxy_icon_url (str) – A proxied url of author icon

Add footer on embed

Parameters
  • text (str) – Footer text

  • icon_url (str) – A url for the icon url

  • proxy_icon_url (str) – A proxied url of footer icon

author: Optional[acord.bases.embeds.EmbedAuthor]

Embed author

color: Optional[acord.bases.embeds.Color]

Embed colour, can be any value as per CSS3 specifications

Allowed Forms

Embed(color="hsl(260, 50%, 20%)")
Embed(color="rgb(10, 10, 10)")
Embed(color="rgba(10, 10, 10, 0.1)")
Embed(color="#LongHex")
Embed(color="#ShortHex")
Embed(color="Hex or ShortHex")
Embed(color=Hex)
Embed(color="blue")
description: Optional[str]

Embed description, must be under 4096 chars if provided

fields: Optional[List[acord.bases.embeds.EmbedField]]

Embed fields

footer: Optional[acord.bases.embeds.EmbedFooter]

Embed footer

image: Optional[acord.bases.embeds.EmbedImage]

Embed image

providor: Optional[acord.bases.embeds.EmbedProvidor]

Embed Providor

thumbnail: Optional[acord.bases.embeds.EmbedThumbnail]

Embed thumbnail

timestamp: Optional[datetime.datetime]

Embed timestamp

title: Optional[str]

Embed title, must be under 256 chars if provided

type: Optional[Literal['rich', 'image', 'video', 'gifv', 'article', 'link']]

Embed type, defaults to rich

url: Optional[pydantic.networks.AnyHttpUrl]

Embed title hyperlink

video: Optional[acord.bases.embeds.EmbedVideo]

Embed video

Components

Attributes
class acord.Component(*, type: acord.bases.enums.components.ComponentTypes, custom_id: str = None, disabled: bool = False)
custom_id: Optional[str]

Custom ID of component cannot be greater then 100 chars

disabled: Optional[bool]

Whether component is disabled

type: acord.bases.enums.components.ComponentTypes

Type of component

ActionRow

Attributes
Methods
class acord.ActionRow(*components, type: acord.bases.enums.components.ComponentTypes, custom_id: str = None, disabled: bool = False)
add_component(component: acord.bases.components.Component) None

This is a function.

Adds a component to your row

Parameters

component (Component) – Component to add to row

components: List[acord.bases.components.Component]

List of components to add to row

Button

Attributes
class acord.Button(*, type: acord.bases.enums.components.ComponentTypes, custom_id: str = None, disabled: bool = False, style: acord.bases.enums.components.ButtonStyles, label: str = None, emoji: Any = None, url: pydantic.networks.AnyHttpUrl = None)
emoji: Optional[acord.models.partials.PartialEmoji]

A partial emoji object

label: Optional[str]

Button label, must be less then 80 chars

style: acord.bases.enums.components.ButtonStyles

Style of button

url: Optional[pydantic.networks.AnyHttpUrl]

URL for link style buttons

SelectMenu

class acord.SelectMenu(*, type: acord.bases.enums.components.ComponentTypes, custom_id: str = None, disabled: bool = False, options: List[acord.bases.components.SelectOption], placeholder: str = None, min_values: int = None, max_values: int = None)
add_option(option: acord.bases.components.SelectOption) None

This is a function.

Adds an option to the select menu

Parameters

option (SelectOption) – New select option to add to menu

max_values: Optional[int]

Max values of selected items

min_values: Optional[int]

Minimum values of selected items

options: List[acord.bases.components.SelectOption]

List of options

placeholder: Optional[str]

Custom placeholder if nothing is selected

SelectOption

class acord.SelectOption(*, label: str, value: str, description: str, emoji: Any = None, default: bool = None)
default: Optional[bool]

will render this option as selected by default

description: str

an additional description of the option, max 100 characters

emoji: Optional[acord.models.partials.PartialEmoji]

an emoji to dispay next to the label

label: str

the user-facing name of the option, max 100 characters

value: str

the dev-define value of the option, max 100 characters

PermissionsOverwrite

class acord.PermissionsOverwrite(*, id: int, type: Literal[0, 1], allow: acord.bases.flags.permissions.Permissions, deny: acord.bases.flags.permissions.Permissions)

AllowedMentions

class acord.AllowedMentions(*, roles: List[int] = None, users: List[int] = None, replied_user: bool = False, everyone: bool = False, deny_all: bool = False, parse: List[str] = [])
deny_all: Optional[bool]

Simply reject every single mention on message

everyone: Optional[bool]

Whether to allow @everyone / @here pings

replied_user: Optional[bool]

Whether to mention to user being replied

roles: Optional[List[int]]

List of roles to mention

users: Optional[List[int]]

List of users to mention

Flags

BaseFlagMeta

class acord.BaseFlagMeta(cls, bases, classdict)
__call__(value: int = 0, **kwds: Dict[str, bool])

If you dont like using bitwise operators, or would like a simple way of creating flags.

Look no further!

Usage

# Example Using ``acord.Permissions``
from acord import Role, Permissions

permissions = Role.permissions

from_int = Permissions(permissions)
my_permissions = Permissions(CONNECT=True, STREAM=True, SPEAK=True)
Parameters
  • value (int) – Value of flag

  • **kwds (Dict[str, bool]) – Name of flags you want to use, value must be set to True!

Intents

class acord.Intents(value: int = 0, **kwds: Dict[str, bool])

Intents are used for accessing certain content through the gateway, without them many of the events wouldn’t work as expected

Usage

All intents are assigned as a attribute, to combine intents, use the | operator, as shown below.

from acord import Intents

myIntents = (
    Intents.GUILDS
    | Intents.GUILD_MESSAGES
    | Intents.GUILD_PRESENCES
    ...
)

If bitwise operators are not to your taste, you can try using BaseFlagMeta.__call__().

Valid Attributes

Listed below are the allowed intent attrs and what events they allow to be used

  • NONE
    • No intents

  • ALL
    • Every intent allowed through the gateway

  • GUILDS
    • GUILD_CREATE

    • GUILD_UPDATE

    • GUILD_DELETE

    • GUILD_ROLE_CREATE

    • GUILD_ROLE_UPDATE

    • GUILD_ROLE_DELETE

    • CHANNEL_CREATE

    • CHANNEL_UPDATE

    • CHANNEL_DELETE

    • CHANNEL_PINS_UPDATE

    • THREAD_CREATE

    • THREAD_UPDATE

    • THREAD_DELETE

    • THREAD_LIST_SYNC

    • THREAD_MEMBER_UPDATE

    • THREAD_MEMBERS_UPDATE

    • STAGE_INSTANCE_CREATE

    • STAGE_INSTANCE_UPDATE

    • STAGE_INSTANCE_DELETE

  • GUILD_MEMBERS
    • GUILD_MEMBER_ADD

    • GUILD_MEMBER_UPDATE

    • GUILD_MEMBER_REMOVE

    • THREAD_MEMBERS_UPDATE

  • GUILD_BANS
    • GUILD_BAN_ADD

    • GUILD_BAN_REMOVE

  • GUILD_EMOJIS_AND_STICKERS
    • GUILD_EMOJIS_UPDATE

    • GUILD_STICKERS_UPDATE

  • GUILD_INTEGRATIONS
    • GUILD_INTEGRATIONS_UPDATE

    • INTEGRATION_CREATE

    • INTEGRATION_UPDATE

    • INTEGRATION_DELETE

  • GUILD_WEBHOOKS
    • WEBHOOKS_UPDATE

  • GUILD_INVITES
    • INVITE_CREATE

    • INVITE_DELETE

  • GUILD_VOICE_STATES
    • VOICE_STATE_UPDATE

  • GUILD_PRESENCES
    • PRESENCE_UPDATE

  • GUILD_MESSAGES
    • MESSAGE_CREATE

    • MESSAGE_UPDATE

    • MESSAGE_DELETE

    • MESSAGE_DELETE_BULK

  • GUILD_MESSAGE_REACTIONS
    • MESSAGE_REACTION_ADD

    • MESSAGE_REACTION_REMOVE

    • MESSAGE_REACTION_REMOVE_ALL

    • MESSAGE_REACTION_REMOVE_EMOJI

  • GUILD_MESSAGE_TYPING
    • TYPING_START

  • DIRECT_MESSAGES
    • MESSAGE_CREATE

    • MESSAGE_UPDATE

    • MESSAGE_DELETE

    • CHANNEL_PINS_UPDATE

  • DIRECT_MESSAGE_REACTIONS
    • MESSAGE_REACTION_ADD

    • MESSAGE_REACTION_REMOVE

    • MESSAGE_REACTION_REMOVE_ALL

    • MESSAGE_REACTION_REMOVE_EMOJI

  • DIRECT_MESSAGE_TYPING
    • TYPING_START

Users

class acord.UserFlags(value: int = 0, **kwds: Dict[str, bool])

User flags allow you to identify users based on there badges given by discord

Usage

Checking for single flags

from acord import UserFlags

isStaff = User.flags & UserFlags.STAFF == UserFlags.STAFF

However, when checking for multiple flags, you need to use the | for all flags you want

from acord import UserFlags
flags = (
    UserFlags.STAFF
    | UserFlags.PARTNER
)

hasFlags = User.flags & flags == flags

If bitwise operators are not to your taste, you can try using BaseFlagMeta.__call__().

NONE

Value of 0, or NO flags

STAFF

discord staff flag

PARTNER

discord partner flag

HYPESQUAD

hypesquad events coordinator flag

HYPESQUAD_BRAVERY

hypesquad house bravery flag

HYPESQUAD_BRILLIANCE

hypesquad house brilliance flag

HYPESQUAD_BALANCE

hypesquad house bravery flag

BUG_HUNTER_LEVEL_1

bug hunter level 1 flag

BUG_HINTER_LEVEL_2

bug hunter level 2 flag

PREMIUM_EARLY_SUPPORTER

early Nitro Supporter

TEAM_PSEUDO_USER

user is a Team

VERIFIED_BOT

verified bot flag

VERIFIED_DEVELOPER

early verified bot developer flag

CERTIFIED_MODERATOR

discord certified moderator flag

Permissions

class acord.Permissions(value: int = 0, **kwds: Dict[str, bool])

Permissions define what actions a user can or cannot do, they are set and follow a hierachy. If you try break the hierachy 403 will be raised. E.g. Banning a member with a higher role then the client.

Usage

from acord import Permissions
permissions = (
    Permissions.MANAGE_MESSAGES
    | Permissions.BAN_MEMBER
    | Permissions.KICK_MEMBERS
)

If bitwise operators are not to your taste, you can try using BaseFlagMeta.__call__().

ADD_REACTIONS = 64

Allows for the addition of reactions to messages

ADMINISTRATOR = 8

Allows all permissions and bypasses channel permission overwrites

ATTACH_FILES = 32768

Allows for uploading images and files

BAN_MEMBER = 4

Allows banning members

CHANGE_NICKNAME = 67108864

Allows for modification of own nickname

CONNECT = 1048576

Allows for joining of a voice channel

CREATE_INSTANT_INVITE = 1

Allows creation of instant invites

CREATE_PRIVATE_THREADS = 68719476736

Allows for creating private threads

CREATE_PUBLIC_THREADS = 34359738368

Allows for creating threads

DEAFEN_MEMBERS = 8388608

Allows for deafening of members in a voice channel

Links sent by users with this permission will be auto-embedded

KICK_MEMBERS = 2

Allows kicking members

MANAGE_CHANNEL = 16

Allows management and editing of channels

MANAGE_EMOJIS_AND_STICKERS = 1073741824

Allows management and editing of emojis and stickers

MANAGE_EVENTS = 8589934592

Allows for creating, editing, and deleting scheduled events

MANAGE_GUILD = 32

Allows management and editing of the guild

MANAGE_MESSAGES = 8192

Allows for deletion of other users messages

MANAGE_NICKAMES = 134217728

Allows for modification of other users nicknames

MANAGE_ROLES = 268435456

Allows management and editing of roles

MANAGE_THREADS = 17179869184

Allows for deleting and archiving threads, and viewing all private threads

MANAGE_WEBHOOKS = 536870912

Allows management and editing of webhooks

MENTION_EVERYONE = 131072

Allows for using the @everyone tag to notify all users in a channel, and the @here tag to notify all online users in a channel

MODERATE_MEMBERS = 1099511627776

Allows for timing out users to prevent them from sending or reacting to messages in chat and threads, and from speaking in voice and stage channels

MOVE_MEMBERS = 16777216

Allows for moving of members between voice channels

MUTE_MEMBERS = 4194304

Allows for muting members in a voice channel

NONE = 0

No permissions

PRIORITY_SPEAKER = 256

Allows for using priority speaker in a voice channel

READ_MESSAGE_HISTORY = 65536

Allows for reading of message history

REQUEST_TO_SPEAK = 4294967296

Allows for requesting to speak in stage channels.

SEND_MESSAGES = 2048

Allows for sending messages in a channel (does not allow sending messages in threads)

SEND_MESSAGE_IN_THREADS = 274877906944

Allows for sending messages in threads

SEND_TTS_MESSAGE = 4096

Allows for sending of /tts messages

SPEAK = 2097152

Allows for speaking in a voice channel

START_EMBEDDED_ACTIVITIES = 549755813888

Allows for launching activities (applications with the EMBEDDED` flag) in a voice channel

STREAM = 512

Allows the user to go live

USE_APPLICATION_COMMANDS = 2147483648

Allows members to use application commands, including slash commands and context menu commands.

USE_EXTERNAL_EMOJIS = 262144

Allows the usage of custom emojis from other servers

USE_EXTERNAL_STICKERS = 137438953472

Allows the usage of custom stickers from other servers

USE_VAD = 33554432

Allows for using voice-activity-detection in a voice channel

VIEW_AUDIT_LOG = 128

Allows for viewing of audit logs

VIEW_CHANNEL = 1024

Allows guild members to view a channel, which includes reading messages in text channels

VIEW_GUILD_INSIGHTS = 524288

Allows for viewing guild insights

SystemChannelFlags

class acord.SystemChannelFlags(value: int = 0, **kwds: Dict[str, bool])

An enumeration.

SUPPRESS_GUILD_REMINDER_NOTIFICATIONS = 4
SUPPRESS_JOIN_NOTIFICATIONS = 1
SUPPRESS_JOIN_NOTIFICATION_REPLIES = 8
SUPPRESS_PREMIUM_SUBSCRIPTIONS = 2

MessageFlags

class acord.MessageFlags(value: int = 0, **kwds: Dict[str, bool])

Message flags are used by discord to parse your message in a specified way.

Example

For example, MessageFlags.SUPPRESS_EMBEDS tells discord to not allow embeds

All message flags are assigned as a attribute, to combine flags, use the | operator, as shown below.

from acord import MessageFlags

myFlags = (
    MessageFlags.CROSSPOSTED
    | MessageFlags.IS_CROSSPOSTED
    ...
)

If bitwise operators are not to your taste, you can try using BaseFlagMeta.__call__().

CROSSPOSTED = 1

this message has been published to subscribed channels

EPHERMERAL = 64

this message is only visible to the user who invoked the Interaction

HAS_THREAD = 32

this message has an associated thread, with the same id as the message

IS_CROSSPOST = 2

this message originated from a message in another channel

LOADING = 128

this message is an Interaction Response and the bot is “thinking”

SOURCE_MESSAGE_DELETED = 8

the source message for this crosspost has been deleted

SUPPRESS_EMBEDS = 4

do not include any embeds when serializing this message

URGENT = 16

this message came from the urgent message system

Enums

GuildMessageNotification

class acord.GuildMessageNotification(value)

An enumeration.

ALL_MESSAGES = 0
ONLY_MENTIONS = 1

ExplicitContentFilterLevel

class acord.ExplicitContentFilterLevel(value)

An enumeration.

ALL_MEMBERS = 2
DISABLED = 0
MEMBERS_WITHOUT_ROLES = 1

MFALevel

class acord.MFALevel(value)

An enumeration.

ELEVATED = 1
NONE = 0

NSFWLevel

class acord.NSFWLevel(value)

An enumeration.

AGE_RESTRICTED = 3
DEFAULT = 0
EXPLICIT = 1
SAFE = 2

PremiumTierLevel

class acord.PremiumTierLevel(value)

An enumeration.

NONE = 0
TIER_1 = 1
TIER_2 = 2
TIER_3 = 3

VerificationLevel

class acord.VerificationLevel(value)

An enumeration.

HIGH = 3
LOW = 1
MEDIUM = 2
NONE = 0
VERY_HIGH = 4

ComponentTypes

class acord.ComponentTypes(value)

An enumeration.

ACTION_ROW = 1
BUTTON = 2
SELECT_MENU = 3

ButtonStyles

class acord.ButtonStyles(value)

An enumeration.

DANGER = 4

Red

Grey, navigates to URL

PRIMARY = 1

Blurple

SECONDARY = 2

Grey

SUCCESS = 3

Green

InteractionType

class acord.InteractionType(value)

An enumeration.

APPLICATION_COMMAND = 2
APPLICATION_COMMAND_AUTOCOMPLETE = 4
MESSAGE_COMPONENT = 3
PING = 1

ApplicationCommandType

class acord.ApplicationCommandType(value)

An enumeration.

CHAT_INPUT = 1
MESSAGE = 3
USER = 2

InteractionCallback

class acord.InteractionCallback(value)

An enumeration.

APPLICATION_COMMAND_AUTOCOMPLETE_RESULT = 8
CHANNEL_MESSAGE_WITH_SOURCE = 4
DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE = 5
DEFERRED_UPDATE_MESSAGE = 6
PONG = 1
UPDATE_MESSAGE = 7

ChannelTypes

class acord.ChannelTypes(value)

An enumeration.

DM = 1
GROUP_DM = 3
GUILD_CATEGORY = 4
GUILD_NEWS = 5
GUILD_NEWS_THREAD = 10
GUILD_PRIVATE_THREAD = 12
GUILD_PUBLIC_THREAD = 11
GUILD_STAGE_VOICE = 13
GUILD_STORE = 6
GUILD_TEXT = 0
GUILD_VOICE = 2

VoiceQuality

class acord.VoiceQuality(value)

An enumeration.

AUTO = 1
FULL = 2

ActivityType

class acord.ActivityType(value)

An enumeration.

COMPETING = 5
CUSTOM = 4
GAME = 0
LISTENING = 2
STREAMING = 1
WATCHING = 3

File

class acord.File(*, fp: Union[str, Type[os.PathLike], Type[io.BufferedIOBase]], position: int = 0, filename: str = None, spoiler: bool = False, is_closed: bool = False)
close() None

Closes the file, which prevents it from being sent again

read_and_close(*, position: int = 0, decode: bool = False)

Reads file from start and closes it

Parameters

position (int) – change were to read file from

reset(seek: Optional[bool] = False, position: Optional[int] = 0) None

Resets a files position

Parameters
  • seek (bool) – Whether to reset position

  • position (int) – Optional field to seek to a specific location in file

filename: Optional[str]

Name of file, if not given tries to read fp.name before returning unknown

fp: Union[str, Type[os.PathLike], Type[io.BufferedIOBase]]

A file object or the path to the file

is_closed: Optional[bool]

Whether fp is open or closed

position: Optional[int]

Position to were the file should be read from

spoiler: Optional[bool]

Whether the file should be marked as a spoiler

Presence

If working with the direct class itself is abit too much for you, consider using our helping functions.

acord.game(name: str, *, status: acord.bases.presence.StatusType = StatusType.online) acord.bases.presence.Presence
acord.listening(name: str, *, status: acord.bases.presence.StatusType = StatusType.online) acord.bases.presence.Presence
acord.watching(name: str, *, status: acord.bases.presence.StatusType = StatusType.online) acord.bases.presence.Presence
acord.competing(name: str, *, status: acord.bases.presence.StatusType = StatusType.online) acord.bases.presence.Presence
acord.streaming(name: str, url: str, *, status: acord.bases.presence.StatusType = StatusType.online) acord.bases.presence.Presence
Attributes
class acord.Presence(*, activities: List[acord.bases.presence.Activity], status: acord.bases.presence.StatusType = StatusType.online, afk: bool = False, since: float = None)
activities: List[acord.bases.presence.Activity]

List of activities for presence

afk: Optional[bool]

Whether the client is AFK

since: Optional[float]

Optional timestamp pointing to when client went idle, defaults to current call

status: Optional[acord.bases.presence.StatusType]

Status of client, default to StatusType.online

Activity

Attributes
class acord.Activity(*, name: str, type: int, url: str = None)
name: str

Name of activity

type: int

Type of activity, consider using ActivityType

url: Optional[str]

URL of activity, if STREAMING. must be one of youtube.com or twitch.tv