Skip to content

Commit

Permalink
select menu 150 chars, guild scheduled event id, USE_EMBEDDED_ACTIVIT…
Browse files Browse the repository at this point in the history
…IES, pre-7.0.5 (#760)

* select menu 150 chars, guild scheduled event id

* VoiceStateUpdate::channel_id may be undefined

* Add use_embedded_activities as replacement for start_embedded_activities

* add version logging

* use_embedded_activities setable & build docs

* placeholder max length build docs

* wrong class guild_scheduled_event_id field

* bump version, run php cs fixer

* use poly_strlen
  • Loading branch information
SQKo authored Mar 11, 2022
1 parent 570323b commit 0d75af9
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 27 deletions.
2 changes: 1 addition & 1 deletion docs/src/pages/api/07_permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Represents permissions for text, voice, and stage instance channels.
- `move_members`
- `use_vad`
- `manage_events`
- `start_embedded_activities`
- `use_embedded_activities` was `start_embedded_activities`

#### Stage Instance Channel Permissions

Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/api/09_components.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ $select = SelectMenu::new()
| ---------------------------------- | ------------------------------------------------------------------------------------------------------ |
| `addOption($option)` | adds an option to the select menu. maximum 25 options per menu. options must have unique values. |
| `removeOption($option)` | removes an option from the select menu. |
| `setPlaceholder($placeholder)` | sets a placeholder string to be displayed when nothing is selected. null to clear. max 100 characters. |
| `setPlaceholder($placeholder)` | sets a placeholder string to be displayed when nothing is selected. null to clear. max 150 characters. |
| `setMinValues($min_values)` | the number of values which must be selected to submit the menu. between 0 and 25, default 1. |
| `setMaxValues($max_values)` | the maximum number of values which can be selected. maximum 25, default 1. |
| `setDisabled($disabled)` | sets whether the menu is disabled or not. |
Expand Down
8 changes: 4 additions & 4 deletions src/Discord/Builders/Components/SelectMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class SelectMenu extends Component
private $options = [];

/**
* Placeholder string to display if nothing is selected. Maximum 100 characters.
* Placeholder string to display if nothing is selected. Maximum 150 characters.
*
* @var string|null
*/
Expand Down Expand Up @@ -176,7 +176,7 @@ public function removeOption(Option $option): self

/**
* Sets the placeholder string to display if nothing is selected.
* Maximum 100 characters. Null to clear placeholder.
* Maximum 150 characters. Null to clear placeholder.
*
* @param string|null $placeholder
*
Expand All @@ -186,8 +186,8 @@ public function removeOption(Option $option): self
*/
public function setPlaceholder(?string $placeholder): self
{
if (isset($placeholder) && strlen($placeholder) > 100) {
throw new \LengthException('Placeholder string must be less than or equal to 100 characters.');
if (isset($placeholder) && poly_strlen($placeholder) > 150) {
throw new \LengthException('Placeholder string must be less than or equal to 150 characters.');
}

$this->placeholder = $placeholder;
Expand Down
2 changes: 1 addition & 1 deletion src/Discord/Builders/Components/TextInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public function setMaxLength(?int $max_length): self
*/
public function setPlaceholder(?string $placeholder): self
{
if (isset($placeholder) && strlen($placeholder) > 100) {
if (isset($placeholder) && poly_strlen($placeholder) > 100) {
throw new \LengthException('Placeholder string must be less than or equal to 100 characters.');
}

Expand Down
4 changes: 3 additions & 1 deletion src/Discord/Discord.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class Discord
*
* @var string Version.
*/
public const VERSION = 'v7.0.4';
public const VERSION = 'v7.0.5';

/**
* The logger.
Expand Down Expand Up @@ -332,6 +332,8 @@ public function __construct(array $options = [])
$this->loop = $options['loop'];
$this->logger = $options['logger'];

$this->logger->debug('Initializing DiscordPHP '.self::VERSION.' (DiscordPHP-Http: '.Http::VERSION.' & Gateway: v'.self::GATEWAY_VERSION.') on PHP '.PHP_VERSION);

$connector = new SocketConnector($this->loop, $options['socket_options']);
$this->wsFactory = new Connector($this->loop, $connector);
$this->handlers = new Handlers();
Expand Down
16 changes: 9 additions & 7 deletions src/Discord/Parts/Channel/StageInstance.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
*
* @see https://discord.com/developers/docs/resources/stage-instance#stage-instance-resource
*
* @property string $id The unique identifier of the Stage Instance.
* @property string $guild_id The unique identifier of the guild that the stage instance associated to.
* @property Guild|null $guild The guild that the stage instance associated to.
* @property string $channel_id The id of the associated Stage channel.
* @property Channel $channel The channel that the stage instance associated to.
* @property string $topic The topic of the Stage instance (1-120 characters).
* @property int $privacy_level The privacy level of the Stage instance.
* @property string $id The unique identifier of the Stage Instance.
* @property string $guild_id The unique identifier of the guild that the stage instance associated to.
* @property Guild|null $guild The guild that the stage instance associated to.
* @property string $channel_id The id of the associated Stage channel.
* @property Channel $channel The channel that the stage instance associated to.
* @property string $topic The topic of the Stage instance (1-120 characters).
* @property int $privacy_level The privacy level of the Stage instance.
* @property string|null $guild_scheduled_event_id The id of the scheduled event.
*/
class StageInstance extends Part
{
Expand All @@ -43,6 +44,7 @@ class StageInstance extends Part
'topic',
'privacy_level',
'discoverable_disabled',
'guild_scheduled_event_id',
];

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Discord/Parts/Interactions/Request/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* @property Emoji|null $emoji Name, id, and animated. (Buttons)
* @property string|null $url A url for link-style buttons. (Buttons)
* @property object[]|null $options The choices in the select, max 25. (Select Menus)
* @property string|null $placeholder Custom placeholder text if nothing is selected, max 100 characters. (Select Menus, Text Inputs)
* @property string|null $placeholder Custom placeholder text if nothing is selected, max 150 characters. (Select Menus, Text Inputs)
* @property int|null $min_values The minimum number of items that must be chosen; default 1, min 0, max 25. (Select Menus)
* @property int|null $max_values The maximum number of items that can be chosen; default 1, max 25. (Select Menus)
* @property ComponentRepository $components A list of child components. (Action Rows)
Expand Down
2 changes: 1 addition & 1 deletion src/Discord/Parts/Permissions/ChannelPermission.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @property bool $move_members
* @property bool $use_vad
* @property bool $manage_events
* @property bool $start_embedded_activities
* @property bool $start_embedded_activities @todo $use_embedded_activities
*
* @property bool $add_reactions
* @property bool $send_messages
Expand Down
22 changes: 21 additions & 1 deletion src/Discord/Parts/Permissions/Permission.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ abstract class Permission extends Part
'move_members' => 24,
'use_vad' => 25,
'manage_events' => 33,
'start_embedded_activities' => 39,
'start_embedded_activities' => 39, // @todo use_embedded_activities
];

/**
Expand Down Expand Up @@ -199,6 +199,26 @@ protected function setBitwiseAttribute($bitwise)
}
}

/**
* @inheritdoc
*
* @todo replace start_embedded_activities in next major version
*/
protected function getUseEmbeddedActivitiesAttribute()
{
return $this->attributes['start_embedded_activities'] ?? null;
}

/**
* @inheritdoc
*
* @todo replace start_embedded_activities in next major version
*/
protected function setUseEmbeddedActivitiesAttribute($value)
{
$this->attributes['start_embedded_activities'] = $value;
}

/**
* @inheritdoc
*
Expand Down
2 changes: 1 addition & 1 deletion src/Discord/Parts/Permissions/RolePermission.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @property bool $move_members
* @property bool $use_vad
* @property bool $manage_events
* @property bool $start_embedded_activities
* @property bool $start_embedded_activities @todo $use_embedded_activities
*
* @property bool $add_reactions
* @property bool $send_messages
Expand Down
2 changes: 1 addition & 1 deletion src/Discord/Parts/User/Member.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ public function getPermissions($channel = null): RolePermission
if ($channel) {
if ($channel instanceof Thread) {
$channel = $this->guild->channels->get('id', $channel->parent_id);
} elseif (!($channel instanceof Channel)) {
} elseif (! ($channel instanceof Channel)) {
throw new \InvalidArgumentException('$channel must be an instance of Channel, Thread or null.');
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Discord/Parts/WebSockets/VoiceStateUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected function getGuildAttribute(): ?Guild
*/
protected function getChannelAttribute(): ?Channel
{
if (! $this->channel_id) {
if (! isset($this->attributes['channel_id'])) {
return null;
}

Expand Down
12 changes: 6 additions & 6 deletions src/Discord/Voice/VoiceClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,21 +326,21 @@ class VoiceClient extends EventEmitter
protected $dnsConfig;

/**
* Silence Frame Remain Count
* Silence Frame Remain Count.
*
* @var int Amount of silence frames remaining.
*/
protected $silenceRemaining = 5;

/**
* readopus Timer
* readopus Timer.
*
* @var TimerInterface Timer
*/
protected $readOpusTimer;

/**
* Audio Buffer
* Audio Buffer.
*
* @var Buffer The Audio Buffer
*/
Expand Down Expand Up @@ -874,8 +874,8 @@ public function playDCAStream($stream): ExtendedPromiseInterface
private function reset(): void
{
if ($this->readOpusTimer) {
$this->loop->cancelTimer($this->readOpusTimer);
$this->readOpusTimer = null;
$this->loop->cancelTimer($this->readOpusTimer);
$this->readOpusTimer = null;
}

$this->setSpeaking(false);
Expand Down Expand Up @@ -1519,7 +1519,7 @@ private function insertSilence(): void
{
// https://discord.com/developers/docs/topics/voice-connections#voice-data-interpolation
while ($this->silenceRemaining--) {
$this->sendBuffer(self::SILENCE_FRAME);
$this->sendBuffer(self::SILENCE_FRAME);
}
}
}

0 comments on commit 0d75af9

Please sign in to comment.