Skip to content

Commit

Permalink
Chore/event intents mapping (#55)
Browse files Browse the repository at this point in the history
- Add RequiresIntent attribute
  • Loading branch information
Exanlv authored Jul 6, 2023
1 parent 116106d commit c47cfd9
Show file tree
Hide file tree
Showing 67 changed files with 205 additions and 48 deletions.
12 changes: 0 additions & 12 deletions src/Attributes/Intent.php

This file was deleted.

12 changes: 0 additions & 12 deletions src/Attributes/Partial.php

This file was deleted.

19 changes: 19 additions & 0 deletions src/Attributes/RequiresIntent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace Ragnarok\Fenrir\Attributes;

use Attribute;
use Ragnarok\Fenrir\Enums\Intent;

/**
* Indicates related intents
*/
#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
class RequiresIntent
{
public function __construct(public readonly Intent $intent)
{
}
}
3 changes: 3 additions & 0 deletions src/Gateway/Events/ApplicationCommandPermissionsUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

namespace Ragnarok\Fenrir\Gateway\Events;

use Ragnarok\Fenrir\Attributes\RequiresIntent;
use Ragnarok\Fenrir\Enums\Intent;
use Ragnarok\Fenrir\Parts\ApplicationCommandPermissions;

/**
* @see https://discord.com/developers/docs/topics/gateway-events#application-command-permissions-update
*/
#[RequiresIntent(Intent::AUTO_MODERATION_CONFIGURATION)]
class ApplicationCommandPermissionsUpdate extends ApplicationCommandPermissions
{
}
3 changes: 3 additions & 0 deletions src/Gateway/Events/AutoModerationActionExecution.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@

namespace Ragnarok\Fenrir\Gateway\Events;

use Ragnarok\Fenrir\Attributes\RequiresIntent;
use Ragnarok\Fenrir\Enums\Intent;
use Ragnarok\Fenrir\Enums\AutoModerationRuleTriggerType;
use Ragnarok\Fenrir\Parts\AutoModerationAction;

/**
* @see https://discord.com/developers/docs/topics/gateway-events#auto-moderation-action-execution
*/
#[RequiresIntent(Intent::AUTO_MODERATION_EXECUTION)]
class AutoModerationActionExecution
{
public string $guild_id;
Expand Down
3 changes: 3 additions & 0 deletions src/Gateway/Events/AutoModerationRuleCreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

namespace Ragnarok\Fenrir\Gateway\Events;

use Ragnarok\Fenrir\Attributes\RequiresIntent;
use Ragnarok\Fenrir\Enums\Intent;
use Ragnarok\Fenrir\Parts\ApplicationCommandPermissions;

/**
* @see https://discord.com/developers/docs/topics/gateway-events#auto-moderation-rule-create
*/
#[RequiresIntent(Intent::AUTO_MODERATION_CONFIGURATION)]
class AutoModerationRuleCreate extends ApplicationCommandPermissions
{
}
3 changes: 3 additions & 0 deletions src/Gateway/Events/AutoModerationRuleDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

namespace Ragnarok\Fenrir\Gateway\Events;

use Ragnarok\Fenrir\Attributes\RequiresIntent;
use Ragnarok\Fenrir\Enums\Intent;
use Ragnarok\Fenrir\Parts\ApplicationCommandPermissions;

/**
* @see https://discord.com/developers/docs/topics/gateway-events#channel-delete
*/
#[RequiresIntent(Intent::AUTO_MODERATION_CONFIGURATION)]
class AutoModerationRuleDelete extends ApplicationCommandPermissions
{
}
3 changes: 3 additions & 0 deletions src/Gateway/Events/AutoModerationRuleUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

namespace Ragnarok\Fenrir\Gateway\Events;

use Ragnarok\Fenrir\Attributes\RequiresIntent;
use Ragnarok\Fenrir\Enums\Intent;
use Ragnarok\Fenrir\Parts\ApplicationCommandPermissions;

/**
* @see https://discord.com/developers/docs/topics/gateway-events#auto-moderation-rule-update
*/
#[RequiresIntent(Intent::AUTO_MODERATION_CONFIGURATION)]
class AutoModerationRuleUpdate extends ApplicationCommandPermissions
{
}
3 changes: 3 additions & 0 deletions src/Gateway/Events/ChannelCreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

namespace Ragnarok\Fenrir\Gateway\Events;

use Ragnarok\Fenrir\Attributes\RequiresIntent;
use Ragnarok\Fenrir\Enums\Intent;
use Ragnarok\Fenrir\Parts\Channel;

/**
* @see https://discord.com/developers/docs/topics/gateway-events#channel-create
*/
#[RequiresIntent(Intent::GUILDS)]
class ChannelCreate extends Channel
{
}
3 changes: 3 additions & 0 deletions src/Gateway/Events/ChannelDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

namespace Ragnarok\Fenrir\Gateway\Events;

use Ragnarok\Fenrir\Attributes\RequiresIntent;
use Ragnarok\Fenrir\Enums\Intent;
use Ragnarok\Fenrir\Parts\Channel;

/**
* @see https://discord.com/developers/docs/topics/gateway-events#channel-delete
*/
#[RequiresIntent(Intent::GUILDS)]
class ChannelDelete extends Channel
{
}
3 changes: 3 additions & 0 deletions src/Gateway/Events/ChannelPinsUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
namespace Ragnarok\Fenrir\Gateway\Events;

use Carbon\Carbon;
use Ragnarok\Fenrir\Attributes\RequiresIntent;
use Ragnarok\Fenrir\Enums\Intent;

/**
* @see https://discord.com/developers/docs/topics/gateway-events#channel-pins-update
*/
#[RequiresIntent(Intent::GUILDS)]
class ChannelPinsUpdate
{
public ?string $guild_id;
Expand Down
3 changes: 3 additions & 0 deletions src/Gateway/Events/ChannelUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

namespace Ragnarok\Fenrir\Gateway\Events;

use Ragnarok\Fenrir\Attributes\RequiresIntent;
use Ragnarok\Fenrir\Enums\Intent;
use Ragnarok\Fenrir\Parts\Channel;

/**
* @see https://discord.com/developers/docs/topics/gateway-events#channel-update
*/
#[RequiresIntent(Intent::GUILDS)]
class ChannelUpdate extends Channel
{
}
3 changes: 3 additions & 0 deletions src/Gateway/Events/GuildBanAdd.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

namespace Ragnarok\Fenrir\Gateway\Events;

use Ragnarok\Fenrir\Attributes\RequiresIntent;
use Ragnarok\Fenrir\Enums\Intent;
use Ragnarok\Fenrir\Parts\User;

/**
* @see https://discord.com/developers/docs/topics/gateway-events#guild-ban-add
*/
#[RequiresIntent(Intent::GUILD_MODERATION)]
class GuildBanAdd
{
public string $guild_id;
Expand Down
3 changes: 3 additions & 0 deletions src/Gateway/Events/GuildBanRemove.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

namespace Ragnarok\Fenrir\Gateway\Events;

use Ragnarok\Fenrir\Attributes\RequiresIntent;
use Ragnarok\Fenrir\Enums\Intent;
use Ragnarok\Fenrir\Parts\User;

/**
* @see https://discord.com/developers/docs/topics/gateway-events#guild-ban-remove
*/
#[RequiresIntent(Intent::GUILD_MODERATION)]
class GuildBanRemove
{
public string $guild_id;
Expand Down
3 changes: 3 additions & 0 deletions src/Gateway/Events/GuildCreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

namespace Ragnarok\Fenrir\Gateway\Events;

use Ragnarok\Fenrir\Attributes\RequiresIntent;
use Ragnarok\Fenrir\Enums\Gateway\Intents;
use Ragnarok\Fenrir\Parts\Guild;

/**
* @see https://discord.com/developers/docs/topics/gateway-events#guild-create
*/
#[RequiresIntent(Intents::GUILDS)]
class GuildCreate extends Guild
{
}
3 changes: 3 additions & 0 deletions src/Gateway/Events/GuildDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

namespace Ragnarok\Fenrir\Gateway\Events;

use Ragnarok\Fenrir\Attributes\RequiresIntent;
use Ragnarok\Fenrir\Enums\Gateway\Intents;
use Ragnarok\Fenrir\Parts\Guild;

/**
* @see https://discord.com/developers/docs/topics/gateway-events#guild-delete
*/
#[RequiresIntent(Intents::GUILDS)]
class GuildDelete extends Guild
{
}
4 changes: 4 additions & 0 deletions src/Gateway/Events/GuildEmojisUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@

namespace Ragnarok\Fenrir\Gateway\Events;

use Ragnarok\Fenrir\Attributes\RequiresIntent;
use Ragnarok\Fenrir\Enums\Gateway\Intents;

/**
* @see https://discord.com/developers/docs/topics/gateway-events#guild-emojis-update
*/
#[RequiresIntent(Intents::GUILD_EMOJIS_AND_STICKERS)]
class GuildEmojisUpdate
{
public string $guild_id;
Expand Down
4 changes: 4 additions & 0 deletions src/Gateway/Events/GuildIntegrationsUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@

namespace Ragnarok\Fenrir\Gateway\Events;

use Ragnarok\Fenrir\Attributes\RequiresIntent;
use Ragnarok\Fenrir\Enums\Gateway\Intents;

/**
* @see https://discord.com/developers/docs/topics/gateway-events#guild-integrations-update
*/
#[RequiresIntent(Intents::GUILD_INTEGRATIONS)]
class GuildIntegrationsUpdate
{
public string $guild_id;
Expand Down
5 changes: 3 additions & 2 deletions src/Gateway/Events/GuildMemberAdd.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

namespace Ragnarok\Fenrir\Gateway\Events;

use Ragnarok\Fenrir\Attributes\Intent;
use Ragnarok\Fenrir\Attributes\RequiresIntent;
use Ragnarok\Fenrir\Enums\Intent;
use Ragnarok\Fenrir\Parts\GuildMember;

/**
* @see https://discord.com/developers/docs/topics/gateway-events#guild-member-add
*/
#[Intent("GUILD_MEMBERS")]
#[RequiresIntent(Intent::GUILD_MEMBERS)]
class GuildMemberAdd extends GuildMember
{
public string $guild_id;
Expand Down
5 changes: 3 additions & 2 deletions src/Gateway/Events/GuildMemberRemove.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

namespace Ragnarok\Fenrir\Gateway\Events;

use Ragnarok\Fenrir\Attributes\Intent;
use Ragnarok\Fenrir\Attributes\RequiresIntent;
use Ragnarok\Fenrir\Enums\Intent;
use Ragnarok\Fenrir\Parts\User;

/**
* @see https://discord.com/developers/docs/topics/gateway-events#guild-member-remove
*/
#[Intent("GUILD_MEMBERS")]
#[RequiresIntent(Intent::GUILD_MEMBERS)]
class GuildMemberRemove
{
public string $guild_id;
Expand Down
3 changes: 3 additions & 0 deletions src/Gateway/Events/GuildMemberUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
namespace Ragnarok\Fenrir\Gateway\Events;

use Carbon\Carbon;
use Ragnarok\Fenrir\Attributes\RequiresIntent;
use Ragnarok\Fenrir\Enums\Intent;
use Ragnarok\Fenrir\Parts\User;

/**
* @see https://discord.com/developers/docs/topics/gateway-events#guild-member-update
*/
#[RequiresIntent(Intent::GUILD_MEMBERS)]
class GuildMemberUpdate
{
public string $guild_id;
Expand Down
3 changes: 3 additions & 0 deletions src/Gateway/Events/GuildRoleCreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

namespace Ragnarok\Fenrir\Gateway\Events;

use Ragnarok\Fenrir\Attributes\RequiresIntent;
use Ragnarok\Fenrir\Enums\Intent;
use Ragnarok\Fenrir\Parts\Role;

/**
* @see https://discord.com/developers/docs/topics/gateway-events#guild-role-create
*/
#[RequiresIntent(Intent::GUILDS)]
class GuildRoleCreate
{
public string $guild_id;
Expand Down
4 changes: 4 additions & 0 deletions src/Gateway/Events/GuildRoleDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@

namespace Ragnarok\Fenrir\Gateway\Events;

use Ragnarok\Fenrir\Attributes\RequiresIntent;
use Ragnarok\Fenrir\Enums\Intent;

/**
* @see https://discord.com/developers/docs/topics/gateway-events#guild-role-delete
*/
#[RequiresIntent(Intent::GUILD_MEMBERS)]
class GuildRoleDelete
{
public string $guild_id;
Expand Down
3 changes: 3 additions & 0 deletions src/Gateway/Events/GuildRoleUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

namespace Ragnarok\Fenrir\Gateway\Events;

use Ragnarok\Fenrir\Attributes\RequiresIntent;
use Ragnarok\Fenrir\Enums\Intent;
use Ragnarok\Fenrir\Parts\Role;

/**
* @see https://discord.com/developers/docs/topics/gateway-events#guild-role-update
*/
#[RequiresIntent(Intent::GUILD_MEMBERS)]
class GuildRoleUpdate
{
public string $guild_id;
Expand Down
3 changes: 3 additions & 0 deletions src/Gateway/Events/GuildScheduledEventCreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

namespace Ragnarok\Fenrir\Gateway\Events;

use Ragnarok\Fenrir\Attributes\RequiresIntent;
use Ragnarok\Fenrir\Enums\Intent;
use Ragnarok\Fenrir\Parts\GuildScheduledEvent;

/**
* @see https://discord.com/developers/docs/topics/gateway-events#guild-scheduled-event-create
*/
#[RequiresIntent(Intent::GUILD_SCHEDULED_EVENTS)]
class GuildScheduledEventCreate extends GuildScheduledEvent
{
}
3 changes: 3 additions & 0 deletions src/Gateway/Events/GuildScheduledEventDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

namespace Ragnarok\Fenrir\Gateway\Events;

use Ragnarok\Fenrir\Attributes\RequiresIntent;
use Ragnarok\Fenrir\Enums\Intent;
use Ragnarok\Fenrir\Parts\GuildScheduledEvent;

/**
* @see https://discord.com/developers/docs/topics/gateway-events#guild-scheduled-event-delete
*/
#[RequiresIntent(Intent::GUILD_SCHEDULED_EVENTS)]
class GuildScheduledEventDelete extends GuildScheduledEvent
{
}
Loading

0 comments on commit c47cfd9

Please sign in to comment.