Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
public function up(): void
{
if (! Schema::hasTable('messages')) {
if (!Schema::hasTable('messages')) {
Schema::create('messages', function (Blueprint $table): void {
$table->uuid('id')->primary();
$table->foreignUuid('provider_id')->constrained('providers');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{
public function up(): void
{
if (! Schema::hasTable('voice_messages')) {
if (!Schema::hasTable('voice_messages')) {
Schema::create('voice_messages', function (Blueprint $table): void {
$table->id();
$table->foreignUuid('provider_id')->constrained('providers');
Expand Down
2 changes: 2 additions & 0 deletions app-modules/activity/phpstan.ignore.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
parameters:
ignoreErrors: []
6 changes: 6 additions & 0 deletions app-modules/activity/phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
includes:
- phpstan.ignore.neon

parameters:
paths:
- src/
3 changes: 3 additions & 0 deletions app-modules/activity/src/Actions/NewVoiceMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ public function __construct(
private IncrementExperience $characterExperience,
) {}

/**
* @param array<string, mixed> $payload
*/
public function persist(array $payload): void
{
$voiceDTO = NewVoiceMessageDTO::make($payload);
Expand Down
3 changes: 3 additions & 0 deletions app-modules/activity/src/DTOs/NewMessageDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public function __construct(
public DateTimeImmutable $sentAt,
) {}

/**
* @param array<string, mixed> $payload
*/
public static function make(array $payload): self
{
return new self(
Expand Down
3 changes: 3 additions & 0 deletions app-modules/activity/src/DTOs/NewVoiceMessageDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public function __construct(
public string $channelName,
) {}

/**
* @param array<string, mixed> $payload
*/
public static function make(array $payload): self
{
return new self(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Http\Controllers\Controller;
use He4rt\Activity\Actions\NewMessage;
use He4rt\Activity\Actions\NewVoiceMessage;
use He4rt\Activity\DTOs\NewMessageDTO;
use He4rt\Activity\Http\Requests\CreateMessageRequest;
use He4rt\Activity\Http\Requests\CreateVoiceMessageRequest;
use Illuminate\Http\Response;
Expand All @@ -18,7 +19,7 @@ public function postMessage(
string $provider,
NewMessage $newMessage,
): Response {
$newMessage->persist($request->validated());
$newMessage->persist(NewMessageDTO::make($request->validated()));

return response()->noContent();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public function authorize(): bool
return true;
}

/**
* @return array<string, mixed>
*/
public function rules(): array
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public function authorize(): bool
return true;
}

/**
* @return array<string, mixed>
*/
public function rules(): array
{
return [
Expand Down
1 change: 1 addition & 0 deletions app-modules/activity/src/Models/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

final class Message extends Model
{
/** @use HasFactory<MessageFactory> */
use HasFactory;
use HasUuids;

Expand Down
50 changes: 50 additions & 0 deletions app-modules/bot-discord/phpstan.ignore.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
parameters:
ignoreErrors:
- message: '#^Access\ to\ an\ undefined\ property\ Discord\\Parts\\Guild\\Guild::\$icon\.$#'
identifier: property.notFound
count: 1
path: src/SlashCommands/DontAskCommand.php
- message: '#^Access\ to\ an\ undefined\ property\ Discord\\Parts\\Guild\\Guild::\$icon\.$#'
identifier: property.notFound
count: 1
path: src/SlashCommands/EditProfileCommand.php
- message: '#^Access\ to\ an\ undefined\ property\ Discord\\Parts\\Guild\\Guild::\$icon\.$#'
identifier: property.notFound
count: 1
path: src/SlashCommands/IntroductionCommand.php
- message: '#^Access\ to\ an\ undefined\ property\ Discord\\Parts\\Guild\\Guild::\$icon\.$#'
identifier: property.notFound
count: 1
path: src/SlashCommands/ProfileCommand.php
- message: '#^Access\ to\ an\ undefined\ property\ Discord\\Parts\\User\\Member::\$user\.$#'
identifier: property.notFound
count: 7
path: src/Events/WelcomeMember.php
- message: '#^Access\ to\ an\ undefined\ property\ Discord\\Parts\\User\\User::\$avatar\.$#'
identifier: property.notFound
count: 1
path: src/SlashCommands/EditProfileCommand.php
- message: '#^Access\ to\ an\ undefined\ property\ Discord\\Parts\\User\\User::\$avatar\.$#'
identifier: property.notFound
count: 2
path: src/SlashCommands/IntroductionCommand.php
- message: '#^Access\ to\ an\ undefined\ property\ Discord\\Parts\\WebSockets\\VoiceStateUpdate::\$channel_id\.$#'
identifier: property.notFound
count: 1
path: src/Events/DynamicVoiceEvent.php
- message: '#^Method\ He4rt\\BotDiscord\\Tasks\\RichPresence::makeActivities\(\)\ should\ return\ array<Discord\\Parts\\User\\Activity>\ but\ returns\ array<int,\ Discord\\Parts\\Part\|Discord\\Repository\\AbstractRepository>\.$#'
identifier: return.type
count: 1
path: src/Tasks/RichPresence.php
- message: '#^Parameter\ \#1\ \$guild\ of\ method\ Discord\\Repository\\Guild\\ChannelRepository::build\(\)\ expects\ Discord\\Repository\\Guild\\Guild\|string,\ Discord\\Parts\\Guild\\Guild\|null\ given\.$#'
identifier: argument.type
count: 1
path: src/SlashCommands/DynamicVoiceCommand.php
- message: '#^Unable\ to\ resolve\ the\ template\ type\ TKey\ in\ call\ to\ function\ collect$#'
identifier: argument.templateType
count: 1
path: src/SlashCommands/EditVoiceChannelLimitCommand.php
- message: '#^Unable\ to\ resolve\ the\ template\ type\ TValue\ in\ call\ to\ function\ collect$#'
identifier: argument.templateType
count: 1
path: src/SlashCommands/EditVoiceChannelLimitCommand.php
6 changes: 6 additions & 0 deletions app-modules/bot-discord/phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
includes:
- phpstan.ignore.neon

parameters:
paths:
- src/
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,19 @@ public function execute(int|string $userId, ?string $channelId): void

private function isMovingBetweenChannels(?string $newChannelId, ?string $oldChannelId): bool
{
return ! is_null($newChannelId)
&& ! is_null($oldChannelId)
return !is_null($newChannelId)
&& !is_null($oldChannelId)
&& $oldChannelId !== $newChannelId;
}

private function isLeavingVoice(?string $newChannelId, ?string $oldChannelId): bool
{
return is_null($newChannelId) && ! is_null($oldChannelId);
return is_null($newChannelId) && !is_null($oldChannelId);
}

private function isJoiningChannel(?string $channelId, ?string $oldChannelId): bool
{
return ! is_null($channelId) && is_null($oldChannelId);
return !is_null($channelId) && is_null($oldChannelId);
}

private function getUserLastChannel(string $userId): ?string
Expand All @@ -92,6 +92,6 @@ private function clearUserLastChannel(string $userId): void

private function isUpdatingInSameChannel(?string $newChannelId, ?string $oldChannelId): bool
{
return ! is_null($newChannelId) && $oldChannelId === $newChannelId;
return !is_null($newChannelId) && $oldChannelId === $newChannelId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@

final class JoiningChannelAction
{
public function execute(string $channelId, array $activeChannels, $user): void
/**
* @param array<string, mixed> $activeChannels
*/
public function execute(string $channelId, array $activeChannels, string $user): void
{
foreach ($activeChannels as $index => $channel) {
/** @var VoiceChannelDTO $channel */
Expand All @@ -23,6 +26,9 @@ public function execute(string $channelId, array $activeChannels, $user): void
}
}

/**
* @param array<string, mixed> $activeChannels
*/
private function saveActiveChannels(array $activeChannels): void
{
cache()->tags(['voice_channels'])->put('active_voice_channels_keys', $activeChannels);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@

final class LeftChannelAction
{
public function execute(array $activeChannels, $user): void
/**
* @param array<string, mixed> $activeChannels
*/
public function execute(array $activeChannels, string $user): void
{
foreach ($activeChannels as $index => $channel) {
/** @var VoiceChannelDTO $channel */
Expand All @@ -22,6 +25,9 @@ public function execute(array $activeChannels, $user): void
}
}

/**
* @param array<string, mixed> $activeChannels
*/
private function saveActiveChannels(array $activeChannels): void
{
cache()->tags(['voice_channels'])->put('active_voice_channels_keys', $activeChannels);
Expand Down
4 changes: 4 additions & 0 deletions app-modules/bot-discord/src/Commands/PingCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class PingCommand extends Command

/**
* Handle the command.
*
* @param array<mixed> $args
*/
public function handle(Message $message, array $args): void
{
Expand All @@ -53,6 +55,8 @@ public function handle(Message $message, array $args): void

/**
* The command interaction routes.
*
* @return array<mixed>
*/
public function interactions(): array
{
Expand Down
4 changes: 4 additions & 0 deletions app-modules/bot-discord/src/DTO/VoiceChannelDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ public function __construct(
public readonly string $channelId,
public readonly string $ownerId,
public int $usersCount,
/** @var array<string, mixed> */
public array $users,
public ?CarbonInterface $lastJoinedAt = null,
) {}

/**
* @param array<string, mixed> $data
*/
public static function make(array $data): self
{
return new self(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ protected function processMiddleware(Interaction $interaction): mixed
]));
}

/** @return Builder<ExternalIdentity> */
protected function getMemberProviderQuery(): Builder
{
return ExternalIdentity::query()
Expand Down
12 changes: 6 additions & 6 deletions app-modules/bot-discord/src/SlashCommands/CargoDelasCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class CargoDelasCommand extends SlashCommand
/**
* The command options.
*
* @var array
* @var array<mixed>
*/
protected $options = [
[
Expand All @@ -43,7 +43,7 @@ class CargoDelasCommand extends SlashCommand
/**
* The permissions required to use the command.
*
* @var array
* @var array<mixed>
*/
protected $permissions = [];

Expand Down Expand Up @@ -71,7 +71,7 @@ public function handle(Interaction $interaction): void
$hasComiteRole = $interaction->member->roles
->find(fn (Role $role) => $role->id === $comiteRoleId);

if (! $hasComiteRole) {
if (!$hasComiteRole) {
$interaction->respondWithMessage('❌ Você não tem permissão para usar este comando.', true);

return;
Expand All @@ -80,7 +80,7 @@ public function handle(Interaction $interaction): void
$targetUserId = $this->value('user');
$targetMember = $this->validateTarget($interaction, $targetUserId);

if (! $targetMember instanceof Member) {
if (!$targetMember instanceof Member) {
return;
}

Expand Down Expand Up @@ -111,7 +111,7 @@ private function validateTarget(Interaction $interaction, string $targetUserId):
{
$targetMember = $interaction->guild->members->get('id', $targetUserId);

if (! $targetMember) {
if (!$targetMember) {
$interaction->respondWithMessage('❌ Usuário mencionado não foi encontrado no servidor.', true);

return null;
Expand All @@ -127,7 +127,7 @@ private function validateTarget(Interaction $interaction, string $targetUserId):
$targetHasPresentation = $targetMember->roles
->find(fn (Role $role) => $role->id === $presentationRoleId);

if (! $targetHasPresentation) {
if (!$targetHasPresentation) {
$username = $targetMember->user->username ?? 'usuário';
$interaction->respondWithMessage(sprintf('❌ @%s precisa se apresentar primeiro (/apresentar).', $username), true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class DontAskCommand extends SlashCommand
/**
* The slash command options.
*
* @var array
* @var array<mixed>
*/
protected $options = [
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ class DynamicVoiceCommand extends SlashCommand
/**
* The command options.
*
* @var array
* @var array<mixed>
*/
protected $options = [];

/**
* The permissions required to use the command.
*
* @var array
* @var array<mixed>
*/
protected $permissions = [];

Expand Down Expand Up @@ -90,6 +90,9 @@ public function handle(Interaction $interaction): void
$this->interactionWithUser($interaction, $channel);
}

/**
* @return array<mixed>
*/
public function options(): array
{
return [
Expand All @@ -110,6 +113,9 @@ public function options(): array
];
}

/**
* @return array<mixed>
*/
private function getVoiceChoices(): array
{
$items = [
Expand Down
Loading