Guild Scheduled Events¶
This section documents everything related to Guild Scheduled Events.
Discord Models¶
GuildScheduledEvent¶
- class disnake.GuildScheduledEvent[source]¶
Represents a guild scheduled event.
New in version 2.3.
- x == y
Checks if two guild scheduled events are equal.
- x != y
Checks if two guild scheduled events are not equal.
- hash(x)
Returns the guild scheduled event’s hash.
- channel_id¶
The channel ID in which the guild scheduled event will be hosted. This field is
None
ifentity_type
isGuildScheduledEventEntityType.external
.- Type:
Optional[
int
]
- creator_id¶
The ID of the user that created the guild scheduled event. This field is
None
for events created before October 25th, 2021.- Type:
Optional[
int
]
- creator¶
The user that created the guild scheduled event. This field is
None
for events created before October 25th, 2021.- Type:
Optional[
User
]
- scheduled_start_time¶
The time when the guild scheduled event will start.
- Type:
- scheduled_end_time¶
The time when the guild scheduled event will end, or
None
if the event does not have a scheduled time to end.- Type:
Optional[
datetime.datetime
]
- privacy_level¶
The privacy level of the guild scheduled event.
- status¶
The status of the guild scheduled event.
- entity_type¶
The type of the guild scheduled event.
- entity_metadata¶
Additional metadata for the guild scheduled event.
- user_count¶
The number of users subscribed to the guild scheduled event. If the guild scheduled event was fetched with
with_user_count
set toFalse
, this field isNone
.- Type:
Optional[
int
]
- property created_at[source]¶
Returns the guild scheduled event’s creation time in UTC.
New in version 2.6.
- Type:
- channel¶
The channel in which the guild scheduled event will be hosted.
This will be
None
ifentity_type
isGuildScheduledEventEntityType.external
.- Type:
Optional[
abc.GuildChannel
]
- property image[source]¶
The cover image asset of the guild scheduled event, if available.
- Type:
Optional[
Asset
]
- await delete()[source]¶
This function is a coroutine.
Deletes the guild scheduled event.
You must have
manage_events
permission to do this.- Raises:
Forbidden – You do not have proper permissions to delete the event.
NotFound – The event does not exist.
HTTPException – Deleting the event failed.
- await edit(*, name=..., description=..., image=..., channel=..., privacy_level=..., scheduled_start_time=..., scheduled_end_time=..., entity_type=..., entity_metadata=..., status=..., reason=None)[source]¶
This function is a coroutine.
Edits the guild scheduled event.
You must have
manage_events
permission to do this.Changed in version 2.6: Updates must follow requirements of
Guild.create_scheduled_event()
Changed in version 2.6: Now raises
TypeError
instead ofValueError
for invalid parameter types.Changed in version 2.6: Removed
channel_id
parameter in favor ofchannel
.Changed in version 2.6: Naive datetime parameters are now assumed to be in the local timezone instead of UTC.
- Parameters:
name (
str
) – The name of the guild scheduled event.description (Optional[
str
]) – The description of the guild scheduled event.image (Optional[Union[
bytes
,Asset
,Emoji
,PartialEmoji
,StickerItem
,Sticker
]]) –The cover image of the guild scheduled event. Set to
None
to remove the image.New in version 2.4.
Changed in version 2.5: Now accepts various resource types in addition to
bytes
.channel (Optional[
abc.Snowflake
]) –The channel in which the guild scheduled event will be hosted. Set to
None
if changingentity_type
toGuildScheduledEventEntityType.external
.New in version 2.6.
privacy_level (
GuildScheduledEventPrivacyLevel
) – The privacy level of the guild scheduled event.scheduled_start_time (
datetime.datetime
) – The time to schedule the guild scheduled event. If the datetime is naive, it is assumed to be local time.scheduled_end_time (Optional[
datetime.datetime
]) – The time when the guild scheduled event is scheduled to end. If the datetime is naive, it is assumed to be local time.entity_type (
GuildScheduledEventEntityType
) – The entity type of the guild scheduled event.entity_metadata (Optional[
GuildScheduledEventMetadata
]) – The entity metadata of the guild scheduled event.status (
GuildScheduledEventStatus
) –The status of the guild scheduled event.
reason (Optional[
str
]) – The reason for editing the guild scheduled event. Shows up on the audit log.
- Raises:
Forbidden – You do not have proper permissions to edit the event.
NotFound – The event does not exist or the
image
asset couldn’t be found.HTTPException – Editing the event failed.
TypeError – The
image
asset is a lottie sticker (seeSticker.read()
), one ofentity_type
,privacy_level
,entity_metadata
orstatus
is not of the correct type, or the provided channel’s type is neitherChannelType.voice
norChannelType.stage_voice
.
- Returns:
The newly updated guild scheduled event instance.
- Return type:
- await start(*, reason=None)[source]¶
This function is a coroutine.
Starts the guild scheduled event.
Changes the event status to
active
.You must have
manage_events
permission to do this.New in version 2.7.
- Parameters:
reason (Optional[
str
]) – The reason for starting the guild scheduled event. Shows up on the audit log.- Raises:
ValueError – The event has already started or ended, or was cancelled.
Forbidden – You do not have permissions to start the event.
HTTPException – Starting the event failed.
- Returns:
The started guild scheduled event instance.
- Return type:
- await end(*, reason=None)[source]¶
This function is a coroutine.
Ends the guild scheduled event.
Changes the event status to
completed
.You must have
manage_events
permission to do this.New in version 2.7.
- Parameters:
reason (Optional[
str
]) – The reason for ending the guild scheduled event. Shows up on the audit log.- Raises:
ValueError – The event has not started yet, has already ended, or was cancelled.
Forbidden – You do not have permissions to end the event.
HTTPException – Ending the event failed.
- Returns:
The ended guild scheduled event instance.
- Return type:
- await cancel(*, reason=None)[source]¶
This function is a coroutine.
Cancels the guild scheduled event.
Changes the event status to
cancelled
.You must have
manage_events
permission to do this.New in version 2.7.
- Parameters:
reason (Optional[
str
]) – The reason for cancelling the guild scheduled event. Shows up on the audit log.- Raises:
ValueError – The event has already started or ended, or was already cancelled.
Forbidden – You do not have permissions to cancel the event.
HTTPException – Cancelling the event failed.
- Returns:
The cancelled guild scheduled event instance.
- Return type:
- fetch_users(*, limit=None, with_members=True, before=None, after=None)[source]¶
This function is a coroutine.
Returns an
AsyncIterator
of users subscribed to the guild scheduled event.If
before
is specified, users are returned in reverse order, i.e. starting with the highest ID.Changed in version 2.5: Now returns an
AsyncIterator
instead of a list of the first 100 users.- Parameters:
limit (Optional[
int
]) – The number of users to retrieve.with_members (
bool
) – Whether to include some users as members. Defaults toTrue
.before (Optional[
abc.Snowflake
]) – Retrieve users before this object.after (Optional[
abc.Snowflake
]) – Retrieve users after this object.
- Raises:
Forbidden – You do not have proper permissions to fetch the users.
NotFound – The event does not exist.
HTTPException – Retrieving the users failed.
- Yields:
Union[
User
,Member
] – The member (if retrievable) or user subscribed to the guild scheduled event.
Examples
Usage
async for user in event.fetch_users(limit=500): print(user.name)
Flattening into a list
users = await event.fetch_users(limit=250).flatten()
RawGuildScheduledEventUserActionEvent¶
- class disnake.RawGuildScheduledEventUserActionEvent[source]¶
Represents the event payload for an
on_raw_guild_scheduled_event_subscribe()
andon_raw_guild_scheduled_event_unsubscribe()
events.New in version 2.3.
- event_id¶
The ID of the guild scheduled event that the user subscribed to or unsubscribed from.
- Type:
Data Classes¶
GuildScheduledEventMetadata¶
- class disnake.GuildScheduledEventMetadata(*, location=None)[source]¶
Represents a guild scheduled event entity metadata.
New in version 2.3.
- location¶
The location of the guild scheduled event. If
GuildScheduledEvent.entity_type
isGuildScheduledEventEntityType.external
, this value is notNone
.- Type:
Optional[
str
]
Enumerations¶
GuildScheduledEventEntityType¶
- class disnake.GuildScheduledEventEntityType[source]¶
Represents the type of a guild scheduled event entity.
New in version 2.3.
- stage_instance¶
The guild scheduled event will take place in a stage channel.
- voice¶
The guild scheduled event will take place in a voice channel.
- external¶
The guild scheduled event will take place in a custom location.