From 027bb15b41eba357661a3a8a88f2f168b57348f9 Mon Sep 17 00:00:00 2001 From: Dany Thach Date: Sun, 31 Oct 2021 18:04:48 +0100 Subject: [PATCH] Bugfix: Message guild returns null? --- src/Toadling.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Toadling.php b/src/Toadling.php index ad517ac..4d2c563 100644 --- a/src/Toadling.php +++ b/src/Toadling.php @@ -48,7 +48,8 @@ class Toadling if('902654364685074522' !== $message->guild_id) { return false; } - preg_match_all('/[^\s]+/', $message->content, $messageWords); + preg_match_all('/[^\s]+/', $message->content, $matches); + $messageWords = $matches[0]; if($messageWords[0] !== '!'.self::COMMAND_NAME) { return false; } @@ -59,7 +60,8 @@ class Toadling if(preg_match('/^#[0-9A-F]{6}$/', $color) !== 1) { return false; } - $colorRole = $message->guild->roles->find(function (Role $role) use ($color) { + $guild = $discord->guilds->get('id', '902654364685074522'); + $colorRole = $guild->roles->find(function (Role $role) use ($color) { return $role->name === $color; }); $colorInt = intval(substr($color, 1), 16);