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¶
- defadd_field
- defcharacters
- defdict
- definsert_field
- defremove_field
- defset_author
- defset_footer
- 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
- 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.0is 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.
Add footer on embed
- 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")
- fields: Optional[List[acord.bases.embeds.EmbedField]]¶
Embed fields
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
- 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¶
- class acord.Component(*, type: acord.bases.enums.components.ComponentTypes, custom_id: str = None, disabled: bool = False)¶
-
- type: acord.bases.enums.components.ComponentTypes¶
Type of component
ActionRow¶
- 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
SelectOption¶
PermissionsOverwrite¶
- class acord.PermissionsOverwrite(*, id: int, type: Literal[0, 1], allow: acord.bases.flags.permissions.Permissions, deny: acord.bases.flags.permissions.Permissions)¶
AllowedMentions¶
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)
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 wantfrom 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
- EMBED_LINKS = 16384¶
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
@everyonetag to notify all users in a channel, and the@heretag 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
/ttsmessages
- 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¶
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_EMBEDStells discord to not allow embedsAll 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¶
ExplicitContentFilterLevel¶
MFALevel¶
NSFWLevel¶
VerificationLevel¶
ComponentTypes¶
InteractionType¶
ApplicationCommandType¶
InteractionCallback¶
ChannelTypes¶
VoiceQuality¶
ActivityType¶
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)¶
-
- 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
- fp: Union[str, Type[os.PathLike], Type[io.BufferedIOBase]]¶
A file object or the path to the file
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¶
- 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
- 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