Soundboard

This section documents everything related to Discord soundboards.

Discord Models

PartialSoundboardSound

Attributes
Methods
class disnake.PartialSoundboardSound[source]

Represents a partial soundboard sound.

Used for sounds in VoiceChannelEffects, and as the base for full SoundboardSound/GuildSoundboardSound objects.

New in version 2.10.

x == y

Checks if two soundboard sounds are equal.

x != y

Checks if two soundboard sounds are not equal.

hash(x)

Returns the soundboard sounds’ hash.

id

The sound’s ID.

Type:

int

volume

The sound’s volume (from 0.0 to 1.0).

Type:

float

property created_at[source]

Returns the sound’s creation time in UTC. Can be None if this is a default sound.

Type:

Optional[datetime.datetime]

property url[source]

The url for the sound file.

Type:

str

is_default()[source]

Whether the sound is a default sound provided by Discord.

Return type:

bool

await read()[source]

This function is a coroutine.

Retrieves the content of this asset as a bytes object.

Raises:
Returns:

The content of the asset.

Return type:

bytes

await save(fp, *, seek_begin=True)[source]

This function is a coroutine.

Saves this asset into a file-like object.

Parameters:
  • fp (Union[io.BufferedIOBase, os.PathLike]) – The file-like object to save this asset to or the filename to use. If a filename is passed then a file is created with that filename and used instead.

  • seek_begin (bool) – Whether to seek to the beginning of the file after saving is successfully done.

Raises:
Returns:

The number of bytes written.

Return type:

int

await to_file(*, spoiler=False, filename=None, description=None)[source]

This function is a coroutine.

Converts the asset into a File suitable for sending via abc.Messageable.send().

New in version 2.5.

Changed in version 2.6: Raises TypeError instead of InvalidArgument.

Parameters:
  • spoiler (bool) – Whether the file is a spoiler.

  • filename (Optional[str]) – The filename to display when uploading to Discord. If this is not given, it defaults to the name of the asset’s URL.

  • description (Optional[str]) – The file’s description.

Raises:
Returns:

The asset as a file suitable for sending.

Return type:

File

SoundboardSound

Methods
class disnake.SoundboardSound[source]

Represents a soundboard sound.

New in version 2.10.

x == y

Checks if two soundboard sounds are equal.

x != y

Checks if two soundboard sounds are not equal.

hash(x)

Returns the soundboard sounds’ hash.

id

The sound’s ID.

Type:

int

volume

The sound’s volume (from 0.0 to 1.0).

Type:

float

name

The sound’s name.

Type:

str

emoji

The sound’s emoji, if any. Due to a Discord limitation, this will have an empty name if it is a custom PartialEmoji.

Type:

Optional[Union[Emoji, PartialEmoji]]

available

Whether this sound is available for use.

Type:

bool

property created_at[source]

Returns the sound’s creation time in UTC. Can be None if this is a default sound.

Type:

Optional[datetime.datetime]

is_default()[source]

Whether the sound is a default sound provided by Discord.

Return type:

bool

await read()[source]

This function is a coroutine.

Retrieves the content of this asset as a bytes object.

Raises:
Returns:

The content of the asset.

Return type:

bytes

await save(fp, *, seek_begin=True)[source]

This function is a coroutine.

Saves this asset into a file-like object.

Parameters:
  • fp (Union[io.BufferedIOBase, os.PathLike]) – The file-like object to save this asset to or the filename to use. If a filename is passed then a file is created with that filename and used instead.

  • seek_begin (bool) – Whether to seek to the beginning of the file after saving is successfully done.

Raises:
Returns:

The number of bytes written.

Return type:

int

await to_file(*, spoiler=False, filename=None, description=None)[source]

This function is a coroutine.

Converts the asset into a File suitable for sending via abc.Messageable.send().

New in version 2.5.

Changed in version 2.6: Raises TypeError instead of InvalidArgument.

Parameters:
  • spoiler (bool) – Whether the file is a spoiler.

  • filename (Optional[str]) – The filename to display when uploading to Discord. If this is not given, it defaults to the name of the asset’s URL.

  • description (Optional[str]) – The file’s description.

Raises:
Returns:

The asset as a file suitable for sending.

Return type:

File

property url[source]

The url for the sound file.

Type:

str

GuildSoundboardSound

Methods
class disnake.GuildSoundboardSound[source]

Represents a soundboard sound that belongs to a guild.

New in version 2.10.

x == y

Checks if two soundboard sounds are equal.

x != y

Checks if two soundboard sounds are not equal.

hash(x)

Returns the soundboard sounds’ hash.

id

The sound’s ID.

Type:

int

volume

The sound’s volume (from 0.0 to 1.0).

Type:

float

name

The sound’s name.

Type:

str

emoji

The sound’s emoji, if any. Due to a Discord limitation, this will have an empty name if it is a custom PartialEmoji.

Type:

Optional[Union[Emoji, PartialEmoji]]

guild_id

The ID of the guild this sound belongs to.

Type:

int

available

Whether this sound is available for use.

Type:

bool

user

The user that created this sound. This can only be retrieved using Guild.fetch_soundboard_sound()/Guild.fetch_soundboard_sounds() while having the create_guild_expressions or manage_guild_expressions permission.

Type:

Optional[User]

property guild[source]

The guild that this sound is from.

Type:

Guild

await edit(*, name=..., volume=..., emoji=..., reason=None)[source]

This function is a coroutine.

Edits a GuildSoundboardSound for the guild.

You must have manage_guild_expressions permission to do this. If this sound was created by you, create_guild_expressions permission is also sufficient.

All fields are optional.

Parameters:
  • name (str) – The sounds’s new name. Must be at least 2 characters.

  • volume (float) – The sound’s new volume (from 0.0 to 1.0).

  • emoji (Optional[Union[str, Emoji, PartialEmoji]]) – The sound’s new emoji. Can be None.

  • reason (Optional[str]) – The reason for editing this sound. Shows up on the audit log.

Raises:
  • Forbidden – You are not allowed to edit this soundboard sound.

  • HTTPException – An error occurred editing the soundboard sound.

Returns:

The newly modified soundboard sound.

Return type:

GuildSoundboardSound

await delete(*, reason=None)[source]

This function is a coroutine.

Deletes the GuildSoundboardSound from the guild.

You must have manage_guild_expressions permission to do this. If this sound was created by you, create_guild_expressions permission is also sufficient.

Parameters:

reason (Optional[str]) – The reason for deleting this sound. Shows up on the audit log.

Raises:
  • Forbidden – You are not allowed to delete this soundboard sound.

  • HTTPException – An error occurred deleting the soundboard sound.

property created_at[source]

Returns the sound’s creation time in UTC. Can be None if this is a default sound.

Type:

Optional[datetime.datetime]

is_default()[source]

Whether the sound is a default sound provided by Discord.

Return type:

bool

await read()[source]

This function is a coroutine.

Retrieves the content of this asset as a bytes object.

Raises:
Returns:

The content of the asset.

Return type:

bytes

await save(fp, *, seek_begin=True)[source]

This function is a coroutine.

Saves this asset into a file-like object.

Parameters:
  • fp (Union[io.BufferedIOBase, os.PathLike]) – The file-like object to save this asset to or the filename to use. If a filename is passed then a file is created with that filename and used instead.

  • seek_begin (bool) – Whether to seek to the beginning of the file after saving is successfully done.

Raises:
Returns:

The number of bytes written.

Return type:

int

await to_file(*, spoiler=False, filename=None, description=None)[source]

This function is a coroutine.

Converts the asset into a File suitable for sending via abc.Messageable.send().

New in version 2.5.

Changed in version 2.6: Raises TypeError instead of InvalidArgument.

Parameters:
  • spoiler (bool) – Whether the file is a spoiler.

  • filename (Optional[str]) – The filename to display when uploading to Discord. If this is not given, it defaults to the name of the asset’s URL.

  • description (Optional[str]) – The file’s description.

Raises:
Returns:

The asset as a file suitable for sending.

Return type:

File

property url[source]

The url for the sound file.

Type:

str

Events