Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Stage Instances #1725

Merged
merged 34 commits into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
cb9f9f5
Implement Stage instances
ashwinvin Jul 9, 2021
67996b8
Rebased and improved
null-domain Sep 28, 2023
f5704cc
Fix failing test
null-domain Sep 28, 2023
ddef5a2
Don't cry, towncrier
null-domain Sep 28, 2023
d99b5d5
Add missing attributes to Stage instances
null-domain Oct 2, 2023
f7fd4d5
Don't use spec_set in stageinstance mock app test
null-domain Oct 4, 2023
1a77a6a
Update tests/hikari/events/test_stage_events.py
null-domain Oct 4, 2023
f42191a
Remove deprecated stage instance privacy level
null-domain Oct 4, 2023
f2e78d6
Lowercase *every instance of "stage instance"
null-domain Oct 4, 2023
ff65fb6
Triple quote docstring
null-domain Oct 4, 2023
36ce0b9
Cast guild_scheduled_event_id to snowflake
null-domain Oct 4, 2023
b8ec2c1
Move note about UnauthorizedError to the right place
null-domain Oct 4, 2023
d4f114a
Turns out g_s_e_id is always in the payload, just set as None
null-domain Oct 4, 2023
ef7ed23
Correct info/raised exc about non-existent stage instance
null-domain Oct 4, 2023
7aed3d3
Remove unused imports, black changes
null-domain Oct 4, 2023
3bfaf63
Fix failing tests, remove remaining refs to deprecated attribute
null-domain Oct 4, 2023
e666ed5
guild_scheduled_event_id should be None instead of UNDEFINED
null-domain Oct 4, 2023
594c3a6
Remove unused import
null-domain Oct 4, 2023
cbd64c9
Extract guild_scheduled_event_id to its own variable
davfsa Oct 28, 2023
e2f4b43
Add missing tests
null-domain Nov 2, 2023
6692e38
Merge branch 'master' into feat/stage-instances
null-domain Nov 3, 2023
423302d
Merge branch 'master' into feat/stage-instances
null-domain Nov 15, 2023
a6dd630
Update hikari/internal/routes.py
null-domain Dec 7, 2023
0358720
Update hikari/api/rest.py
null-domain Dec 7, 2023
144f93d
Update hikari/api/rest.py
null-domain Dec 7, 2023
257e387
Merge branch 'master' into feat/stage-instances
null-domain Dec 20, 2023
e1b0cf4
Merge branch 'master' into thommo-stage-instances-patch
tandemdude Aug 2, 2024
8429ded
Address PR comments and fix flake8 errors
tandemdude Aug 2, 2024
5bc6021
Update hikari/stage_instances.py
tandemdude Aug 3, 2024
1d71179
Apply suggestions from code review
tandemdude Aug 3, 2024
6dd22a4
Address final comments, ensure pipelines pass
tandemdude Aug 3, 2024
2cf82d7
Implement StageInstancePrivacyLevel, fix incorrect tests
tandemdude Aug 3, 2024
944d49b
Remove stage_instance_id from events, fix formatting
tandemdude Aug 3, 2024
aa0025b
Fix tests and flake8
tandemdude Aug 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/1725.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Implement stage instances
1 change: 1 addition & 0 deletions hikari/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
from hikari.snowflakes import SnowflakeishOr
from hikari.snowflakes import SnowflakeishSequence
from hikari.snowflakes import Unique
from hikari.stage_instances import *
from hikari.stickers import *
from hikari.templates import *
from hikari.traits import *
Expand Down
1 change: 1 addition & 0 deletions hikari/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ from hikari.snowflakes import Snowflakeish as Snowflakeish
from hikari.snowflakes import SnowflakeishOr as SnowflakeishOr
from hikari.snowflakes import SnowflakeishSequence as SnowflakeishSequence
from hikari.snowflakes import Unique as Unique
from hikari.stage_instances import *
from hikari.stickers import *
from hikari.templates import *
from hikari.traits import *
Expand Down
20 changes: 20 additions & 0 deletions hikari/api/entity_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
from hikari import scheduled_events as scheduled_events_models
from hikari import sessions as gateway_models
from hikari import snowflakes
from hikari import stage_instances
from hikari import stickers as sticker_models
from hikari import templates as template_models
from hikari import users as user_models
Expand Down Expand Up @@ -1967,3 +1968,22 @@ def deserialize_sku(self, payload: data_binding.JSONObject) -> entitlement_model
hikari.monetization.SKU
The deserialized SKU object.
"""

#########################
# STAGE INSTANCE MODELS #
#########################

@abc.abstractmethod
def deserialize_stage_instance(self, payload: data_binding.JSONObject) -> stage_instances.StageInstance:
"""Parse a raw payload from Discord into a guild stage instance object.

Parameters
----------
payload : hikari.internal.data_binding.JSONObject
The JSON payload to deserialize.

Returns
-------
hikari.stage_intances.StageInstance
The deserialized stage instance object
"""
62 changes: 62 additions & 0 deletions hikari/api/event_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
from hikari.events import role_events
from hikari.events import scheduled_events
from hikari.events import shard_events
from hikari.events import stage_events
from hikari.events import typing_events
from hikari.events import user_events
from hikari.events import voice_events
Expand Down Expand Up @@ -1408,3 +1409,64 @@ def deserialize_entitlement_update_event(
hikari.events.entitlement_events.EntitlementUpdateEvent
The parsed entitlement update event object.
"""

#########################
# STAGE INSTANCE EVENTS #
#########################

@abc.abstractmethod
def deserialize_stage_instance_create_event(
self, shard: gateway_shard.GatewayShard, payload: data_binding.JSONObject
) -> stage_events.StageInstanceCreateEvent:
"""Parse a raw payload from Discord into a stage instance create event object.

Parameters
----------
shard
The shard that emitted this event.
payload
The dict payload to parse.

Returns
-------
hikari.events.stage_events.StageInstanceCreateEvent
The parsed stage instance create event object.
"""

@abc.abstractmethod
def deserialize_stage_instance_update_event(
self, shard: gateway_shard.GatewayShard, payload: data_binding.JSONObject
) -> stage_events.StageInstanceUpdateEvent:
"""Parse a raw payload from Discord into a stage instance update event object.

Parameters
----------
shard
The shard that emitted this event.
payload
The dict payload to parse.

Returns
-------
hikari.events.stage_events.StageInstanceUpdateEvent
The parsed stage instance update event object.
"""

@abc.abstractmethod
def deserialize_stage_instance_delete_event(
self, shard: gateway_shard.GatewayShard, payload: data_binding.JSONObject
) -> stage_events.StageInstanceDeleteEvent:
"""Parse a raw payload from Discord into a stage instance delete event object.

Parameters
----------
shard
The shard that emitted this event.
payload
The dict payload to parse.

Returns
-------
hikari.events.stage_events.StageInstanceDeleteEvent
The parsed stage instance delete event object.
"""
170 changes: 170 additions & 0 deletions hikari/api/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
from hikari import permissions as permissions_
from hikari import sessions
from hikari import snowflakes
from hikari import stage_instances
from hikari import stickers as stickers_
from hikari import templates
from hikari import users
Expand Down Expand Up @@ -8206,3 +8207,172 @@ async def delete_test_entitlement(
hikari.errors.InternalServerError
If an internal error occurs on Discord while handling the request.
"""

@abc.abstractmethod
async def fetch_stage_instance(
self, channel: snowflakes.SnowflakeishOr[channels_.GuildStageChannel]
) -> stage_instances.StageInstance:
"""Fetch the stage instance associated with a guild stage channel.

Parameters
----------
channel
The guild stage channel to fetch the stage instance from.

Returns
-------
hikari.stage_instances.StageInstance
The stage instance associated with the guild stage channel.

Raises
------
hikari.errors.UnauthorizedError
If you are unauthorized to make the request (invalid/missing token).
hikari.errors.NotFoundError
If the stage instance or channel is not found.
hikari.errors.RateLimitTooLongError
Raised in the event that a rate limit occurs that is
longer than `max_rate_limit` when making a request.
hikari.errors.RateLimitedError
Usually, Hikari will handle and retry on hitting
rate-limits automatically. This includes most bucket-specific
rate-limits and global rate-limits. In some rare edge cases,
however, Discord implements other undocumented rules for
rate-limiting, such as limits per attribute. These cannot be
detected or handled normally by Hikari due to their undocumented
nature, and will trigger this exception if they occur.
hikari.errors.InternalServerError
If an internal error occurs on Discord while handling the request.
"""

@abc.abstractmethod
async def create_stage_instance(
self,
channel: snowflakes.SnowflakeishOr[channels_.GuildStageChannel],
*,
topic: str,
privacy_level: undefined.UndefinedOr[typing.Union[int, stage_instances.StageInstancePrivacyLevel]],
send_start_notification: undefined.UndefinedOr[bool] = undefined.UNDEFINED,
scheduled_event_id: undefined.UndefinedOr[
snowflakes.SnowflakeishOr[scheduled_events.ScheduledEvent]
] = undefined.UNDEFINED,
) -> stage_instances.StageInstance:
"""Create a stage instance in guild stage channel.

Parameters
----------
channel
The channel to use for the stage instance creation.
topic
The topic for the stage instance.
privacy_level
The privacy level for the stage instance.
send_start_notification
Whether to send a notification to *all* server members that the stage instance has started.
scheduled_event_id
The ID of the scheduled event to associate with the stage instance.


Returns
-------
hikari.stage_instances.StageInstance
The created stage instance.

Raises
------
hikari.errors.UnauthorizedError
If you are unauthorized to make the request (invalid/missing token).
hikari.errors.NotFoundError
If the interaction or response is not found.
hikari.errors.RateLimitTooLongError
Raised in the event that a rate limit occurs that is
longer than `max_rate_limit` when making a request.
hikari.errors.RateLimitedError
Usually, Hikari will handle and retry on hitting
rate-limits automatically. This includes most bucket-specific
rate-limits and global rate-limits. In some rare edge cases,
however, Discord implements other undocumented rules for
rate-limiting, such as limits per attribute. These cannot be
detected or handled normally by Hikari due to their undocumented
nature, and will trigger this exception if they occur.
hikari.errors.InternalServerError
If an internal error occurs on Discord while handling the request.
"""

@abc.abstractmethod
async def edit_stage_instance(
self,
channel: snowflakes.SnowflakeishOr[channels_.GuildStageChannel],
*,
topic: undefined.UndefinedOr[str] = undefined.UNDEFINED,
privacy_level: undefined.UndefinedOr[
typing.Union[int, stage_instances.StageInstancePrivacyLevel]
] = undefined.UNDEFINED,
) -> stage_instances.StageInstance:
"""Edit the stage instance in a guild stage channel.

Parameters
----------
channel
The channel that the stage instance is associated with.
topic
The topic for the stage instance.
privacy_level:
The privacy level for the stage instance.

Returns
-------
hikari.stage_instances.StageInstance
The edited stage instance.

Raises
------
hikari.errors.UnauthorizedError
If you are unauthorized to make the request (invalid/missing token
or you are not a moderator of the stage instance).
hikari.errors.NotFoundError
If the interaction or response is not found.
hikari.errors.RateLimitTooLongError
Raised in the event that a rate limit occurs that is
longer than `max_rate_limit` when making a request.
hikari.errors.RateLimitedError
Usually, Hikari will handle and retry on hitting
rate-limits automatically. This includes most bucket-specific
rate-limits and global rate-limits. In some rare edge cases,
however, Discord implements other undocumented rules for
rate-limiting, such as limits per attribute. These cannot be
detected or handled normally by Hikari due to their undocumented
nature, and will trigger this exception if they occur.
hikari.errors.InternalServerError
If an internal error occurs on Discord while handling the request.
"""

@abc.abstractmethod
async def delete_stage_instance(self, channel: snowflakes.SnowflakeishOr[channels_.GuildStageChannel]) -> None:
"""Delete the stage instance.

Parameters
----------
channel
The guild stage channel to fetch the stage instance from.

Raises
------
hikari.errors.UnauthorizedError
If you are unauthorized to make the request (invalid/missing token).
hikari.errors.NotFoundError
If the interaction or response is not found.
hikari.errors.RateLimitTooLongError
Raised in the event that a rate limit occurs that is
longer than `max_rate_limit` when making a request.
hikari.errors.RateLimitedError
Usually, Hikari will handle and retry on hitting
rate-limits automatically. This includes most bucket-specific
rate-limits and global rate-limits. In some rare edge cases,
however, Discord implements other undocumented rules for
rate-limiting, such as limits per attribute. These cannot be
detected or handled normally by Hikari due to their undocumented
nature, and will trigger this exception if they occur.
hikari.errors.InternalServerError
If an internal error occurs on Discord while handling the request.
"""
3 changes: 3 additions & 0 deletions hikari/audit_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,9 @@ class AuditLogEventType(int, enums.Enum):
INTEGRATION_CREATE = 80
INTEGRATION_UPDATE = 81
INTEGRATION_DELETE = 82
STAGE_INSTANCE_CREATE = 83
STAGE_INSTANCE_UPDATE = 84
STAGE_INSTANCE_DELETE = 85
STICKER_CREATE = 90
STICKER_UPDATE = 91
STICKER_DELETE = 92
Expand Down
1 change: 1 addition & 0 deletions hikari/events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from hikari.events.role_events import *
from hikari.events.scheduled_events import *
from hikari.events.shard_events import *
from hikari.events.stage_events import *
from hikari.events.typing_events import *
from hikari.events.user_events import *
from hikari.events.voice_events import *
1 change: 1 addition & 0 deletions hikari/events/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ from hikari.events.reaction_events import *
from hikari.events.role_events import *
from hikari.events.scheduled_events import *
from hikari.events.shard_events import *
from hikari.events.stage_events import *
from hikari.events.typing_events import *
from hikari.events.user_events import *
from hikari.events.voice_events import *
Loading
Loading