Skip to content

Documentation

dskprt edited this page Apr 26, 2020 · 3 revisions

Fastcord

class fastcord.Fastcord(token, verbose=False)

Used to create a Fastcord instance to interact with the Discord API

Arguments

  • token (str)
    The Discord application token.
  • verbose [Optional] (bool)
    Defaults to False. When set to True, the application will log all messages sent by the websocket.

Fields

token (str)
The current bot token.

verbose (bool)
Whether or not the application should log all the messages sent by the websocket.

ws (websocket.WebSocketApp)
The websocket that is used to communicate with the Discord gateway.

Methods

run()
Starts the websocket.

change_presence(presence)
Changes the bots presence. Used to change the bot's status and/or activity.

change_activity(activity)
Changes the bots activity.

get_user(user_id) (fastcord.User)
Gets a Discord user by their ID.

  • Arguments
    • user_id (int)
      The users ID.

get_guild(guild_id) (fastcord.Guild)
Gets a Discord guild by its ID.

  • Arguments
    • guild_id (int)
      The guilds ID.

get_channel(channel_id) (fastcord.Channel)
Gets a Discord channel by its ID.

  • Arguments
    • channel_id (int)
      The channels ID.

Events

How to use events:

import fastcord

bot = fastcord.Fastcord(TOKEN)

@bot.on_event(EVENT_TYPE)
def on_some_event(ARGS?):
    # do something

bot.run()

Event types

message Called when a message is sent.

ready Called when the bot is ready.

Discord Objects

Note: Discord objects SHOULD NOT be created manually! (except for Activity, Presence and Embed)

Activity

class fastcord.Activity(name=None, _type=None, fastcord=None, obj=None)

Arguments

  • name (str) The activity's name.
  • _type (fastcord.ActivityType) The activity's type. Can be one of the following:
    fastcord.ActivityType.GAME
    fastcord.ActivityType.STREAMING
    fastcord.ActivityType.LISTENING
    fastcord.ActivityType.CUSTOM
  • fastcord (fastcord.Fastcord) The Fastcord instance. When set to None a new object for creating a custom Activity will be made instead.
  • obj (dict) The activity JSON object. When set to None a new object for creating a custom Activity will be made instead.

Fields

activity (dict) The activity's JSON object.

_name (str) The activity's name.

_type (fastcord.ActivityType) The activity's type.

_url (str) The activity's URL. Only applies to Streaming type activities.

Methods

name(name)
Sets the Activity's name.

  • Arguments
    • name (str) The new activity's name.

type(activity_type)
Sets the Activity's type.

  • Arguments
    • activity_type (fastcord.ActivityType) The new activity's type. Can be one of the following:
      fastcord.ActivityType.GAME
      fastcord.ActivityType.STREAMING
      fastcord.ActivityType.LISTENING
      fastcord.ActivityType.CUSTOM

url(url)
Sets the activity's URL. Only applies to Streaming type activities.

  • Arguments
    • url (str) The new activity's URL.

Attachment

class fastcord.Attachment(fastcord, obj)

Arguments

Fields

id (int) The attachment's id.

name (str) The attachment's name.

url (str) The attachment's URL.

Channel

class fastcord.Channel(fastcord, obj)

Arguments

Fields

id (int) The channel's id.

type (fastcord.ChannelType) The channel's type.

nsfw (bool) Whether or not that channel is marked as NSFW.

name (str) The channel's name.

slowmode (int) The amount of time in seconds a user has to wait before sending another message to the channel.

owner (fastcord.User) The owner of the DM. Only applies to DM type channels.

guild (fastcord.Guild) The guild to which this channel belongs to.

Methods

send(content=None, embed=None, file=None, filename="file")
Send a message to the channel.

  • Arguments
    • content (str) The message contents. Defaults to None.
    • embed (embed) The embed that should be sent with the message. Defaults to None.
    • file (bytearray) The file that should be sent with the message. Defaults to None.
    • filename (str) The file name. Should be changed with the appropriate extension for the file changed. Defaults to file.

Embed

class fastcord.Embed(fastcord=None, obj=None)

Arguments

  • fastcord (fastcord.Fastcord) The Fastcord instance. When set to None a new object for creating a custom Embed will be made instead.
  • obj (dict) The embed JSON object. When set to None a new object for creating a custom Embed will be made instead.

Emoji

Guild

Message

Presence

Reaction

Role

User