From b6c720f33101d3b46fb25a8fb1d8e83bef4d9701 Mon Sep 17 00:00:00 2001 From: SQKo <87897282+SQKo@users.noreply.github.com> Date: Sun, 30 Apr 2023 20:23:13 +0700 Subject: [PATCH 1/4] Update stage channel behavior --- src/Discord/Parts/Channel/Channel.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Discord/Parts/Channel/Channel.php b/src/Discord/Parts/Channel/Channel.php index 1bdc7dc1e..5ff05494c 100644 --- a/src/Discord/Parts/Channel/Channel.php +++ b/src/Discord/Parts/Channel/Channel.php @@ -66,7 +66,7 @@ * @property bool|null $nsfw Whether the channel is NSFW. * @property ?string|null $last_message_id The unique identifier of the last message sent in the channel (or thread for forum channels) (may not point to an existing or valid message or thread). * @property int|null $bitrate The bitrate of the channel. Only for voice channels. - * @property int|null $user_limit The user limit of the channel. + * @property int|null $user_limit The user limit of the channel. Max 99 for voice channels and 10000 for stage channels (0 refers to no limit). * @property int|null $rate_limit_per_user Amount of seconds a user has to wait before sending a new message (slow mode). * @property Collection|User[] $recipients A collection of all the recipients in the channel. Only for DM or group channels. * @property-read User|null $recipient The first recipient of the channel. Only for DM or group channels. @@ -1299,7 +1299,7 @@ public function allowInvite() */ public function isTextBased() { - return in_array($this->type, [self::TYPE_GUILD_TEXT, self::TYPE_DM, self::TYPE_GUILD_VOICE, self::TYPE_GROUP_DM, self::TYPE_PUBLIC_THREAD, self::TYPE_PRIVATE_THREAD, self::TYPE_GUILD_ANNOUNCEMENT]); + return in_array($this->type, [self::TYPE_GUILD_TEXT, self::TYPE_DM, self::TYPE_GUILD_VOICE, self::TYPE_GROUP_DM, self::TYPE_PUBLIC_THREAD, self::TYPE_PRIVATE_THREAD, self::TYPE_GUILD_ANNOUNCEMENT, self::TYPE_GUILD_STAGE_VOICE]); } /** @@ -1419,7 +1419,9 @@ public function getUpdatableAttributes(): array $attr['parent_id'] = $this->parent_id; $attr['default_auto_archive_duration'] = $this->default_auto_archive_duration; } elseif ($this->type == self::TYPE_GUILD_STAGE_VOICE) { + $attr['nsfw'] = $this->nsfw; $attr['rate_limit_per_user'] = $this->rate_limit_per_user; + $attr['user_limit'] = $this->user_limit; $attr['parent_id'] = $this->parent_id; $attr['bitrate'] = $this->bitrate; $attr['rtc_region'] = $this->rtc_region; From 42f5ea0627d052d9293ce2c53e9cfd45f11e8eb5 Mon Sep 17 00:00:00 2001 From: SQKo <87897282+SQKo@users.noreply.github.com> Date: Sun, 30 Apr 2023 20:23:40 +0700 Subject: [PATCH 2/4] Update stage channel and all permission --- src/Discord/Parts/Permissions/Permission.php | 34 +++++++------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/src/Discord/Parts/Permissions/Permission.php b/src/Discord/Parts/Permissions/Permission.php index f93eec2cf..709b30a29 100644 --- a/src/Discord/Parts/Permissions/Permission.php +++ b/src/Discord/Parts/Permissions/Permission.php @@ -39,9 +39,9 @@ abstract class Permission extends Part * @var array */ public const STAGE_PERMISSIONS = [ + 'stream' => 9, 'connect' => 20, 'mute_members' => 22, - 'deafen_members' => 23, 'move_members' => 24, 'request_to_speak' => 32, 'manage_events' => 33, @@ -54,25 +54,15 @@ abstract class Permission extends Part * @var array */ public const VOICE_PERMISSIONS = [ - 'add_reactions' => 6, 'priority_speaker' => 8, 'stream' => 9, - 'send_messages' => 11, - 'send_tts_messages' => 12, - 'manage_messages' => 13, - 'embed_links' => 14, - 'attach_files' => 15, - 'read_message_history' => 16, - 'use_external_emojis' => 18, 'connect' => 20, 'speak' => 21, 'mute_members' => 22, 'deafen_members' => 23, 'move_members' => 24, 'use_vad' => 25, - 'manage_webhooks' => 29, 'manage_events' => 33, - 'use_external_stickers' => 37, 'use_embedded_activities' => 39, ]; @@ -83,20 +73,9 @@ abstract class Permission extends Part * @var array */ public const TEXT_PERMISSIONS = [ - 'add_reactions' => 6, - 'send_messages' => 11, - 'send_tts_messages' => 12, - 'manage_messages' => 13, - 'embed_links' => 14, - 'attach_files' => 15, - 'read_message_history' => 16, - 'use_external_emojis' => 18, - 'manage_webhooks' => 29, - 'use_application_commands' => 31, 'manage_threads' => 34, 'create_public_threads' => 35, 'create_private_threads' => 36, - 'use_external_stickers' => 37, 'send_messages_in_threads' => 38, ]; @@ -129,9 +108,20 @@ abstract class Permission extends Part public const ALL_PERMISSIONS = [ 'create_instant_invite' => 0, 'manage_channels' => 4, + 'add_reactions' => 6, 'view_channel' => 10, + 'send_messages' => 11, + 'send_tts_messages' => 12, + 'manage_messages' => 13, + 'embed_links' => 14, + 'attach_files' => 15, + 'read_message_history' => 16, 'mention_everyone' => 17, + 'use_external_emojis' => 18, 'manage_roles' => 28, + 'manage_webhooks' => 29, + 'use_application_commands' => 31, + 'use_external_stickers' => 37, ]; /** From 6e819ad56ec1c9a195530832665826ad54349025 Mon Sep 17 00:00:00 2001 From: SQKo <87897282+SQKo@users.noreply.github.com> Date: Sun, 30 Apr 2023 20:27:30 +0700 Subject: [PATCH 3/4] Add message types for stage channel --- src/Discord/Parts/Channel/Message.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Discord/Parts/Channel/Message.php b/src/Discord/Parts/Channel/Message.php index 2cb600d22..80d0b354a 100644 --- a/src/Discord/Parts/Channel/Message.php +++ b/src/Discord/Parts/Channel/Message.php @@ -120,6 +120,10 @@ class Message extends Part public const TYPE_AUTO_MODERATION_ACTION = 24; public const TYPE_ROLE_SUBSCRIPTION_PURCHASE = 25; public const TYPE_INTERACTION_PREMIUM_UPSELL = 26; + public const TYPE_STAGE_START = 27; + public const TYPE_STAGE_END = 28; + public const TYPE_STAGE_SPEAKER = 29; + public const TYPE_STAGE_TOPIC = 31; public const TYPE_GUILD_APPLICATION_PREMIUM_SUBSCRIPTION = 32; /** @deprecated 7.1.0 Use `Message::TYPE_USER_JOIN` */ From 8728f0cd05d42dcc896e1ba51a8fe00b265039c4 Mon Sep 17 00:00:00 2001 From: Exanlv Date: Sun, 30 Apr 2023 16:42:39 +0200 Subject: [PATCH 4/4] make array multi line to improve readability --- src/Discord/Parts/Channel/Channel.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Discord/Parts/Channel/Channel.php b/src/Discord/Parts/Channel/Channel.php index 5ff05494c..dd416194e 100644 --- a/src/Discord/Parts/Channel/Channel.php +++ b/src/Discord/Parts/Channel/Channel.php @@ -1299,7 +1299,16 @@ public function allowInvite() */ public function isTextBased() { - return in_array($this->type, [self::TYPE_GUILD_TEXT, self::TYPE_DM, self::TYPE_GUILD_VOICE, self::TYPE_GROUP_DM, self::TYPE_PUBLIC_THREAD, self::TYPE_PRIVATE_THREAD, self::TYPE_GUILD_ANNOUNCEMENT, self::TYPE_GUILD_STAGE_VOICE]); + return in_array($this->type, [ + self::TYPE_GUILD_TEXT, + self::TYPE_DM, + self::TYPE_GUILD_VOICE, + self::TYPE_GROUP_DM, + self::TYPE_PUBLIC_THREAD, + self::TYPE_PRIVATE_THREAD, + self::TYPE_GUILD_ANNOUNCEMENT, + self::TYPE_GUILD_STAGE_VOICE + ]); } /**