Skip to content

Commit

Permalink
Added getUser() method
Browse files Browse the repository at this point in the history
  • Loading branch information
Plytas committed Feb 13, 2025
1 parent 38fb69f commit 1cafe43
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
20 changes: 10 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@
"spatie/laravel-package-tools": "^1.16"
},
"require-dev": {
"laravel/pint": "^1.14",
"nunomaduro/collision": "^8.1.1||^7.10.0",
"larastan/larastan": "^2.9",
"orchestra/testbench": "^9.0.0||^8.22.0",
"pestphp/pest": "^2.34",
"laravel/pint": "^1.20",
"nunomaduro/collision": "^8.5.0||^7.10.0",
"larastan/larastan": "^2.9.14",
"orchestra/testbench": "^9.9.0||^8.22.0",
"pestphp/pest": "^2.36",
"pestphp/pest-plugin-arch": "^2.7",
"pestphp/pest-plugin-laravel": "^2.3",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan-deprecation-rules": "^1.1",
"phpstan/phpstan-phpunit": "^1.3",
"spatie/laravel-ray": "^1.35"
"pestphp/pest-plugin-laravel": "^2.4",
"phpstan/extension-installer": "^1.4.3",
"phpstan/phpstan-deprecation-rules": "^1.2.1",
"phpstan/phpstan-phpunit": "^1.4.2",
"spatie/laravel-ray": "^1.39.1"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion config/discord-interactions.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

'middleware' => [
'before' => [
//ThrottleRequests::class,
// ThrottleRequests::class,
],
'after' => [

Expand Down
6 changes: 6 additions & 0 deletions src/Discord.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Plytas\Discord\Data\DiscordInteraction;
use Plytas\Discord\Data\DiscordMessage;
use Plytas\Discord\Data\DiscordRole;
use Plytas\Discord\Data\DiscordUser;
use Plytas\Discord\Exceptions\InvalidConfigurationException;

readonly class Discord
Expand Down Expand Up @@ -101,6 +102,11 @@ public function openDirectMessageChannel(string $userId): Response
return $this->client->asJson()->post('/users/@me/channels', ['recipient_id' => $userId]);
}

public function getUser(string $userId): DiscordUser
{
return DiscordUser::from($this->client->get("/users/{$userId}")->json());
}

public function getGuild(string $guildId): DiscordGuild
{
return DiscordGuild::from($this->client->get("/guilds/{$guildId}")->json());
Expand Down
2 changes: 1 addition & 1 deletion src/DiscordComponentRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function handle(DiscordInteraction $interaction): DiscordResponse
$componentHandler = self::$componentHandlers[$componentId] ?? null;

if ($componentHandler === null) {
return $interaction->pong(); //Maybe acknowledge the interaction
return $interaction->pong(); // Maybe acknowledge the interaction
}

if (! is_a($componentHandler, DiscordComponentHandler::class, true)) {
Expand Down
2 changes: 2 additions & 0 deletions src/Facades/Discord.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Plytas\Discord\Data\DiscordInteraction;
use Plytas\Discord\Data\DiscordMessage;
use Plytas\Discord\Data\DiscordRole;
use Plytas\Discord\Data\DiscordUser;

/**
* @method static Response createCommand(DiscordApplicationCommand $command)
Expand All @@ -20,6 +21,7 @@
* @method static Response updateMessage(string $channelId, string $messageId, DiscordMessage $message)
* @method static Response deleteMessage(string $channelId, string $messageId)
* @method static Response openDirectMessageChannel(string $userId)
* @method static DiscordUser getUser(string $userId)
* @method static DiscordGuild getGuild(string $guildId)
* @method static Collection<int, DiscordChannel> getChannels(string $guildId)
* @method static Collection<int, DiscordRole> getRoles(string $guildId)
Expand Down

0 comments on commit 1cafe43

Please sign in to comment.