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

update ExtendedPromiseInterface and resolve #102

Merged
merged 3 commits into from
Nov 20, 2024
Merged
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
6 changes: 3 additions & 3 deletions fakes/PromiseFake.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Fakes\Ragnarok\Fenrir;

use React\Promise\ExtendedPromiseInterface;
use React\Promise\PromiseInterface;
use React\Promise\Promise;
use Throwable;

Expand All @@ -15,7 +15,7 @@ class PromiseFake
*
* @param mixed $return What the promise should resolve to
*/
public static function get(mixed $return = null): ExtendedPromiseInterface
public static function get(mixed $return = null): PromiseInterface
{
return new Promise(static function ($resolve) use ($return) {
$resolve($return);
Expand All @@ -27,7 +27,7 @@ public static function get(mixed $return = null): ExtendedPromiseInterface
*
* @param Throwable $e The exception
*/
public static function reject(Throwable $e): ExtendedPromiseInterface
public static function reject(Throwable $e): PromiseInterface
{
return new Promise(static function ($resolve, $reject) use ($e) {
$reject($e);
Expand Down
4 changes: 2 additions & 2 deletions fakes/RetrierFake.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
namespace Fakes\Ragnarok\Fenrir;

use Exan\Retrier\Retrier;
use React\Promise\ExtendedPromiseInterface;
use React\Promise\PromiseInterface;

class RetrierFake extends Retrier
{
public function retry(int $attempts, callable $action): ExtendedPromiseInterface
public function retry(int $attempts, callable $action): PromiseInterface
{
return PromiseFake::get($action(1));
}
Expand Down
4 changes: 2 additions & 2 deletions fakes/WebsocketFake.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
use Evenement\EventEmitter;
use JsonSerializable;
use Ragnarok\Fenrir\WebsocketInterface;
use React\Promise\ExtendedPromiseInterface;
use React\Promise\PromiseInterface;

class WebsocketFake extends EventEmitter implements WebsocketInterface
{
public array $openings = [];

public function open(string $url): ExtendedPromiseInterface
public function open(string $url): PromiseInterface
{
$this->openings[] = $url;

Expand Down
6 changes: 3 additions & 3 deletions src/Gateway/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
use Ratchet\RFC6455\Messaging\MessageInterface;
use React\EventLoop\LoopInterface;
use React\EventLoop\TimerInterface;
use React\Promise\ExtendedPromiseInterface;
use React\Promise\PromiseInterface;

/**
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
Expand Down Expand Up @@ -183,7 +183,7 @@ public function setSequence(int $sequence): void
$this->sequence = $sequence;
}

public function connect(string $url): ExtendedPromiseInterface
public function connect(string $url): PromiseInterface
{
$url .= '?' . http_build_query(self::QUERY_DATA);

Expand Down Expand Up @@ -309,7 +309,7 @@ public function resume(): void
], true);
}

public function open(): ExtendedPromiseInterface
public function open(): PromiseInterface
{
return $this->connect(self::DEFAULT_WEBSOCKET_URL);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Gateway/ConnectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Exan\Eventer\Eventer;
use Ragnarok\Fenrir\EventHandler;
use Ragnarok\Fenrir\Gateway\Helpers\PresenceUpdateBuilder;
use React\Promise\ExtendedPromiseInterface;
use React\Promise\PromiseInterface;

interface ConnectionInterface
{
Expand All @@ -16,7 +16,7 @@ public function getDefaultUrl(): string;
public function getSequence(): ?int;
public function setSequence(int $sequence);

public function connect(string $url): ExtendedPromiseInterface;
public function connect(string $url): PromiseInterface;
public function disconnect(int $code, string $reason): void;

public function setSessionId(string $sessionId): void;
Expand Down
4 changes: 2 additions & 2 deletions src/Interaction/ButtonInteraction.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Ragnarok\Fenrir\Discord;
use Ragnarok\Fenrir\Gateway\Events\InteractionCreate;
use Ragnarok\Fenrir\Interaction\Helpers\InteractionCallbackBuilder;
use React\Promise\ExtendedPromiseInterface;
use React\Promise\PromiseInterface;

class ButtonInteraction
{
Expand All @@ -17,7 +17,7 @@ public function __construct(public readonly InteractionCreate $interaction, priv

public function createInteractionResponse(
InteractionCallbackBuilder $interactionCallbackBuilder
): ExtendedPromiseInterface {
): PromiseInterface {
return $this->discord->rest->webhook->createInteractionResponse(
$this->interaction->id,
$this->interaction->token,
Expand Down
10 changes: 5 additions & 5 deletions src/Interaction/CommandInteraction.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Ragnarok\Fenrir\Interaction\Helpers\InteractionCallbackBuilder;
use Ragnarok\Fenrir\Parts\ApplicationCommandInteractionDataOptionStructure as OptionStructure;
use Ragnarok\Fenrir\Rest\Helpers\Webhook\EditWebhookBuilder;
use React\Promise\ExtendedPromiseInterface;
use React\Promise\PromiseInterface;

use function Freezemage\ArrayUtils\find as array_find;

Expand All @@ -30,23 +30,23 @@ public function __construct(public readonly InteractionCreate $interaction, priv

public function createInteractionResponse(
InteractionCallbackBuilder $interactionCallbackBuilder
): ExtendedPromiseInterface {
): PromiseInterface {
return $this->discord->rest->webhook->createInteractionResponse(
$this->interaction->id,
$this->interaction->token,
$interactionCallbackBuilder
);
}

public function getInteractionResponse(): ExtendedPromiseInterface
public function getInteractionResponse(): PromiseInterface
{
return $this->discord->rest->webhook->getOriginalInteractionResponse(
$this->interaction->application_id,
$this->interaction->token
);
}

public function editInteractionResponse(EditWebhookBuilder $webhookBuilder): ExtendedPromiseInterface
public function editInteractionResponse(EditWebhookBuilder $webhookBuilder): PromiseInterface
{
return $this->discord->rest->webhook->editOriginalInteractionResponse(
$this->interaction->application_id,
Expand All @@ -55,7 +55,7 @@ public function editInteractionResponse(EditWebhookBuilder $webhookBuilder): Ext
);
}

public function deleteInteractionResponse(): ExtendedPromiseInterface
public function deleteInteractionResponse(): PromiseInterface
{
return $this->discord->rest->webhook->deleteOriginalInteractionResponse(
$this->interaction->application_id,
Expand Down
14 changes: 7 additions & 7 deletions src/Rest/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Ragnarok\Fenrir\Rest;

use Ragnarok\Fenrir\Parts\Application as PartsApplication;
use React\Promise\ExtendedPromiseInterface;
use React\Promise\PromiseInterface;

/**
* @see https://discord.com/developers/docs/resources/application
Expand All @@ -15,31 +15,31 @@ class Application extends HttpResource
/**
* @see https://discord.com/developers/docs/resources/application#get-current-application
*
* @return ExtendedPromiseInterface<\Ragnarok\Fenrir\Parts\Application>
* @return PromiseInterface<\Ragnarok\Fenrir\Parts\Application>
*/
public function getCurrent(): ExtendedPromiseInterface
public function getCurrent(): PromiseInterface
{
return $this->mapPromise(
$this->http->get(
'applications/@me' // @todo update endpoint to Endpoint:: when available
),
PartsApplication::class,
)->otherwise($this->logThrowable(...));
)->catch($this->logThrowable(...));
}

/**
* @see https://discord.com/developers/docs/resources/application#edit-current-application
*
* @return ExtendedPromiseInterface<\Ragnarok\Fenrir\Parts\Application>
* @return PromiseInterface<\Ragnarok\Fenrir\Parts\Application>
*/
public function editCurrent(array $params): ExtendedPromiseInterface
public function editCurrent(array $params): PromiseInterface
{
return $this->mapPromise(
$this->http->patch(
'applications/@me', // @todo update endpoint to Endpoint:: when available
$params,
),
PartsApplication::class,
)->otherwise($this->logThrowable(...));
)->catch($this->logThrowable(...));
}
}
14 changes: 7 additions & 7 deletions src/Rest/ApplicationRoleConnectionMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Discord\Http\Endpoint;
use Ragnarok\Fenrir\Parts\ApplicationRoleConnectionMetadata as PartsApplicationRoleConnectionMetadata;
use React\Promise\ExtendedPromiseInterface;
use React\Promise\PromiseInterface;

/**
* @see https://discord.com/developers/docs/resources/application-role-connection-metadata
Expand All @@ -16,31 +16,31 @@ class ApplicationRoleConnectionMetadata extends HttpResource
/**
* @see https://discord.com/developers/docs/resources/application-role-connection-metadata#get-application-role-connection-metadata-records
*
* @return ExtendedPromiseInterface<\Ragnarok\Fenrir\Parts\ApplicationRoleConnectionMetadata>
* @return PromiseInterface<\Ragnarok\Fenrir\Parts\ApplicationRoleConnectionMetadata>
*/
public function getRecords(): ExtendedPromiseInterface
public function getRecords(): PromiseInterface
{
return $this->mapPromise(
$this->http->get(
Endpoint::APPLICATION_ROLE_CONNECTION_METADATA,
),
PartsApplicationRoleConnectionMetadata::class,
)->otherwise($this->logThrowable(...));
)->catch($this->logThrowable(...));
}

/**
* @see https://discord.com/developers/docs/resources/application-role-connection-metadata#update-application-role-connection-metadata-records
*
* @return ExtendedPromiseInterface<\Ragnarok\Fenrir\Parts\ApplicationRoleConnectionMetadata>
* @return PromiseInterface<\Ragnarok\Fenrir\Parts\ApplicationRoleConnectionMetadata>
*/
public function updateRecords(array $params): ExtendedPromiseInterface
public function updateRecords(array $params): PromiseInterface
{
return $this->mapPromise(
$this->http->put(
Endpoint::APPLICATION_ROLE_CONNECTION_METADATA,
$params,
),
PartsApplicationRoleConnectionMetadata::class,
)->otherwise($this->logThrowable(...));
)->catch($this->logThrowable(...));
}
}
8 changes: 4 additions & 4 deletions src/Rest/AuditLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Discord\Http\Endpoint;
use Ragnarok\Fenrir\Parts\AuditLog as PartsAuditLog;
use Ragnarok\Fenrir\Rest\Helpers\AuditLog\GetGuildAuditLogsBuilder;
use React\Promise\ExtendedPromiseInterface;
use React\Promise\PromiseInterface;

/**
* @see https://discord.com/developers/docs/resources/audit-log
Expand All @@ -17,12 +17,12 @@ class AuditLog extends HttpResource
/**
* @see https://discord.com/developers/docs/resources/audit-log#get-guild-audit-log
*
* @return ExtendedPromiseInterface<\Ragnarok\Fenrir\Parts\AuditLog>
* @return PromiseInterface<\Ragnarok\Fenrir\Parts\AuditLog>
*/
public function getGuildAuditLogs(
string $guildId,
GetGuildAuditLogsBuilder $getGuildAuditLogsBuilder
): ExtendedPromiseInterface {
): PromiseInterface {
return $this->mapPromise(
$this->http->get(
Endpoint::bind(
Expand All @@ -32,6 +32,6 @@ public function getGuildAuditLogs(
$getGuildAuditLogsBuilder->get()
),
PartsAuditLog::class
)->otherwise($this->logThrowable(...));
)->catch($this->logThrowable(...));
}
}
Loading
Loading