discordsdk package

Submodules

discordsdk.achievement module

class discordsdk.achievement.AchievementManager

Bases: object

count_user_achievements() int

Counts the list of a user’s achievements for iteration.

fetch_user_achievements(callback: Callable[[discordsdk.enum.Result], None]) None

Loads a stable list of the current user’s achievements to iterate over.

Returns discordsdk.enum.Result via callback.

get_user_achievement(achievement_id: int) None

Gets the user achievement for the given achievement id.

get_user_achievement_at(index: int) discordsdk.model.UserAchievement

Gets the user’s achievement at a given index of their list of achievements.

on_user_achievement_update(achievement: discordsdk.model.UserAchievement) None

Fires when an achievement is updated for the currently connected user

set_user_achievement(achievement_id: int, percent_complete: int, callback: Callable[[discordsdk.enum.Result], None]) None

Updates the current user’s status for a given achievement.

Returns discordsdk.enum.Result via callback.

discordsdk.activity module

class discordsdk.activity.ActivityManager

Bases: object

accept_invite(user_id: int, callback: Callable[[discordsdk.enum.Result], None]) None

Accepts a game invitation from a given userId.

Returns discordsdk.enum.Result (int) via callback.

clear_activity(callback: Callable[[discordsdk.enum.Result], None]) None

Clears a user’s presence in Discord to make it show nothing.

Returns discordsdk.enum.Result (int) via callback.

on_activity_invite(type: discordsdk.enum.ActivityActionType, user: discordsdk.model.User, activity: discordsdk.model.Activity) None

Fires when the user receives a join or spectate invite.

on_activity_join(join_secret: str) None

Fires when a user accepts a game chat invite or receives confirmation from Asking to Join.

on_activity_join_request(user: discordsdk.model.User) None

Fires when a user asks to join the current user’s game.

on_activity_spectate(spectate_secret: str) None

Fires when a user accepts a spectate chat invite or clicks the Spectate button on a user’s profile.

register_command(command: str) discordsdk.enum.Result

Registers a command by which Discord can launch your game.

register_steam(steam_id: int) discordsdk.enum.Result

Registers your game’s Steam app id for the protocol steam://run-game-id/<id>.

send_invite(user_id: int, type: discordsdk.enum.ActivityActionType, content: str, callback: Callable[[discordsdk.enum.Result], None]) None

Sends a game invite to a given user.

Returns discordsdk.enum.Result (int) via callback.

send_request_reply(user_id: int, reply: discordsdk.enum.ActivityJoinRequestReply, callback: Callable[[discordsdk.enum.Result], None]) None

Sends a reply to an Ask to Join request.

Returns discordsdk.enum.Result (int) via callback.

update_activity(activity: discordsdk.model.Activity, callback: Callable[[discordsdk.enum.Result], None]) None

Set a user’s presence in Discord to a new activity.

Returns discordsdk.enum.Result (int) via callback.

discordsdk.application module

class discordsdk.application.ApplicationManager

Bases: object

get_current_branch() str

Get the name of pushed branch on which the game is running.

get_current_locale() str

Get the locale the current user has Discord set to.

get_oauth2_token(callback: Callable[[discordsdk.enum.Result, Optional[discordsdk.model.OAuth2Token]], None]) None

Retrieve an oauth2 bearer token for the current user.

Returns discordsdk.enum.Result (int) and OAuth2Token (str) via callback.

get_ticket(callback: Callable[[discordsdk.enum.Result, Optional[str]], None]) None

Get the signed app ticket for the current user.

Returns discordsdk.Enum.Result (int) and str via callback.

validate_or_exit(callback: Callable[[discordsdk.enum.Result], None]) None

Checks if the current user has the entitlement to run this game.

Returns discordsdk.enum.Result (int) via callback.

discordsdk.discord module

class discordsdk.discord.Discord(client_id: int, flags: discordsdk.enum.CreateFlags)

Bases: object

core: discordsdk.sdk.IDiscordCore = None
get_achievement_manager() discordsdk.achievement.AchievementManager

Fetches an instance of the manager for interfacing with achievements in the SDK.

get_activity_manager() discordsdk.activity.ActivityManager

Fetches an instance of the manager for interfacing with activies in the SDK.

get_application_manager() discordsdk.application.ApplicationManager

Fetches an instance of the manager for interfacing with applications in the SDK.

get_image_manager() discordsdk.image.ImageManager

Fetches an instance of the manager for interfacing with images in the SDK.

get_lobby_manager() discordsdk.lobby.LobbyManager

Fetches an instance of the manager for interfacing with lobbies in the SDK.

get_network_manager() discordsdk.network.NetworkManager

Fetches an instance of the manager for interfacing with networking in the SDK.

get_overlay_manager() discordsdk.overlay.OverlayManager

Fetches an instance of the manager for interfacing with the overlay in the SDK.

get_relationship_manager() discordsdk.relationship.RelationshipManager

Fetches an instance of the manager for interfacing with relationships in the SDK.

get_storage_manager() discordsdk.storage.StorageManager

Fetches an instance of the manager for interfacing with storage in the SDK.

get_store_manager() discordsdk.store.StoreManager

Fetches an instance of the manager for interfacing with SKUs and Entitlements in the SDK.

get_user_manager() discordsdk.user.UserManager

Fetches an instance of the manager for interfacing with users in the SDK.

get_voice_manager() discordsdk.voice.VoiceManager

Fetches an instance of the manager for interfacing with voice chat in the SDK.

run_callbacks() None

Runs all pending SDK callbacks.

set_log_hook(min_level: discordsdk.enum.LogLevel, hook: Callable[[discordsdk.enum.LogLevel, str], None]) None

Registers a logging callback function with the minimum level of message to receive.

discordsdk.enum module

class discordsdk.enum.ActivityActionType(value)

Bases: enum.IntEnum

An enumeration.

join = 1
spectate = 2
class discordsdk.enum.ActivityJoinRequestReply(value)

Bases: enum.IntEnum

An enumeration.

ignore = 2
no = 0
yes = 1
class discordsdk.enum.ActivityType(value)

Bases: enum.IntEnum

An enumeration.

custom = 4
listening = 2
playing = 0
streaming = 1
class discordsdk.enum.CreateFlags(value)

Bases: enum.IntFlag

An enumeration.

default = 0
no_require_discord = 1
class discordsdk.enum.EntitlementType(value)

Bases: enum.IntEnum

An enumeration.

DeveloperGift = 3
FreePurchase = 5
PremiumPurchase = 7
PremiumSubscription = 2
Purchase = 1
TestModePurchase = 4
UserGift = 6
class discordsdk.enum.ImageType(value)

Bases: enum.IntEnum

An enumeration.

user = 0
class discordsdk.enum.InputModeType(value)

Bases: enum.IntEnum

An enumeration.

PushToTalk = 1
VoiceActivity = 0
class discordsdk.enum.LobbySearchCast(value)

Bases: enum.IntEnum

An enumeration.

Number = 2
String = 1
class discordsdk.enum.LobbySearchComparison(value)

Bases: enum.IntEnum

An enumeration.

Equal = 0
GreaterThan = 1
GreaterThanOrEqual = 2
LessThan = -1
LessThanOrEqual = -2
NotEqual = 3
class discordsdk.enum.LobbySearchDistance(value)

Bases: enum.IntEnum

An enumeration.

Default = 1
Extended = 2
Global = 3
Local = 0
class discordsdk.enum.LobbyType(value)

Bases: enum.IntEnum

An enumeration.

private = 1
public = 2
class discordsdk.enum.LogLevel(value)

Bases: enum.IntEnum

An enumeration.

debug = 3
error = 0
info = 2
warning = 1
class discordsdk.enum.PremiumType(value)

Bases: enum.IntEnum

An enumeration.

none_ = 0
tier_1 = 1
tier_2 = 2
class discordsdk.enum.RelationshipType(value)

Bases: enum.IntEnum

An enumeration.

blocked = 2
friend = 1
implicit = 5
none_ = 0
pending_incoming = 3
pending_outgoing = 4
class discordsdk.enum.Result(value)

Bases: enum.IntEnum

An enumeration.

application_mismatch = 17
capture_shortcut_already_listening = 39
conflict = 10
drawing_init_failed = 44
get_guild_timeout = 37
insufficient_buffer = 28
internal_error = 4
invalid_access_token = 16
invalid_base_64 = 19
invalid_channel = 32
invalid_command = 6
invalid_data_url = 18
invalid_entitlement = 25
invalid_event = 31
invalid_file_size = 24
invalid_filename = 23
invalid_gift_code = 41
invalid_guild = 30
invalid_invite = 14
invalid_join_secret = 12
invalid_lobby_secret = 22
invalid_origin = 33
invalid_payload = 5
invalid_permissions = 7
invalid_secret = 11
invalid_version = 2
lobby_full = 21
lock_failed = 3
no_eligible_activity = 13
not_authenticated = 15
not_fetched = 8
not_filtered = 20
not_found = 9
not_installed = 26
not_running = 27
oauth2_error = 35
ok = 0
purchase_canceled = 29
purchase_error = 42
rate_limited = 34
select_channel_timeout = 36
select_voice_force_required = 38
service_unavailable = 1
transaction_aborted = 43
unauthorized_for_achievement = 40
class discordsdk.enum.SkuType(value)

Bases: enum.IntEnum

An enumeration.

Application = 1
Bundle = 4
Consumable = 3
DLC = 2
class discordsdk.enum.Status(value)

Bases: enum.IntEnum

An enumeration.

do_not_disturb = 3
idle = 2
offline = 0
online = 1
class discordsdk.enum.UserFlag(value)

Bases: enum.IntFlag

An enumeration.

hype_squad_events = 4
hype_squad_house_1 = 64
hype_squad_house_2 = 128
hype_squad_house_3 = 256
partner = 2

discordsdk.exception module

exception discordsdk.exception.DiscordException

Bases: Exception

exception discordsdk.exception.application_mismatch

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.capture_shortcut_already_listening

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.conflict

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.drawing_init_failed

Bases: discordsdk.exception.DiscordException

discordsdk.exception.exception

alias of discordsdk.exception.drawing_init_failed

discordsdk.exception.get_exception(result)
exception discordsdk.exception.get_guild_timeout

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.insufficient_buffer

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.internal_error

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.invalid_access_token

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.invalid_base_64

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.invalid_channel

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.invalid_command

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.invalid_data_url

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.invalid_entitlement

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.invalid_event

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.invalid_file_size

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.invalid_filename

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.invalid_gift_code

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.invalid_guild

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.invalid_invite

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.invalid_join_secret

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.invalid_lobby_secret

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.invalid_origin

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.invalid_payload

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.invalid_permissions

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.invalid_secret

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.invalid_version

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.lobby_full

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.lock_failed

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.no_eligible_activity

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.not_authenticated

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.not_fetched

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.not_filtered

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.not_found

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.not_installed

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.not_running

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.oauth2_error

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.ok

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.purchase_canceled

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.purchase_error

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.rate_limited

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.select_channel_timeout

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.select_voice_force_required

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.service_unavailable

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.transaction_aborted

Bases: discordsdk.exception.DiscordException

exception discordsdk.exception.unauthorized_for_achievement

Bases: discordsdk.exception.DiscordException

discordsdk.image module

class discordsdk.image.ImageManager

Bases: object

fetch(handle: discordsdk.model.ImageHandle, refresh: bool, callback: Callable[[discordsdk.enum.Result, Optional[discordsdk.model.ImageHandle]], None]) None

Prepares an image to later retrieve data about it.

Returns discordsdk.enum.Result (int) and ImageHandle via callback.

get_data(handle: discordsdk.model.ImageHandle) bytes

Gets the image data for a given user’s avatar.

get_dimensions(handle: discordsdk.model.ImageHandle) discordsdk.model.ImageDimensions

Gets the dimension for the given user’s avatar’s source image

discordsdk.lobby module

class discordsdk.lobby.LobbyManager

Bases: object

connect_lobby(lobby_id: int, lobby_secret: str, callback: Callable[[discordsdk.enum.Result], None]) None

Connects the current user to a given lobby.

connect_lobby_with_activity_secret(activity_secret: str, callback: Callable[[discordsdk.enum.Result, Optional[discordsdk.model.Lobby]], None]) None

Connects the current user to a lobby; requires the special activity secret from the lobby which is a concatenated lobby_id and secret.

connect_network(lobby_id: int) None

Connects to the networking layer for the given lobby ID.

connect_voice(lobby_id: int, callback: Callable[[discordsdk.enum.Result], None]) None

Connects to the voice channel of the current lobby.

Returns discordsdk.enum.Result (int) via callback.

create_lobby(transaction: discordsdk.lobby.LobbyTransaction, callback: Callable[[discordsdk.enum.Result, Optional[discordsdk.model.Lobby]], None]) None

Creates a lobby.

Returns discordsdk.enum.Result (int) and Lobby via callback.

delete_lobby(lobby_id: int, callback: Callable[[discordsdk.enum.Result], None]) None

Deletes a given lobby.

disconnect_lobby(lobby_id: int, callback: Callable[[discordsdk.enum.Result], None]) None

Disconnects the current user from a lobby.

Returns discordsdk.enum.Result (int) via callback.

disconnect_network(lobby_id: int) None

Disconnects from the networking layer for the given lobby ID.

disconnect_voice(lobby_id: int, callback: Callable[[discordsdk.enum.Result], None]) None

Disconnects from the voice channel of a given lobby.

Returns discordsdk.enum.Result (int) via callback.

flush_network() None

Flushes the network. Call this when you’re done sending messages.

get_lobby(lobby_id: int) discordsdk.model.Lobby

Gets the lobby object for a given lobby id.

get_lobby_activity_secret(lobby_id: int) str

Gets the special activity secret for a given lobby.

get_lobby_create_transaction() discordsdk.lobby.LobbyTransaction

Gets a Lobby transaction used for creating a new lobby

get_lobby_id(index: int) int

Returns the id for the lobby at the given index.

get_lobby_metadata_key(lobby_id: int, index: int) str

Returns the key for the lobby metadata at the given index.

get_lobby_metadata_value(lobby_id: int, key: str) str

Returns lobby metadata value for a given key and id.

get_lobby_update_transaction(lobby_id: int) discordsdk.lobby.LobbyTransaction

Gets a lobby transaction used for updating an existing lobby.

get_member_metadata_key(lobby_id: int, user_id: int, index: int) str

Gets the key for the lobby metadata at the given index on a lobby member.

get_member_metadata_value(lobby_id: int, user_id: int, key: str) str

Returns user metadata for a given key.

get_member_update_transaction(lobby_id: int, user_id: int) discordsdk.lobby.LobbyMemberTransaction

Gets a new member transaction for a lobby member in a given lobby.

get_member_user(lobby_id: int, user_id: int) discordsdk.model.User

Gets the user object for a given user id.

get_member_user_id(lobby_id: int, index: int) int

Gets the user id of the lobby member at the given index.

get_search_query() discordsdk.lobby.LobbySearchQuery

Creates a search object to search available lobbies.

lobby_count() int

Get the number of lobbies that match the search.

lobby_metadata_count(lobby_id: int) int

Returns the number of metadata key/value pairs on a given lobby.

member_count(lobby_id: int) int

Get the number of members in a lobby.

member_metadata_count(lobby_id: int, user_id: int) int

Gets the number of metadata key/value pairs for the given lobby member.

on_lobby_delete(lobby_id: int, reason: str) None

Fired when a lobby is deleted.

on_lobby_message(lobby_id: int, user_id: int, message: str) None

Fires when a message is sent to the lobby.

on_lobby_update(lobby_id: int) None

Fires when a lobby is updated.

on_member_connect(lobby_id: int, user_id: int) None

Fires when a new member joins the lobby.

on_member_disconnect(lobby_id: int, user_id: int) None

Fires when a member leaves the lobby.

on_member_update(lobby_id: int, user_id: int) None

Fires when data for a lobby member is updated.

on_network_message(lobby_id: int, user_id: int, channel_id: int, data: bytes) None

Fires when the user receives a message from the lobby’s networking layer.

on_speaking(lobby_id: int, user_id: int, speaking: bool) None

Fires when a user connected to voice starts or stops speaking.

open_network_channel(lobby_id: int, channel_id: int, reliable: bool) None

Opens a network channel to all users in a lobby on the given channel number. No need to iterate over everyone!

search(search: discordsdk.lobby.LobbySearchQuery, callback: Callable[[discordsdk.enum.Result], None]) None

Searches available lobbies based on the search criteria chosen in the LobbySearchQuery member functions.

Lobbies that meet the criteria are then globally filtered, and can be accessed via iteration with lobby_count() and get_lobby_id(). The callback fires when the list of lobbies is stable and ready for iteration.

Returns discordsdk.enum.Result (int) via callback.

send_lobby_message(lobby_id: int, data: str, callback: Callable[[discordsdk.enum.Result], None]) None

Sends a message to the lobby on behalf of the current user.

Returns discordsdk.Result (int) via callback.

send_network_message(lobby_id: int, user_id: int, channel_id: int, data: bytes) None

Sends a network message to the given user ID that is a member of the given lobby ID over the given channel ID.

update_lobby(lobby_id: int, transaction: discordsdk.lobby.LobbyTransaction, callback: Callable[[discordsdk.enum.Result], None]) None

Updates a lobby with data from the given transaction.

update_member(lobby_id: int, user_id: int, transaction: discordsdk.lobby.LobbyMemberTransaction, callback: Callable[[discordsdk.enum.Result], None]) None

Updates lobby member info for a given member of the lobby.

Returns discordsdk.enum.Result (int) via callback.

class discordsdk.lobby.LobbyMemberTransaction(internal: discordsdk.sdk.IDiscordLobbyMemberTransaction)

Bases: object

delete_metadata(key: str) None

Sets metadata value under a given key name for the current user.

set_metadata(key: str, value: str) None

Sets metadata value under a given key name for the current user.

class discordsdk.lobby.LobbySearchQuery(internal: discordsdk.sdk.IDiscordLobbySearchQuery)

Bases: object

distance(distance: discordsdk.enum.LobbySearchDistance) None

Filters lobby results to within certain regions relative to the user’s location.

filter(key: str, comp: discordsdk.enum.LobbySearchComparison, cast: discordsdk.enum.LobbySearchCast, value: str) None

Filters lobbies based on metadata comparison.

limit(limit: int) None

Limits the number of lobbies returned in a search.

sort(key: str, cast: discordsdk.enum.LobbySearchCast, value: str) None

Sorts the filtered lobbies based on “near-ness” to a given value.

class discordsdk.lobby.LobbyTransaction(internal: discordsdk.sdk.IDiscordLobbyTransaction)

Bases: object

delete_metadata(key: str) None

Deletes the lobby metadata for a key.

set_capacity(capacity: int) None

Sets a new capacity for the lobby.

set_locked(locked: bool) None

Sets the lobby to locked or unlocked.

set_metadata(key: str, value: str) None

Sets metadata value under a given key name for the lobby.

set_owner(user_id: int) None

Sets a new owner for the lobby.

set_type(type: discordsdk.enum.LobbyType) None

Marks a lobby as private or public.

discordsdk.model module

class discordsdk.model.Activity(**kwargs)

Bases: discordsdk.model.Model

application_id: int
assets: discordsdk.model.ActivityAssets
details: str
instance: bool
name: str
party: discordsdk.model.ActivityParty
secrets: discordsdk.model.ActivitySecrets
state: str
timestamps: discordsdk.model.ActivityTimestamps
class discordsdk.model.ActivityAssets(**kwargs)

Bases: discordsdk.model.Model

large_image: str
large_text: str
small_image: str
small_text: str
class discordsdk.model.ActivityParty(**kwargs)

Bases: discordsdk.model.Model

id: str
size: discordsdk.model.PartySize
class discordsdk.model.ActivitySecrets(**kwargs)

Bases: discordsdk.model.Model

join: str
match: str
spectate: str
class discordsdk.model.ActivityTimestamps(**kwargs)

Bases: discordsdk.model.Model

end: int
start: int
class discordsdk.model.Entitlement(**kwargs)

Bases: discordsdk.model.Model

id: int
sku_id: int
type: discordsdk.enum.EntitlementType
class discordsdk.model.FileStat(**kwargs)

Bases: discordsdk.model.Model

filename: str
last_modified: int
size: int
class discordsdk.model.ImageDimensions(**kwargs)

Bases: discordsdk.model.Model

height: int
width: int
class discordsdk.model.ImageHandle(**kwargs)

Bases: discordsdk.model.Model

id: int
size: int
type: discordsdk.enum.ImageType
class discordsdk.model.InputMode(**kwargs)

Bases: discordsdk.model.Model

shortcut: str
type: discordsdk.enum.InputModeType
class discordsdk.model.Lobby(**kwargs)

Bases: discordsdk.model.Model

capacity: int
id: int
locked: bool
owner_id: int
secret: str
type: discordsdk.enum.LobbyType
class discordsdk.model.Model(**kwargs)

Bases: object

class discordsdk.model.OAuth2Token(**kwargs)

Bases: discordsdk.model.Model

access_token: str
expires: str
scopes: str
class discordsdk.model.PartySize(**kwargs)

Bases: discordsdk.model.Model

current_size: int
max_size: int
class discordsdk.model.Presence(**kwargs)

Bases: discordsdk.model.Model

activity: discordsdk.model.Activity
status: discordsdk.enum.Status
class discordsdk.model.Relationship(**kwargs)

Bases: discordsdk.model.Model

presence: discordsdk.model.Presence
type: discordsdk.enum.RelationshipType
user: discordsdk.model.User
class discordsdk.model.Sku(**kwargs)

Bases: discordsdk.model.Model

id: int
name: str
price: discordsdk.model.SkuPrice
type: discordsdk.enum.SkuType
class discordsdk.model.SkuPrice(**kwargs)

Bases: discordsdk.model.Model

amount: int
currency: str
class discordsdk.model.User(**kwargs)

Bases: discordsdk.model.Model

avatar: str
bot: str
discriminator: str
id: int
username: str
class discordsdk.model.UserAchievement(**kwargs)

Bases: discordsdk.model.Model

achievement_id: int
percent_complete: int
unlocked_at: str
user_id: str

discordsdk.network module

class discordsdk.network.NetworkManager

Bases: object

close_channel(peer_id: int, channel_id: int) None

Close the connection to a given user by peer_id on the given channel.

close_peer(peer_id: int) None

Disconnects the network session to another Discord user.

flush() None

Flushes the network.

get_peer_id() int

Get the networking peer_id for the current user, allowing other users to send packets to them.

on_message(peer_id: int, channel_id: int, data: bytes) None

Fires when you receive data from another user.

on_route_update(route: str) None

Fires when your networking route has changed.

open_channel(peer_id: int, channel_id: int, reliable: bool) None

Opens a channel to a user with their given peer_id on the given channel number.

open_peer(peer_id: int, route: str) None

Opens a network connection to another Discord user.

send_message(peer_id: int, channel_id: int, data: bytes) None

Sends data to a given peer_id through the given channel.

update_peer(peer_id: int, route: str) None

Updates the network connection to another Discord user.

discordsdk.overlay module

class discordsdk.overlay.OverlayManager

Bases: object

is_enabled() bool

Check whether the user has the overlay enabled or disabled.

is_locked() bool

Check if the overlay is currently locked or unlocked

on_toggle(locked: bool) None

Fires when the overlay is locked or unlocked (a.k.a. opened or closed)

open_activity_invite(type: discordsdk.enum.ActivityActionType, callback: Callable[[discordsdk.enum.Result], None]) None

Opens the overlay modal for sending game invitations to users, channels, and servers.

open_guild_invite(code: str, callback: Callable[[discordsdk.enum.Result], None]) None

Opens the overlay modal for joining a Discord guild, given its invite code.

open_voice_settings(callback: Callable[[discordsdk.enum.Result], None]) None

Opens the overlay widget for voice settings for the currently connected application.

set_locked(locked: bool, callback: Callable[[discordsdk.enum.Result], None]) None

Locks or unlocks input in the overlay.

discordsdk.relationship module

class discordsdk.relationship.RelationshipManager

Bases: object

count() int

Get the number of relationships that match your filter.

filter(filter: Callable[[discordsdk.model.Relationship], None]) None

Filters a user’s relationship list by a boolean condition.

get(user_id: int) discordsdk.model.Relationship

Get the relationship between the current user and a given user by id.

get_at(index: int) discordsdk.model.Relationship

Get the relationship at a given index when iterating over a list of relationships.

on_refresh() None

Fires at initialization when Discord has cached a snapshot of the current status of all your relationships.

on_relationship_update(relationship: discordsdk.model.Relationship) None

Fires when a relationship in the filtered list changes, like an updated presence or user attribute.

discordsdk.sdk module

class discordsdk.sdk.DiscordActivity

Bases: _ctypes.Structure

application_id

Structure/Union member

assets

Structure/Union member

details

Structure/Union member

instance

Structure/Union member

name

Structure/Union member

party

Structure/Union member

secrets

Structure/Union member

state

Structure/Union member

timestamps

Structure/Union member

type

Structure/Union member

class discordsdk.sdk.DiscordActivityAssets

Bases: _ctypes.Structure

large_image

Structure/Union member

large_text

Structure/Union member

small_image

Structure/Union member

small_text

Structure/Union member

class discordsdk.sdk.DiscordActivityParty

Bases: _ctypes.Structure

id

Structure/Union member

size

Structure/Union member

class discordsdk.sdk.DiscordActivitySecrets

Bases: _ctypes.Structure

join

Structure/Union member

match

Structure/Union member

spectate

Structure/Union member

class discordsdk.sdk.DiscordActivityTimestamps

Bases: _ctypes.Structure

end

Structure/Union member

start

Structure/Union member

discordsdk.sdk.DiscordBranch

alias of discordsdk.sdk.c_char_Array_4096

class discordsdk.sdk.DiscordCreateParams

Bases: _ctypes.Structure

achievement_events

Structure/Union member

achievement_version

Structure/Union member

activity_events

Structure/Union member

activity_version

Structure/Union member

application_events

Structure/Union member

application_version

Structure/Union member

client_id

Structure/Union member

event_data

Structure/Union member

events

Structure/Union member

flags

Structure/Union member

image_events

Structure/Union member

image_version

Structure/Union member

lobby_events

Structure/Union member

lobby_version

Structure/Union member

network_events

Structure/Union member

network_version

Structure/Union member

overlay_events

Structure/Union member

overlay_version

Structure/Union member

relationship_events

Structure/Union member

relationship_version

Structure/Union member

storage_events

Structure/Union member

storage_version

Structure/Union member

store_events

Structure/Union member

store_version

Structure/Union member

user_events

Structure/Union member

user_version

Structure/Union member

voice_events

Structure/Union member

voice_version

Structure/Union member

discordsdk.sdk.DiscordCreateParamsSetDefault(params)
discordsdk.sdk.DiscordDateTime

alias of discordsdk.sdk.c_char_Array_64

class discordsdk.sdk.DiscordEntitlement

Bases: _ctypes.Structure

id

Structure/Union member

sku_id

Structure/Union member

type

Structure/Union member

class discordsdk.sdk.DiscordFileStat

Bases: _ctypes.Structure

filename

Structure/Union member

last_modified

Structure/Union member

size

Structure/Union member

class discordsdk.sdk.DiscordImageDimensions

Bases: _ctypes.Structure

height

Structure/Union member

width

Structure/Union member

class discordsdk.sdk.DiscordImageHandle

Bases: _ctypes.Structure

id

Structure/Union member

size

Structure/Union member

type

Structure/Union member

class discordsdk.sdk.DiscordInputMode

Bases: _ctypes.Structure

shortcut

Structure/Union member

type

Structure/Union member

class discordsdk.sdk.DiscordLobby

Bases: _ctypes.Structure

capacity

Structure/Union member

id

Structure/Union member

locked

Structure/Union member

owner_id

Structure/Union member

secret

Structure/Union member

type

Structure/Union member

discordsdk.sdk.DiscordLobbySecret

alias of discordsdk.sdk.c_char_Array_128

discordsdk.sdk.DiscordLocale

alias of discordsdk.sdk.c_char_Array_128

discordsdk.sdk.DiscordMetadataKey

alias of discordsdk.sdk.c_char_Array_256

discordsdk.sdk.DiscordMetadataValue

alias of discordsdk.sdk.c_char_Array_4096

class discordsdk.sdk.DiscordOAuth2Token

Bases: _ctypes.Structure

access_token

Structure/Union member

expires

Structure/Union member

scopes

Structure/Union member

class discordsdk.sdk.DiscordPartySize

Bases: _ctypes.Structure

current_size

Structure/Union member

max_size

Structure/Union member

discordsdk.sdk.DiscordPath

alias of discordsdk.sdk.c_char_Array_4096

class discordsdk.sdk.DiscordPresence

Bases: _ctypes.Structure

activity

Structure/Union member

status

Structure/Union member

class discordsdk.sdk.DiscordRelationship

Bases: _ctypes.Structure

presence

Structure/Union member

type

Structure/Union member

user

Structure/Union member

class discordsdk.sdk.DiscordSku

Bases: _ctypes.Structure

id

Structure/Union member

name

Structure/Union member

price

Structure/Union member

type

Structure/Union member

class discordsdk.sdk.DiscordSkuPrice

Bases: _ctypes.Structure

amount

Structure/Union member

currency

Structure/Union member

class discordsdk.sdk.DiscordUser

Bases: _ctypes.Structure

avatar

Structure/Union member

bot

Structure/Union member

discriminator

Structure/Union member

id

Structure/Union member

username

Structure/Union member

class discordsdk.sdk.DiscordUserAchievement

Bases: _ctypes.Structure

achievement_id

Structure/Union member

percent_complete

Structure/Union member

unlocked_at

Structure/Union member

user_id

Structure/Union member

class discordsdk.sdk.IDiscordAchievementEvents

Bases: _ctypes.Structure

on_user_achievement_update: Callable[[discordsdk.sdk.DiscordUserAchievement], None]

Structure/Union member

class discordsdk.sdk.IDiscordAchievementManager

Bases: _ctypes.Structure

count_user_achievements: Callable[[...], None]

Structure/Union member

fetch_user_achievements: Callable[[...], None]

Structure/Union member

get_user_achievement: Callable[[...], ctypes.c_int]

Structure/Union member

get_user_achievement_at: Callable[[...], ctypes.c_int]

Structure/Union member

set_user_achievement: Callable[[...], None]

Structure/Union member

class discordsdk.sdk.IDiscordActivityEvents

Bases: _ctypes.Structure

on_activity_invite: Callable[[...], None]

Structure/Union member

on_activity_join: Callable[[...], None]

Structure/Union member

on_activity_join_request: Callable[[...], None]

Structure/Union member

on_activity_spectate: Callable[[...], None]

Structure/Union member

class discordsdk.sdk.IDiscordActivityManager

Bases: _ctypes.Structure

accept_invite: Callable[[...], None]

Structure/Union member

clear_activity: Callable[[...], None]

Structure/Union member

register_command: Callable[[...], ctypes.c_int]

Structure/Union member

register_steam: Callable[[...], ctypes.c_int]

Structure/Union member

send_invite: Callable[[...], None]

Structure/Union member

send_request_reply: Callable[[...], None]

Structure/Union member

update_activity: Callable[[...], None]

Structure/Union member

class discordsdk.sdk.IDiscordApplicationManager

Bases: _ctypes.Structure

get_current_branch

Structure/Union member

get_current_locale

Structure/Union member

get_oauth2_token

Structure/Union member

get_ticket

Structure/Union member

validate_or_exit

Structure/Union member

class discordsdk.sdk.IDiscordCore

Bases: _ctypes.Structure

destroy

Structure/Union member

get_achievement_manager

Structure/Union member

get_activity_manager

Structure/Union member

get_application_manager

Structure/Union member

get_image_manager

Structure/Union member

get_lobby_manager

Structure/Union member

get_network_manager

Structure/Union member

get_overlay_manager

Structure/Union member

get_relationship_manager

Structure/Union member

get_storage_manager

Structure/Union member

get_store_manager

Structure/Union member

get_user_manager

Structure/Union member

get_voice_manager

Structure/Union member

run_callbacks

Structure/Union member

set_log_hook

Structure/Union member

class discordsdk.sdk.IDiscordImageManager

Bases: _ctypes.Structure

fetch

Structure/Union member

get_data

Structure/Union member

get_dimensions

Structure/Union member

class discordsdk.sdk.IDiscordLobbyEvents

Bases: _ctypes.Structure

on_lobby_delete

Structure/Union member

on_lobby_message

Structure/Union member

on_lobby_update

Structure/Union member

on_member_connect

Structure/Union member

on_member_disconnect

Structure/Union member

on_member_update

Structure/Union member

on_network_message

Structure/Union member

on_speaking

Structure/Union member

class discordsdk.sdk.IDiscordLobbyManager

Bases: _ctypes.Structure

connect_lobby

Structure/Union member

connect_lobby_with_activity_secret

Structure/Union member

connect_network

Structure/Union member

connect_voice

Structure/Union member

create_lobby

Structure/Union member

delete_lobby

Structure/Union member

disconnect_lobby

Structure/Union member

disconnect_network

Structure/Union member

disconnect_voice

Structure/Union member

flush_network

Structure/Union member

get_lobby

Structure/Union member

get_lobby_activity_secret

Structure/Union member

get_lobby_create_transaction

Structure/Union member

get_lobby_id

Structure/Union member

get_lobby_metadata_key

Structure/Union member

get_lobby_metadata_value

Structure/Union member

get_lobby_update_transaction

Structure/Union member

get_member_metadata_key

Structure/Union member

get_member_metadata_value

Structure/Union member

get_member_update_transaction

Structure/Union member

get_member_user

Structure/Union member

get_member_user_id

Structure/Union member

get_search_query

Structure/Union member

lobby_count

Structure/Union member

lobby_metadata_count

Structure/Union member

member_count

Structure/Union member

member_metadata_count

Structure/Union member

open_network_channel

Structure/Union member

search

Structure/Union member

send_lobby_message

Structure/Union member

send_network_message

Structure/Union member

update_lobby

Structure/Union member

update_member

Structure/Union member

class discordsdk.sdk.IDiscordLobbyMemberTransaction

Bases: _ctypes.Structure

delete_metadata

Structure/Union member

set_metadata

Structure/Union member

class discordsdk.sdk.IDiscordLobbySearchQuery

Bases: _ctypes.Structure

distance

Structure/Union member

filter

Structure/Union member

limit

Structure/Union member

sort

Structure/Union member

class discordsdk.sdk.IDiscordLobbyTransaction

Bases: _ctypes.Structure

delete_metadata

Structure/Union member

set_capacity

Structure/Union member

set_locked

Structure/Union member

set_metadata

Structure/Union member

set_owner

Structure/Union member

set_type

Structure/Union member

class discordsdk.sdk.IDiscordNetworkEvents

Bases: _ctypes.Structure

on_message

Structure/Union member

on_route_update

Structure/Union member

class discordsdk.sdk.IDiscordNetworkManager

Bases: _ctypes.Structure

close_channel

Structure/Union member

close_peer

Structure/Union member

flush

Structure/Union member

get_peer_id

Structure/Union member

open_channel

Structure/Union member

open_peer

Structure/Union member

send_message

Structure/Union member

update_peer

Structure/Union member

class discordsdk.sdk.IDiscordOverlayEvents

Bases: _ctypes.Structure

on_toggle

Structure/Union member

class discordsdk.sdk.IDiscordOverlayManager

Bases: _ctypes.Structure

is_enabled

Structure/Union member

is_locked

Structure/Union member

open_activity_invite

Structure/Union member

open_guild_invite

Structure/Union member

open_voice_settings

Structure/Union member

set_locked

Structure/Union member

class discordsdk.sdk.IDiscordRelationshipEvents

Bases: _ctypes.Structure

on_refresh

Structure/Union member

on_relationship_update

Structure/Union member

class discordsdk.sdk.IDiscordRelationshipManager

Bases: _ctypes.Structure

count

Structure/Union member

filter

Structure/Union member

get

Structure/Union member

get_at

Structure/Union member

class discordsdk.sdk.IDiscordStorageManager

Bases: _ctypes.Structure

count

Structure/Union member

delete_

Structure/Union member

exists

Structure/Union member

get_path

Structure/Union member

read

Structure/Union member

read_async

Structure/Union member

read_async_partial

Structure/Union member

stat

Structure/Union member

stat_at

Structure/Union member

write

Structure/Union member

write_async

Structure/Union member

class discordsdk.sdk.IDiscordStoreEvents

Bases: _ctypes.Structure

on_entitlement_create

Structure/Union member

on_entitlement_delete

Structure/Union member

class discordsdk.sdk.IDiscordStoreManager

Bases: _ctypes.Structure

count_entitlements

Structure/Union member

count_skus

Structure/Union member

fetch_entitlements

Structure/Union member

fetch_skus

Structure/Union member

get_entitlement

Structure/Union member

get_entitlement_at

Structure/Union member

get_sku

Structure/Union member

get_sku_at

Structure/Union member

has_sku_entitlement

Structure/Union member

start_purchase

Structure/Union member

class discordsdk.sdk.IDiscordUserEvents

Bases: _ctypes.Structure

on_current_user_update

Structure/Union member

class discordsdk.sdk.IDiscordUserManager

Bases: _ctypes.Structure

current_user_has_flag

Structure/Union member

get_current_user

Structure/Union member

get_current_user_premium_type

Structure/Union member

get_user

Structure/Union member

class discordsdk.sdk.IDiscordVoiceEvents

Bases: _ctypes.Structure

on_settings_update

Structure/Union member

class discordsdk.sdk.IDiscordVoiceManager

Bases: _ctypes.Structure

get_input_mode

Structure/Union member

get_local_volume

Structure/Union member

is_local_mute

Structure/Union member

is_self_deaf

Structure/Union member

is_self_mute

Structure/Union member

set_input_mode

Structure/Union member

set_local_mute

Structure/Union member

set_local_volume

Structure/Union member

set_self_deaf

Structure/Union member

set_self_mute

Structure/Union member

discordsdk.storage module

class discordsdk.storage.StorageManager

Bases: object

count() int

Returns the count of files, for iteration.

delete(name: str) None

Deletes written data for the given key name.

exists(name: str) bool

Checks if data exists for a given key name.

get_path() str

Returns the filepath to which Discord saves files if you were to use the SDK’s storage manager.

read(name: str) bytes

Reads data synchronously from the game’s allocated save file.

read_async(name: str, callback: Callable[[discordsdk.enum.Result, Optional[bytes]], None]) None

Reads data asynchronously from the game’s allocated save file.

Returns discordsdk.enum.Result (int) and data (bytes) via callback.

read_async_partial(name: str, offset: int, length: int, callback: Callable[[discordsdk.enum.Result], None]) None

Reads data asynchronously from the game’s allocated save file, starting at a given offset and up to a given length.

stat(name: str) discordsdk.model.FileStat

Returns file info for the given key name.

stat_at(index: int) discordsdk.model.FileStat

Returns file info for the given index when iterating over files.

write(name: str, data: bytes) None

Writes data synchronously to disk, under the given key name.

write_async(name: str, data: bytes, callback: Callable[[discordsdk.enum.Result], None]) None

Writes data asynchronously to disk under the given keyname.

discordsdk.store module

class discordsdk.store.StoreManager

Bases: object

count_entitlements() int

Get the number of entitlements readied by FetchEntitlements().

count_skus() int

Get the number of SKUs readied by FetchSkus().

fetch_entitlements(callback: Callable[[discordsdk.enum.Result], None]) None

Fetches a list of entitlements to which the user is entitled.

Returns discordsdk.enum.Result (int) via callback.

fetch_skus(callback: Callable[[discordsdk.enum.Result], None]) None

Fetches the list of SKUs for the connected application, readying them for iteration.

Returns discordsdk.enum.Result (int) via callback.

get_entitlement(entitlement_id: int) discordsdk.model.Entitlement

Gets an entitlement by its id.

get_entitlement_at(index: int) discordsdk.model.Entitlement

Gets an entitlement by index when iterating over a user’s entitlements.

get_sku(sku_id: int) discordsdk.model.Sku

Gets a SKU by its ID.

get_sku_at(index: int) discordsdk.model.Sku

Gets a SKU by index when iterating over SKUs.

has_sku_entitlement(sku_id: int) bool

Returns whether or not the user is entitled to the given SKU ID.

on_entitlement_create(entitlement: discordsdk.model.Entitlement) None

Fires when the connected user receives a new entitlement, either through purchase or through a developer grant.

on_entitlement_delete(entitlement: discordsdk.model.Entitlement) None

Fires when the connected user loses an entitlement, either by expiration, revocation, or consumption in the case of consumable entitlements.

start_purchase(sku_id: int, callback: Callable[[discordsdk.enum.Result], None]) None

Opens the overlay to begin the in-app purchase dialogue for the given SKU ID.

Returns discordsdk.enum.Result (int) via callback.

discordsdk.user module

class discordsdk.user.UserManager

Bases: object

current_user_has_flag(flag: discordsdk.enum.UserFlag) bool

See whether or not the current user has a certain UserFlag on their account.

get_current_user() discordsdk.model.User

Fetch information about the currently connected user account.

get_current_user_premium_type() discordsdk.enum.PremiumType

Get the PremiumType for the currently connected user.

get_user(user_id: int, callback: Callable[[discordsdk.enum.Result], None]) None

Get user information for a given id.

Returns discordsdk.enum.Result (int) and User via callback.

on_current_user_update() None

Fires when the User struct of the currently connected user changes.

discordsdk.voice module

class discordsdk.voice.VoiceManager

Bases: object

get_input_mode() discordsdk.model.InputMode

Get the current voice input mode for the user

get_local_volume(user_id: int) int

Gets the local volume for a given user.

is_local_mute(user_id: int) bool

Whether the given user is currently muted by the connected user.

is_self_deaf() bool

Whether the connected user is currently deafened.

is_self_mute() bool

Whether the connected user is currently muted.

on_settings_update() None
set_input_mode(inputMode: discordsdk.model.InputMode, callback: Callable[[discordsdk.enum.Result], None]) None

Sets a new voice input mode for the uesr.

Returns discordsdk.enum.Result (int) via callback.

set_local_mute(user_id: int, mute: bool) None

Mutes or unmutes the given user for the currently connected user.

set_local_volume(user_id: int, volume: int) None

Sets the local volume for a given user.

set_self_deaf(deaf: bool) None

Deafens or undefeans the currently connected user.

set_self_mute(mute: bool) None

Mutes or unmutes the currently connected user.

Module contents

class discordsdk.AchievementManager

Bases: object

count_user_achievements() int

Counts the list of a user’s achievements for iteration.

fetch_user_achievements(callback: Callable[[discordsdk.enum.Result], None]) None

Loads a stable list of the current user’s achievements to iterate over.

Returns discordsdk.enum.Result via callback.

get_user_achievement(achievement_id: int) None

Gets the user achievement for the given achievement id.

get_user_achievement_at(index: int) discordsdk.model.UserAchievement

Gets the user’s achievement at a given index of their list of achievements.

on_user_achievement_update(achievement: discordsdk.model.UserAchievement) None

Fires when an achievement is updated for the currently connected user

set_user_achievement(achievement_id: int, percent_complete: int, callback: Callable[[discordsdk.enum.Result], None]) None

Updates the current user’s status for a given achievement.

Returns discordsdk.enum.Result via callback.

class discordsdk.Activity(**kwargs)

Bases: discordsdk.model.Model

application_id: int
assets: discordsdk.model.ActivityAssets
details: str
instance: bool
name: str
party: discordsdk.model.ActivityParty
secrets: discordsdk.model.ActivitySecrets
state: str
timestamps: discordsdk.model.ActivityTimestamps
class discordsdk.ActivityActionType(value)

Bases: enum.IntEnum

An enumeration.

join = 1
spectate = 2
class discordsdk.ActivityAssets(**kwargs)

Bases: discordsdk.model.Model

large_image: str
large_text: str
small_image: str
small_text: str
class discordsdk.ActivityJoinRequestReply(value)

Bases: enum.IntEnum

An enumeration.

ignore = 2
no = 0
yes = 1
class discordsdk.ActivityManager

Bases: object

accept_invite(user_id: int, callback: Callable[[discordsdk.enum.Result], None]) None

Accepts a game invitation from a given userId.

Returns discordsdk.enum.Result (int) via callback.

clear_activity(callback: Callable[[discordsdk.enum.Result], None]) None

Clears a user’s presence in Discord to make it show nothing.

Returns discordsdk.enum.Result (int) via callback.

on_activity_invite(type: discordsdk.enum.ActivityActionType, user: discordsdk.model.User, activity: discordsdk.model.Activity) None

Fires when the user receives a join or spectate invite.

on_activity_join(join_secret: str) None

Fires when a user accepts a game chat invite or receives confirmation from Asking to Join.

on_activity_join_request(user: discordsdk.model.User) None

Fires when a user asks to join the current user’s game.

on_activity_spectate(spectate_secret: str) None

Fires when a user accepts a spectate chat invite or clicks the Spectate button on a user’s profile.

register_command(command: str) discordsdk.enum.Result

Registers a command by which Discord can launch your game.

register_steam(steam_id: int) discordsdk.enum.Result

Registers your game’s Steam app id for the protocol steam://run-game-id/<id>.

send_invite(user_id: int, type: discordsdk.enum.ActivityActionType, content: str, callback: Callable[[discordsdk.enum.Result], None]) None

Sends a game invite to a given user.

Returns discordsdk.enum.Result (int) via callback.

send_request_reply(user_id: int, reply: discordsdk.enum.ActivityJoinRequestReply, callback: Callable[[discordsdk.enum.Result], None]) None

Sends a reply to an Ask to Join request.

Returns discordsdk.enum.Result (int) via callback.

update_activity(activity: discordsdk.model.Activity, callback: Callable[[discordsdk.enum.Result], None]) None

Set a user’s presence in Discord to a new activity.

Returns discordsdk.enum.Result (int) via callback.

class discordsdk.ActivityParty(**kwargs)

Bases: discordsdk.model.Model

id: str
size: discordsdk.model.PartySize
class discordsdk.ActivitySecrets(**kwargs)

Bases: discordsdk.model.Model

join: str
match: str
spectate: str
class discordsdk.ActivityTimestamps(**kwargs)

Bases: discordsdk.model.Model

end: int
start: int
class discordsdk.ActivityType(value)

Bases: enum.IntEnum

An enumeration.

custom = 4
listening = 2
playing = 0
streaming = 1
class discordsdk.ApplicationManager

Bases: object

get_current_branch() str

Get the name of pushed branch on which the game is running.

get_current_locale() str

Get the locale the current user has Discord set to.

get_oauth2_token(callback: Callable[[discordsdk.enum.Result, Optional[discordsdk.model.OAuth2Token]], None]) None

Retrieve an oauth2 bearer token for the current user.

Returns discordsdk.enum.Result (int) and OAuth2Token (str) via callback.

get_ticket(callback: Callable[[discordsdk.enum.Result, Optional[str]], None]) None

Get the signed app ticket for the current user.

Returns discordsdk.Enum.Result (int) and str via callback.

validate_or_exit(callback: Callable[[discordsdk.enum.Result], None]) None

Checks if the current user has the entitlement to run this game.

Returns discordsdk.enum.Result (int) via callback.

class discordsdk.CreateFlags(value)

Bases: enum.IntFlag

An enumeration.

default = 0
no_require_discord = 1
class discordsdk.Discord(client_id: int, flags: discordsdk.enum.CreateFlags)

Bases: object

core: discordsdk.sdk.IDiscordCore = None
get_achievement_manager() discordsdk.achievement.AchievementManager

Fetches an instance of the manager for interfacing with achievements in the SDK.

get_activity_manager() discordsdk.activity.ActivityManager

Fetches an instance of the manager for interfacing with activies in the SDK.

get_application_manager() discordsdk.application.ApplicationManager

Fetches an instance of the manager for interfacing with applications in the SDK.

get_image_manager() discordsdk.image.ImageManager

Fetches an instance of the manager for interfacing with images in the SDK.

get_lobby_manager() discordsdk.lobby.LobbyManager

Fetches an instance of the manager for interfacing with lobbies in the SDK.

get_network_manager() discordsdk.network.NetworkManager

Fetches an instance of the manager for interfacing with networking in the SDK.

get_overlay_manager() discordsdk.overlay.OverlayManager

Fetches an instance of the manager for interfacing with the overlay in the SDK.

get_relationship_manager() discordsdk.relationship.RelationshipManager

Fetches an instance of the manager for interfacing with relationships in the SDK.

get_storage_manager() discordsdk.storage.StorageManager

Fetches an instance of the manager for interfacing with storage in the SDK.

get_store_manager() discordsdk.store.StoreManager

Fetches an instance of the manager for interfacing with SKUs and Entitlements in the SDK.

get_user_manager() discordsdk.user.UserManager

Fetches an instance of the manager for interfacing with users in the SDK.

get_voice_manager() discordsdk.voice.VoiceManager

Fetches an instance of the manager for interfacing with voice chat in the SDK.

run_callbacks() None

Runs all pending SDK callbacks.

set_log_hook(min_level: discordsdk.enum.LogLevel, hook: Callable[[discordsdk.enum.LogLevel, str], None]) None

Registers a logging callback function with the minimum level of message to receive.

exception discordsdk.DiscordException

Bases: Exception

class discordsdk.Entitlement(**kwargs)

Bases: discordsdk.model.Model

id: int
sku_id: int
type: discordsdk.enum.EntitlementType
class discordsdk.EntitlementType(value)

Bases: enum.IntEnum

An enumeration.

DeveloperGift = 3
FreePurchase = 5
PremiumPurchase = 7
PremiumSubscription = 2
Purchase = 1
TestModePurchase = 4
UserGift = 6
class discordsdk.FileStat(**kwargs)

Bases: discordsdk.model.Model

filename: str
last_modified: int
size: int
class discordsdk.ImageDimensions(**kwargs)

Bases: discordsdk.model.Model

height: int
width: int
class discordsdk.ImageHandle(**kwargs)

Bases: discordsdk.model.Model

id: int
size: int
type: discordsdk.enum.ImageType
class discordsdk.ImageManager

Bases: object

fetch(handle: discordsdk.model.ImageHandle, refresh: bool, callback: Callable[[discordsdk.enum.Result, Optional[discordsdk.model.ImageHandle]], None]) None

Prepares an image to later retrieve data about it.

Returns discordsdk.enum.Result (int) and ImageHandle via callback.

get_data(handle: discordsdk.model.ImageHandle) bytes

Gets the image data for a given user’s avatar.

get_dimensions(handle: discordsdk.model.ImageHandle) discordsdk.model.ImageDimensions

Gets the dimension for the given user’s avatar’s source image

class discordsdk.ImageType(value)

Bases: enum.IntEnum

An enumeration.

user = 0
class discordsdk.InputMode(**kwargs)

Bases: discordsdk.model.Model

shortcut: str
type: discordsdk.enum.InputModeType
class discordsdk.InputModeType(value)

Bases: enum.IntEnum

An enumeration.

PushToTalk = 1
VoiceActivity = 0
class discordsdk.Lobby(**kwargs)

Bases: discordsdk.model.Model

capacity: int
id: int
locked: bool
owner_id: int
secret: str
type: discordsdk.enum.LobbyType
class discordsdk.LobbyManager

Bases: object

connect_lobby(lobby_id: int, lobby_secret: str, callback: Callable[[discordsdk.enum.Result], None]) None

Connects the current user to a given lobby.

connect_lobby_with_activity_secret(activity_secret: str, callback: Callable[[discordsdk.enum.Result, Optional[discordsdk.model.Lobby]], None]) None

Connects the current user to a lobby; requires the special activity secret from the lobby which is a concatenated lobby_id and secret.

connect_network(lobby_id: int) None

Connects to the networking layer for the given lobby ID.

connect_voice(lobby_id: int, callback: Callable[[discordsdk.enum.Result], None]) None

Connects to the voice channel of the current lobby.

Returns discordsdk.enum.Result (int) via callback.

create_lobby(transaction: discordsdk.lobby.LobbyTransaction, callback: Callable[[discordsdk.enum.Result, Optional[discordsdk.model.Lobby]], None]) None

Creates a lobby.

Returns discordsdk.enum.Result (int) and Lobby via callback.

delete_lobby(lobby_id: int, callback: Callable[[discordsdk.enum.Result], None]) None

Deletes a given lobby.

disconnect_lobby(lobby_id: int, callback: Callable[[discordsdk.enum.Result], None]) None

Disconnects the current user from a lobby.

Returns discordsdk.enum.Result (int) via callback.

disconnect_network(lobby_id: int) None

Disconnects from the networking layer for the given lobby ID.

disconnect_voice(lobby_id: int, callback: Callable[[discordsdk.enum.Result], None]) None

Disconnects from the voice channel of a given lobby.

Returns discordsdk.enum.Result (int) via callback.

flush_network() None

Flushes the network. Call this when you’re done sending messages.

get_lobby(lobby_id: int) discordsdk.model.Lobby

Gets the lobby object for a given lobby id.

get_lobby_activity_secret(lobby_id: int) str

Gets the special activity secret for a given lobby.

get_lobby_create_transaction() discordsdk.lobby.LobbyTransaction

Gets a Lobby transaction used for creating a new lobby

get_lobby_id(index: int) int

Returns the id for the lobby at the given index.

get_lobby_metadata_key(lobby_id: int, index: int) str

Returns the key for the lobby metadata at the given index.

get_lobby_metadata_value(lobby_id: int, key: str) str

Returns lobby metadata value for a given key and id.

get_lobby_update_transaction(lobby_id: int) discordsdk.lobby.LobbyTransaction

Gets a lobby transaction used for updating an existing lobby.

get_member_metadata_key(lobby_id: int, user_id: int, index: int) str

Gets the key for the lobby metadata at the given index on a lobby member.

get_member_metadata_value(lobby_id: int, user_id: int, key: str) str

Returns user metadata for a given key.

get_member_update_transaction(lobby_id: int, user_id: int) discordsdk.lobby.LobbyMemberTransaction

Gets a new member transaction for a lobby member in a given lobby.

get_member_user(lobby_id: int, user_id: int) discordsdk.model.User

Gets the user object for a given user id.

get_member_user_id(lobby_id: int, index: int) int

Gets the user id of the lobby member at the given index.

get_search_query() discordsdk.lobby.LobbySearchQuery

Creates a search object to search available lobbies.

lobby_count() int

Get the number of lobbies that match the search.

lobby_metadata_count(lobby_id: int) int

Returns the number of metadata key/value pairs on a given lobby.

member_count(lobby_id: int) int

Get the number of members in a lobby.

member_metadata_count(lobby_id: int, user_id: int) int

Gets the number of metadata key/value pairs for the given lobby member.

on_lobby_delete(lobby_id: int, reason: str) None

Fired when a lobby is deleted.

on_lobby_message(lobby_id: int, user_id: int, message: str) None

Fires when a message is sent to the lobby.

on_lobby_update(lobby_id: int) None

Fires when a lobby is updated.

on_member_connect(lobby_id: int, user_id: int) None

Fires when a new member joins the lobby.

on_member_disconnect(lobby_id: int, user_id: int) None

Fires when a member leaves the lobby.

on_member_update(lobby_id: int, user_id: int) None

Fires when data for a lobby member is updated.

on_network_message(lobby_id: int, user_id: int, channel_id: int, data: bytes) None

Fires when the user receives a message from the lobby’s networking layer.

on_speaking(lobby_id: int, user_id: int, speaking: bool) None

Fires when a user connected to voice starts or stops speaking.

open_network_channel(lobby_id: int, channel_id: int, reliable: bool) None

Opens a network channel to all users in a lobby on the given channel number. No need to iterate over everyone!

search(search: discordsdk.lobby.LobbySearchQuery, callback: Callable[[discordsdk.enum.Result], None]) None

Searches available lobbies based on the search criteria chosen in the LobbySearchQuery member functions.

Lobbies that meet the criteria are then globally filtered, and can be accessed via iteration with lobby_count() and get_lobby_id(). The callback fires when the list of lobbies is stable and ready for iteration.

Returns discordsdk.enum.Result (int) via callback.

send_lobby_message(lobby_id: int, data: str, callback: Callable[[discordsdk.enum.Result], None]) None

Sends a message to the lobby on behalf of the current user.

Returns discordsdk.Result (int) via callback.

send_network_message(lobby_id: int, user_id: int, channel_id: int, data: bytes) None

Sends a network message to the given user ID that is a member of the given lobby ID over the given channel ID.

update_lobby(lobby_id: int, transaction: discordsdk.lobby.LobbyTransaction, callback: Callable[[discordsdk.enum.Result], None]) None

Updates a lobby with data from the given transaction.

update_member(lobby_id: int, user_id: int, transaction: discordsdk.lobby.LobbyMemberTransaction, callback: Callable[[discordsdk.enum.Result], None]) None

Updates lobby member info for a given member of the lobby.

Returns discordsdk.enum.Result (int) via callback.

class discordsdk.LobbyMemberTransaction(internal: discordsdk.sdk.IDiscordLobbyMemberTransaction)

Bases: object

delete_metadata(key: str) None

Sets metadata value under a given key name for the current user.

set_metadata(key: str, value: str) None

Sets metadata value under a given key name for the current user.

class discordsdk.LobbySearchCast(value)

Bases: enum.IntEnum

An enumeration.

Number = 2
String = 1
class discordsdk.LobbySearchComparison(value)

Bases: enum.IntEnum

An enumeration.

Equal = 0
GreaterThan = 1
GreaterThanOrEqual = 2
LessThan = -1
LessThanOrEqual = -2
NotEqual = 3
class discordsdk.LobbySearchDistance(value)

Bases: enum.IntEnum

An enumeration.

Default = 1
Extended = 2
Global = 3
Local = 0
class discordsdk.LobbySearchQuery(internal: discordsdk.sdk.IDiscordLobbySearchQuery)

Bases: object

distance(distance: discordsdk.enum.LobbySearchDistance) None

Filters lobby results to within certain regions relative to the user’s location.

filter(key: str, comp: discordsdk.enum.LobbySearchComparison, cast: discordsdk.enum.LobbySearchCast, value: str) None

Filters lobbies based on metadata comparison.

limit(limit: int) None

Limits the number of lobbies returned in a search.

sort(key: str, cast: discordsdk.enum.LobbySearchCast, value: str) None

Sorts the filtered lobbies based on “near-ness” to a given value.

class discordsdk.LobbyTransaction(internal: discordsdk.sdk.IDiscordLobbyTransaction)

Bases: object

delete_metadata(key: str) None

Deletes the lobby metadata for a key.

set_capacity(capacity: int) None

Sets a new capacity for the lobby.

set_locked(locked: bool) None

Sets the lobby to locked or unlocked.

set_metadata(key: str, value: str) None

Sets metadata value under a given key name for the lobby.

set_owner(user_id: int) None

Sets a new owner for the lobby.

set_type(type: discordsdk.enum.LobbyType) None

Marks a lobby as private or public.

class discordsdk.LobbyType(value)

Bases: enum.IntEnum

An enumeration.

private = 1
public = 2
class discordsdk.LogLevel(value)

Bases: enum.IntEnum

An enumeration.

debug = 3
error = 0
info = 2
warning = 1
class discordsdk.Model(**kwargs)

Bases: object

class discordsdk.NetworkManager

Bases: object

close_channel(peer_id: int, channel_id: int) None

Close the connection to a given user by peer_id on the given channel.

close_peer(peer_id: int) None

Disconnects the network session to another Discord user.

flush() None

Flushes the network.

get_peer_id() int

Get the networking peer_id for the current user, allowing other users to send packets to them.

on_message(peer_id: int, channel_id: int, data: bytes) None

Fires when you receive data from another user.

on_route_update(route: str) None

Fires when your networking route has changed.

open_channel(peer_id: int, channel_id: int, reliable: bool) None

Opens a channel to a user with their given peer_id on the given channel number.

open_peer(peer_id: int, route: str) None

Opens a network connection to another Discord user.

send_message(peer_id: int, channel_id: int, data: bytes) None

Sends data to a given peer_id through the given channel.

update_peer(peer_id: int, route: str) None

Updates the network connection to another Discord user.

class discordsdk.OAuth2Token(**kwargs)

Bases: discordsdk.model.Model

access_token: str
expires: str
scopes: str
class discordsdk.OverlayManager

Bases: object

is_enabled() bool

Check whether the user has the overlay enabled or disabled.

is_locked() bool

Check if the overlay is currently locked or unlocked

on_toggle(locked: bool) None

Fires when the overlay is locked or unlocked (a.k.a. opened or closed)

open_activity_invite(type: discordsdk.enum.ActivityActionType, callback: Callable[[discordsdk.enum.Result], None]) None

Opens the overlay modal for sending game invitations to users, channels, and servers.

open_guild_invite(code: str, callback: Callable[[discordsdk.enum.Result], None]) None

Opens the overlay modal for joining a Discord guild, given its invite code.

open_voice_settings(callback: Callable[[discordsdk.enum.Result], None]) None

Opens the overlay widget for voice settings for the currently connected application.

set_locked(locked: bool, callback: Callable[[discordsdk.enum.Result], None]) None

Locks or unlocks input in the overlay.

class discordsdk.PartySize(**kwargs)

Bases: discordsdk.model.Model

current_size: int
max_size: int
class discordsdk.PremiumType(value)

Bases: enum.IntEnum

An enumeration.

none_ = 0
tier_1 = 1
tier_2 = 2
class discordsdk.Presence(**kwargs)

Bases: discordsdk.model.Model

activity: discordsdk.model.Activity
status: discordsdk.enum.Status
class discordsdk.Relationship(**kwargs)

Bases: discordsdk.model.Model

presence: discordsdk.model.Presence
type: discordsdk.enum.RelationshipType
user: discordsdk.model.User
class discordsdk.RelationshipManager

Bases: object

count() int

Get the number of relationships that match your filter.

filter(filter: Callable[[discordsdk.model.Relationship], None]) None

Filters a user’s relationship list by a boolean condition.

get(user_id: int) discordsdk.model.Relationship

Get the relationship between the current user and a given user by id.

get_at(index: int) discordsdk.model.Relationship

Get the relationship at a given index when iterating over a list of relationships.

on_refresh() None

Fires at initialization when Discord has cached a snapshot of the current status of all your relationships.

on_relationship_update(relationship: discordsdk.model.Relationship) None

Fires when a relationship in the filtered list changes, like an updated presence or user attribute.

class discordsdk.RelationshipType(value)

Bases: enum.IntEnum

An enumeration.

blocked = 2
friend = 1
implicit = 5
none_ = 0
pending_incoming = 3
pending_outgoing = 4
class discordsdk.Result(value)

Bases: enum.IntEnum

An enumeration.

application_mismatch = 17
capture_shortcut_already_listening = 39
conflict = 10
drawing_init_failed = 44
get_guild_timeout = 37
insufficient_buffer = 28
internal_error = 4
invalid_access_token = 16
invalid_base_64 = 19
invalid_channel = 32
invalid_command = 6
invalid_data_url = 18
invalid_entitlement = 25
invalid_event = 31
invalid_file_size = 24
invalid_filename = 23
invalid_gift_code = 41
invalid_guild = 30
invalid_invite = 14
invalid_join_secret = 12
invalid_lobby_secret = 22
invalid_origin = 33
invalid_payload = 5
invalid_permissions = 7
invalid_secret = 11
invalid_version = 2
lobby_full = 21
lock_failed = 3
no_eligible_activity = 13
not_authenticated = 15
not_fetched = 8
not_filtered = 20
not_found = 9
not_installed = 26
not_running = 27
oauth2_error = 35
ok = 0
purchase_canceled = 29
purchase_error = 42
rate_limited = 34
select_channel_timeout = 36
select_voice_force_required = 38
service_unavailable = 1
transaction_aborted = 43
unauthorized_for_achievement = 40
class discordsdk.Sku(**kwargs)

Bases: discordsdk.model.Model

id: int
name: str
price: discordsdk.model.SkuPrice
type: discordsdk.enum.SkuType
class discordsdk.SkuPrice(**kwargs)

Bases: discordsdk.model.Model

amount: int
currency: str
class discordsdk.SkuType(value)

Bases: enum.IntEnum

An enumeration.

Application = 1
Bundle = 4
Consumable = 3
DLC = 2
class discordsdk.Status(value)

Bases: enum.IntEnum

An enumeration.

do_not_disturb = 3
idle = 2
offline = 0
online = 1
class discordsdk.StorageManager

Bases: object

count() int

Returns the count of files, for iteration.

delete(name: str) None

Deletes written data for the given key name.

exists(name: str) bool

Checks if data exists for a given key name.

get_path() str

Returns the filepath to which Discord saves files if you were to use the SDK’s storage manager.

read(name: str) bytes

Reads data synchronously from the game’s allocated save file.

read_async(name: str, callback: Callable[[discordsdk.enum.Result, Optional[bytes]], None]) None

Reads data asynchronously from the game’s allocated save file.

Returns discordsdk.enum.Result (int) and data (bytes) via callback.

read_async_partial(name: str, offset: int, length: int, callback: Callable[[discordsdk.enum.Result], None]) None

Reads data asynchronously from the game’s allocated save file, starting at a given offset and up to a given length.

stat(name: str) discordsdk.model.FileStat

Returns file info for the given key name.

stat_at(index: int) discordsdk.model.FileStat

Returns file info for the given index when iterating over files.

write(name: str, data: bytes) None

Writes data synchronously to disk, under the given key name.

write_async(name: str, data: bytes, callback: Callable[[discordsdk.enum.Result], None]) None

Writes data asynchronously to disk under the given keyname.

class discordsdk.StoreManager

Bases: object

count_entitlements() int

Get the number of entitlements readied by FetchEntitlements().

count_skus() int

Get the number of SKUs readied by FetchSkus().

fetch_entitlements(callback: Callable[[discordsdk.enum.Result], None]) None

Fetches a list of entitlements to which the user is entitled.

Returns discordsdk.enum.Result (int) via callback.

fetch_skus(callback: Callable[[discordsdk.enum.Result], None]) None

Fetches the list of SKUs for the connected application, readying them for iteration.

Returns discordsdk.enum.Result (int) via callback.

get_entitlement(entitlement_id: int) discordsdk.model.Entitlement

Gets an entitlement by its id.

get_entitlement_at(index: int) discordsdk.model.Entitlement

Gets an entitlement by index when iterating over a user’s entitlements.

get_sku(sku_id: int) discordsdk.model.Sku

Gets a SKU by its ID.

get_sku_at(index: int) discordsdk.model.Sku

Gets a SKU by index when iterating over SKUs.

has_sku_entitlement(sku_id: int) bool

Returns whether or not the user is entitled to the given SKU ID.

on_entitlement_create(entitlement: discordsdk.model.Entitlement) None

Fires when the connected user receives a new entitlement, either through purchase or through a developer grant.

on_entitlement_delete(entitlement: discordsdk.model.Entitlement) None

Fires when the connected user loses an entitlement, either by expiration, revocation, or consumption in the case of consumable entitlements.

start_purchase(sku_id: int, callback: Callable[[discordsdk.enum.Result], None]) None

Opens the overlay to begin the in-app purchase dialogue for the given SKU ID.

Returns discordsdk.enum.Result (int) via callback.

class discordsdk.User(**kwargs)

Bases: discordsdk.model.Model

avatar: str
bot: str
discriminator: str
id: int
username: str
class discordsdk.UserAchievement(**kwargs)

Bases: discordsdk.model.Model

achievement_id: int
percent_complete: int
unlocked_at: str
user_id: str
class discordsdk.UserFlag(value)

Bases: enum.IntFlag

An enumeration.

hype_squad_events = 4
hype_squad_house_1 = 64
hype_squad_house_2 = 128
hype_squad_house_3 = 256
partner = 2
class discordsdk.UserManager

Bases: object

current_user_has_flag(flag: discordsdk.enum.UserFlag) bool

See whether or not the current user has a certain UserFlag on their account.

get_current_user() discordsdk.model.User

Fetch information about the currently connected user account.

get_current_user_premium_type() discordsdk.enum.PremiumType

Get the PremiumType for the currently connected user.

get_user(user_id: int, callback: Callable[[discordsdk.enum.Result], None]) None

Get user information for a given id.

Returns discordsdk.enum.Result (int) and User via callback.

on_current_user_update() None

Fires when the User struct of the currently connected user changes.

class discordsdk.VoiceManager

Bases: object

get_input_mode() discordsdk.model.InputMode

Get the current voice input mode for the user

get_local_volume(user_id: int) int

Gets the local volume for a given user.

is_local_mute(user_id: int) bool

Whether the given user is currently muted by the connected user.

is_self_deaf() bool

Whether the connected user is currently deafened.

is_self_mute() bool

Whether the connected user is currently muted.

on_settings_update() None
set_input_mode(inputMode: discordsdk.model.InputMode, callback: Callable[[discordsdk.enum.Result], None]) None

Sets a new voice input mode for the uesr.

Returns discordsdk.enum.Result (int) via callback.

set_local_mute(user_id: int, mute: bool) None

Mutes or unmutes the given user for the currently connected user.

set_local_volume(user_id: int, volume: int) None

Sets the local volume for a given user.

set_self_deaf(deaf: bool) None

Deafens or undefeans the currently connected user.

set_self_mute(mute: bool) None

Mutes or unmutes the currently connected user.

discordsdk.bind_events(structure: _ctypes.Structure, *methods: List[Callable[[...], None]])
discordsdk.get_exception(result)