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

feat : string possibility with interact #1199

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 24 additions & 0 deletions src/Discord/Parts/Channel/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ protected function getRecipientsAttribute(): Collection
return $recipients;
}






Comment on lines +265 to +269
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why ?

/**
* Returns the guild attribute.
*
Expand Down Expand Up @@ -350,6 +355,25 @@ public function setPermissions(Part $part, array $allow = [], array $deny = [],
return $this->setOverwrite($part, $overwrite, $reason);
}


/**
* Rename channel
*
* @param string $name
* @return ExtendedPromiseInterface
*/
public function rename(string $name): ExtendedPromiseInterface
{
if ($this->name === $name) {
return reject(new InvalidOverwriteException('The name is already set in the channel.'));
}

$this->name = $name;
return $this->http->patch(Endpoint::bind(Endpoint::CHANNEL, $this->id),[
'name' => $this->name
]);
}

Comment on lines +360 to +376
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in a separate PR

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree with this, there is already $channel->name setter and save()
we cant let adding every function for changing every simple attribute like this

people would make multiple different http calls just to update a channel information

/**
* Sets an overwrite to the channel.
*
Expand Down
6 changes: 5 additions & 1 deletion src/Discord/Parts/Interactions/Interaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,12 +414,16 @@ public function sendFollowUpMessage(MessageBuilder $builder, bool $ephemeral = f
*
* @return ExtendedPromiseInterface
*/
public function respondWithMessage(MessageBuilder $builder, bool $ephemeral = false): ExtendedPromiseInterface
public function respondWithMessage(string|MessageBuilder $builder, bool $ephemeral = false): ExtendedPromiseInterface
{
if (! in_array($this->type, [InteractionType::APPLICATION_COMMAND, InteractionType::MESSAGE_COMPONENT, InteractionType::MODAL_SUBMIT])) {
return reject(new \LogicException('You can only acknowledge application command, message component, or modal submit interactions.'));
}

if (is_string($builder)) {
$builder = MessageBuilder::new()->setContent($builder);
}

if ($ephemeral) {
$builder->setFlags(Message::FLAG_EPHEMERAL);
}
Expand Down