Skip to content

Commit

Permalink
Added guild support to interactions
Browse files Browse the repository at this point in the history
  • Loading branch information
Plytas committed Jun 26, 2024
1 parent 5d44423 commit da91f52
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Data/DiscordGuild.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Plytas\Discord\Data;

use Spatie\LaravelData\Data;

class DiscordGuild extends Data
{
public function __construct(
public string $id,
public string $name,
public ?string $icon = null,
)
{
}
}
1 change: 1 addition & 0 deletions src/Data/DiscordInteraction.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public function __construct(
public int $version,
public string $token,
public ?DiscordMember $member = null,
public ?string $guild_id = null,
public ?string $channel_id = null,
/**
* @var array<string, mixed>
Expand Down
6 changes: 6 additions & 0 deletions src/Discord.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Support\Facades\Http;
use Plytas\Discord\Data\DiscordApplicationCommand;
use Plytas\Discord\Data\DiscordChannel;
use Plytas\Discord\Data\DiscordGuild;
use Plytas\Discord\Data\DiscordInteraction;
use Plytas\Discord\Data\DiscordMessage;
use Plytas\Discord\Data\DiscordRole;
Expand Down Expand Up @@ -76,6 +77,11 @@ public function deleteMessage(string $channelId, string $messageId): Response
return $this->client->delete("/channels/{$channelId}/messages/{$messageId}");
}

public function getGuild(string $guildId): DiscordGuild
{
return DiscordGuild::from($this->client->get("/guilds/{$guildId}")->json());
}

/**
* @return Collection<int, DiscordChannel>
*/
Expand Down
2 changes: 2 additions & 0 deletions src/Facades/Discord.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Support\Facades\Facade;
use Plytas\Discord\Data\DiscordApplicationCommand;
use Plytas\Discord\Data\DiscordChannel;
use Plytas\Discord\Data\DiscordGuild;
use Plytas\Discord\Data\DiscordInteraction;
use Plytas\Discord\Data\DiscordMessage;
use Plytas\Discord\Data\DiscordRole;
Expand All @@ -18,6 +19,7 @@
* @method static Response createMessage(string $channelId, DiscordMessage $message)
* @method static Response updateMessage(string $channelId, string $messageId, DiscordMessage $message)
* @method static Response deleteMessage(string $channelId, string $messageId)
* @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 da91f52

Please sign in to comment.