Skip to content

Commit

Permalink
Implemented ability to open DM channel
Browse files Browse the repository at this point in the history
  • Loading branch information
Plytas committed Aug 15, 2024
1 parent 217415b commit 13e7a81
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
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 ?DiscordUser $user = null,
public ?string $guild_id = null,
public ?string $channel_id = null,
/**
Expand Down
5 changes: 5 additions & 0 deletions src/Discord.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ public function deleteMessage(string $channelId, string $messageId): Response
return $this->client->delete("/channels/{$channelId}/messages/{$messageId}");
}

public function openDirectMessageChannel(string $userId): Response
{
return $this->client->asJson()->post("/users/@me/channels", ['recipient_id' => $userId]);
}

public function getGuild(string $guildId): DiscordGuild
{
return DiscordGuild::from($this->client->get("/guilds/{$guildId}")->json());
Expand Down
1 change: 1 addition & 0 deletions src/Facades/Discord.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,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 Response openDirectMessageChannel(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 13e7a81

Please sign in to comment.