Skip to content

Commit 01ee060

Browse files
authored
chore: restore bot intents, rename token env (#599)
1 parent 1a4ff88 commit 01ee060

16 files changed

Lines changed: 366 additions & 356 deletions

File tree

‎.env.example‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ VITE_PUSHER_PORT="${PUSHER_PORT}"
9797
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
9898
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
9999

100-
DISCORD_TOKEN=
100+
DISCORD_BOT_TOKEN=
101101
GITHUB_WEBHOOK_SECRET=
102102
GITHUB_API_TOKEN=
103103

‎.env.testing.example‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ AWS_USE_PATH_STYLE_ENDPOINT=false
8080

8181
VITE_APP_NAME="${APP_NAME}"
8282

83-
DISCORD_TOKEN=
83+
DISCORD_BOT_TOKEN=
8484

8585
# API mobile (he4rt-app) — valor fixo, não é segredo de produção.
8686
JWT_SECRET=testing-jwt-secret-do-not-use-in-production

‎app-modules/bot-discord/phpstan.ignore.neon‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ parameters:
2424
message: '#^Parameter \#1 \$roles of method Discord\\Parts\\Guild\\Member\\Member::setRoles\(\) expects#'
2525
identifier: argument.type
2626
count: 1
27-
path: src/Disabled/SlashCommands/CargoDelasCommand.php
27+
path: src/SlashCommands/CargoDelasCommand.php
2828
-
2929
message: '#^Parameter \#1 \$roles of method Discord\\Parts\\Guild\\Member\\Member::setRoles\(\) expects#'
3030
identifier: argument.type

‎app-modules/bot-discord/src/Events/GreetingsEvent.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ class GreetingsEvent extends Event
2424
public function handle(Message $message, Discord $discord): void
2525
{
2626
$mentionsBot = $message->mentions->get('id', $discord->id) !== null;
27+
$mentionsNobody = $message->mentions->count() === 0;
28+
$isAddressedToSomeoneElse = !$mentionsBot && !$mentionsNobody;
2729

28-
if ($message->author->bot || !$mentionsBot) {
30+
if ($message->author->bot || $isAddressedToSomeoneElse) {
2931
return;
3032
}
3133

app-modules/bot-discord/src/Disabled/Events/MessageReceivedEvent.php renamed to app-modules/bot-discord/src/Events/MessageReceivedEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace He4rt\BotDiscord\Disabled\Events;
5+
namespace He4rt\BotDiscord\Events;
66

77
use Discord\Parts\Channel\Message;
88
use Discord\WebSockets\Event as Events;

app-modules/bot-discord/src/Disabled/Events/WelcomeMember.php renamed to app-modules/bot-discord/src/Events/WelcomeMember.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace He4rt\BotDiscord\Disabled\Events;
5+
namespace He4rt\BotDiscord\Events;
66

77
use Discord\Discord;
88
use Discord\Parts\Guild\Member\Member;

app-modules/bot-discord/src/Disabled/SlashCommands/CargoDelasCommand.php renamed to app-modules/bot-discord/src/SlashCommands/CargoDelasCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
declare(strict_types=1);
44

5-
namespace He4rt\BotDiscord\Disabled\SlashCommands;
5+
namespace He4rt\BotDiscord\SlashCommands;
66

77
use Discord\Parts\Guild\Member\Member;
88
use Discord\Parts\Guild\Role\Role;
99
use Discord\Parts\Interactions\Command\Option;
1010
use Discord\Parts\Interactions\Interaction;
11-
use He4rt\BotDiscord\SlashCommands\AbstractSlashCommand;
1211

1312
class CargoDelasCommand extends AbstractSlashCommand
1413
{

‎app-modules/bot-discord/tests/Unit/Events/GreetingsEventTest.php‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ function greetingsMessage(Discord $discord, string $content, array $mentionedIds
5858
GreetingsEvent::make()->handle($message, $this->discord);
5959
});
6060

61+
it('greets a member who mentions nobody', function (): void {
62+
$message = greetingsMessage($this->discord, 'bom dia', []);
63+
$message->shouldReceive('reply')->once()->with('Bom dia!');
64+
65+
GreetingsEvent::make()->handle($message, $this->discord);
66+
});
67+
6168
it('ignores a greeting that does not mention the bot', function (): void {
6269
$message = greetingsMessage($this->discord, sprintf('<@%s> bom dia', GREETINGS_OTHER_BOT_ID), [GREETINGS_OTHER_BOT_ID]);
6370
$message->shouldNotReceive('reply');

‎app-modules/integration-discord/config/integration-discord.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
declare(strict_types=1);
44

55
return [
6-
'token' => env('DISCORD_TOKEN'),
6+
'token' => env('DISCORD_BOT_TOKEN'),
77
];

‎app/Console/Commands/FetchDiscordMembers.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function handle(): void
2121
$guildId = config('he4rt.discord.guild_id');
2222

2323
if (!$token) {
24-
$this->error('Discord bot token not configured (HE4RT_DISCORD_BOT_KEY).');
24+
$this->error('Discord bot token not configured (DISCORD_BOT_TOKEN).');
2525

2626
return;
2727
}

0 commit comments

Comments
 (0)