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

Updates/sep 26 2024 #99

Merged
merged 24 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
fba5310
Add integration types config for application part
Exanlv Sep 26, 2024
e043c28
Add integration types and contexts to application command
Exanlv Sep 26, 2024
771042e
Add context to interaction
Exanlv Sep 26, 2024
8dc9b30
Add authorizing_integration_owners to interaction
Exanlv Sep 26, 2024
8a50533
Add interaction_metadata to message
Exanlv Sep 26, 2024
a9fa2bb
Deprecate ApplicationCommand::$dm_permissions and Message::$interaction
Exanlv Sep 26, 2024
d87288d
Add AutoModerationRuleTriggerType::MEMBER_PROFILE and ActionType::BLO…
Exanlv Sep 26, 2024
74d4bd2
Add premium button
Exanlv Sep 26, 2024
c4f5e97
Add use Permission::USE_EXTERNAL_SOUNDS
Exanlv Sep 26, 2024
46a3d2a
Add Permission::SEND_VOICE_MESSAGES
Exanlv Sep 26, 2024
a08169f
Add Permission::SEND_POLLS
Exanlv Sep 26, 2024
b40285d
Add Permission::USE_EXTERNAL_APPS
Exanlv Sep 26, 2024
24138e7
Add MessageReferenceType to MessageReference
Exanlv Sep 26, 2024
e3bf0ad
Add Application::$approximate_guild_count
Exanlv Sep 26, 2024
bc4b2e1
Add Application::$approximate_user_install_count
Exanlv Sep 26, 2024
6a3fa65
Add Application::$redirect_uris
Exanlv Sep 26, 2024
7d7e4fe
Add Application::$interactions_endpoint_url
Exanlv Sep 26, 2024
b5a59dc
Add Application Emoji rest calls
Exanlv Sep 26, 2024
eac742c
Add Guild voice state endpoints
Exanlv Sep 26, 2024
613462a
Add Guild get role endpoint
Exanlv Sep 26, 2024
c2c2ca1
Add Launch activity interaction callback type
Exanlv Sep 26, 2024
6368a1a
Add doc comment
Exanlv Sep 26, 2024
f44a12f
Use proper var name for application emoji delete call
Exanlv Sep 26, 2024
8005e33
cd
Exanlv Sep 26, 2024
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
32 changes: 32 additions & 0 deletions src/Component/Button/PremiumButton.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace Ragnarok\Fenrir\Component\Button;

use Ragnarok\Fenrir\Component\Component;
use Ragnarok\Fenrir\Enums\ButtonStyle;
use Ragnarok\Fenrir\Rest\Helpers\Emoji\EmojiBuilder;

class PremiumButton extends Component
{
private ButtonStyle $style = ButtonStyle::Premium;

public function __construct(
private string $skuId,
private bool $disabled = false
) {
}

public function get(): array
{
$data = [
'type' => 2,
'style' => $this->style,
'sku_id' => $this->skuId,
'disabled' => $this->disabled,
];

return $data;
}
}
1 change: 1 addition & 0 deletions src/Enums/ActionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ enum ActionType: int
case BLOCK_MESSAGE = 1;
case SENT_ALERT_MESSAGE = 2;
case TIMEOUT = 3;
case BLOCK_MEMBER_INTERACTION = 4;
}
11 changes: 11 additions & 0 deletions src/Enums/ApplicationIntegrationType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

declare(strict_types=1);

namespace Ragnarok\Fenrir\Enums;

enum ApplicationIntegrationType: int
{
case GUILD_INSTALL = 0;
case USER_INSTALL = 1;
}
1 change: 1 addition & 0 deletions src/Enums/AutoModerationRuleTriggerType.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ enum AutoModerationRuleTriggerType: int
case SPAM = 3;
case KEYWORD_PRESET = 4;
case MENTION_SPAM = 5;
case MEMBER_PROFILE = 6;
}
1 change: 1 addition & 0 deletions src/Enums/ButtonStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ enum ButtonStyle: int
case Success = 3;
case Danger = 4;
case Link = 5;
case Premium = 6;
}
1 change: 1 addition & 0 deletions src/Enums/InteractionCallbackType.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ enum InteractionCallbackType: int
case UPDATE_MESSAGE = 7;
case APPLICATION_COMMAND_AUTOCOMPLETE_RESULT = 8;
case MODAL = 9;
case LAUNCH_ACTIVITY = 12;
}
12 changes: 12 additions & 0 deletions src/Enums/InteractionContextType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace Ragnarok\Fenrir\Enums;

enum InteractionContextType: int
{
case GUILD = 0;
case BOT_DM = 1;
case PRIVATE_CHANNEL = 2;
}
11 changes: 11 additions & 0 deletions src/Enums/MessageReferenceType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

declare(strict_types=1);

namespace Ragnarok\Fenrir\Enums;

enum MessageReferenceType: int
{
case DEFAULT = 0;
case FORWARD = 1;
}
4 changes: 4 additions & 0 deletions src/Enums/Permission.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,8 @@ enum Permission: int
case MODERATE_MEMBERS = 1 << 40;
case CREATE_GUILD_EXPRESSIONS = 1 << 43;
case CREATE_EVENTS = 1 << 44;
case USE_EXTERNAL_SOUNDS = 1 << 45;
case SEND_VOICE_MESSAGES = 1 << 46;
case SEND_POLLS = 1 << 49;
case USE_EXTERNAL_APPS = 1 << 50;
}
14 changes: 13 additions & 1 deletion src/Parts/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Ragnarok\Fenrir\Parts;

use Ragnarok\Fenrir\Attributes\Partial;
use Ragnarok\Fenrir\Bitwise\Bitwise;
use Ragnarok\Fenrir\Mapping\ArrayMapping;

class Application
{
Expand All @@ -29,11 +29,23 @@ class Application
public ?string $slug;
public ?string $cover_image;
public ?Bitwise $flags;
public ?int $approximate_guild_count;
public ?int $approximate_user_install_count;
/**
* @var string[]
*/
public ?array $redirect_uris;
public ?string $interactions_endpoint_url;
/**
* @var string[]
*/
public ?array $tags;
public ?InstallParams $install_params;
public ?string $custom_install_url;
public ?string $role_connections_verification_url;
/**
* @var ApplicationIntegrationType[]
*/
#[ArrayMapping(ApplicationIntegrationType::class)]
public ?array $integration_types_config;
}
15 changes: 15 additions & 0 deletions src/Parts/ApplicationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
namespace Ragnarok\Fenrir\Parts;

use Ragnarok\Fenrir\Enums\ApplicationCommandTypes;
use Ragnarok\Fenrir\Enums\ApplicationIntegrationType;
use Ragnarok\Fenrir\Enums\InteractionContextType;
use Ragnarok\Fenrir\Mapping\ArrayMapping;

class ApplicationCommand
Expand All @@ -29,8 +31,21 @@ class ApplicationCommand
#[ArrayMapping(ApplicationCommandOptionStructure::class)]
public ?array $options;
public ?string $default_member_permissions;
/**
* @deprecated use $this->contexts instead
*/
public ?bool $dm_permission;
public ?bool $default_permission;
public ?bool $nsfw;
public string $version;
/**
* @var ApplicationIntegrationType[]
*/
#[ArrayMapping(ApplicationIntegrationType::class)]
public ?array $integration_types;
/**
* @var InteractionContextType[]
*/
#[ArrayMapping(InteractionContextType::class)]
public ?array $contexts;
}
10 changes: 10 additions & 0 deletions src/Parts/ApplicationIntegrationType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

namespace Ragnarok\Fenrir\Parts;

class ApplicationIntegrationType
{
public InstallParams $oauth2_install_params;
}
7 changes: 7 additions & 0 deletions src/Parts/Interaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Ragnarok\Fenrir\Parts;

use Ragnarok\Fenrir\Enums\InteractionContextType;
use Ragnarok\Fenrir\Enums\InteractionType;

class Interaction
Expand All @@ -24,4 +25,10 @@ class Interaction
public ?string $locale;
public string $guild_locale;
public Channel $channel;
public InteractionContextType $context;
/**
* @var string[]
* @see https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-authorizing-integration-owners-object
*/
public array $authorizing_integration_owners;
}
5 changes: 4 additions & 1 deletion src/Parts/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Ragnarok\Fenrir\Parts;

use Carbon\Carbon;
use Ragnarok\Fenrir\Attributes\Partial;
use Ragnarok\Fenrir\Bitwise\Bitwise;
use Ragnarok\Fenrir\Enums\MessageType;
use Ragnarok\Fenrir\Mapping\ArrayMapping;
Expand Down Expand Up @@ -58,6 +57,10 @@ class Message
public ?MessageReference $message_reference;
public ?Bitwise $flags;
public ?Message $referenced_message;
public ?MessageInteractionMetadata $interaction_metadata;
/**
* @deprecated use $this->interaction_metadata instead
*/
public ?MessageInteraction $interaction;
public ?Channel $thread;
/**
Expand Down
14 changes: 11 additions & 3 deletions src/Parts/MessageInteraction.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,22 @@

namespace Ragnarok\Fenrir\Parts;

use Ragnarok\Fenrir\Attributes\Partial;
use Ragnarok\Fenrir\Enums\InteractionType;

/**
* @see https://discord.com/developers/docs/resources/message#message-interaction-metadata-object-message-interaction-metadata-structure
*/
class MessageInteraction
{
public string $id;
public InteractionType $type;
public string $name;
public User $user;
public ?GuildMember $member;
/**
* @var string[]
* @see https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-authorizing-integration-owners-object
*/
public array $authorizing_integration_owners;
Exanlv marked this conversation as resolved.
Show resolved Hide resolved
public ?string $original_response_message_id;
public ?string $interacted_message_id;
public ?self $triggering_interaction_metadata;
}
16 changes: 16 additions & 0 deletions src/Parts/MessageInteractionMetadata.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace Ragnarok\Fenrir\Parts;

use Ragnarok\Fenrir\Enums\InteractionType;

class MessageInteractionMetadata
{
public string $id;
public InteractionType $type;
public string $name;
public User $user;
public ?GuildMember $member;
}
3 changes: 3 additions & 0 deletions src/Parts/MessageReference.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@

namespace Ragnarok\Fenrir\Parts;

use Ragnarok\Fenrir\Enums\MessageReferenceType;

class MessageReference
{
public ?MessageReferenceType $type;
public ?string $message_id;
public ?string $channel_id;
public ?string $guild_id;
Expand Down
99 changes: 99 additions & 0 deletions src/Rest/Emoji.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,103 @@ public function deleteGuildEmoji(
$this->getAuditLogReasonHeader($reason)
)->otherwise($this->logThrowable(...));
}

/**
* @see https://discord.com/developers/docs/resources/emoji#list-application-emojis
*
* @return ExtendedPromiseInterface<\Ragnarok\Fenrir\Parts\Emoji[]>
*/
public function listApplicationEmojis(string $applicationId): ExtendedPromiseInterface
{
return $this->mapArrayPromise(
$this->http->get(
Endpoint::bind(
'applications/:application/emojis',
$applicationId
),
),
PartsEmoji::class
)->otherwise($this->logThrowable(...));
}

/**
* @see https://discord.com/developers/docs/resources/emoji#get-application-emoji
*
* @return ExtendedPromiseInterface<\Ragnarok\Fenrir\Parts\Emoji>
*/
public function getApplicationEmoji(string $guildId, string $emojiId): ExtendedPromiseInterface
{
return $this->mapPromise(
$this->http->get(
Endpoint::bind(
'applications/:application/emojis/:emoji',
$guildId,
$emojiId
)
),
PartsEmoji::class
)->otherwise($this->logThrowable(...));
}

/**
* @see https://discord.com/developers/docs/resources/emoji#create-application-emoji
*
* @return ExtendedPromiseInterface<\Ragnarok\Fenrir\Parts\Emoji>
*/
public function createApplicationEmoji(
string $applicationId,
CreateEmojiBuilder $emojiBuilder,
): ExtendedPromiseInterface {
return $this->mapPromise(
$this->http->post(
Endpoint::bind(
'applications/:application/emojis',
$applicationId
),
$emojiBuilder->get(),
),
PartsEmoji::class
)->otherwise($this->logThrowable(...));
}

/**
* @see https://discord.com/developers/docs/resources/emoji#modify-application-emoji
*
* @return ExtendedPromiseInterface<\Ragnarok\Fenrir\Parts\Emoji>
*/
public function modifyApplicationEmoji(
string $applicationId,
string $emojiId,
CreateEmojiBuilder $emojiBuilder,
): ExtendedPromiseInterface {
return $this->mapPromise(
$this->http->patch(
Endpoint::bind(
'applications/:application/emojis/:emoji',
$applicationId,
$emojiId
),
$emojiBuilder->get(),
),
PartsEmoji::class
)->otherwise($this->logThrowable(...));
}

/**
* @see https://discord.com/developers/docs/resources/emoji#delete-application-emoji
*
* @return ExtendedPromiseInterface<void>
*/
public function deleteApplicationEmoji(
string $applicationId,
string $emojiId,
): ExtendedPromiseInterface {
return $this->http->delete(
Endpoint::bind(
'applications/:application/emojis/:emoji',
$applicationId,
$emojiId
),
)->otherwise($this->logThrowable(...));
}
}
Loading
Loading