From 3b1b7f94d6f4cbaf4a8ca332b84342cccc6d4632 Mon Sep 17 00:00:00 2001 From: Dany Thach Date: Sun, 31 Oct 2021 20:13:59 +0100 Subject: [PATCH] Colors added - Now it MUST work --- src/Toadling.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Toadling.php b/src/Toadling.php index 794137f..e5bf1fe 100644 --- a/src/Toadling.php +++ b/src/Toadling.php @@ -56,15 +56,20 @@ class Toadling if($messageWords[1] !== 'color') { return false; } - $color = strtoupper($messageWords[2]); - if(preg_match('/^#[0-9A-F]{6}$/', $color) !== 1) { - return false; + $color = strtolower($messageWords[2]); + $colorInt = intval(substr($color, 1), 16); + if(preg_match('/^#[0-9a-f]{6}$/', $color) !== 1) { + $color = strtolower($color); + if(!array_key_exists($color, \Discord\COLORTABLE)) { + return false; + } + $colorInt = \Discord\COLORTABLE[$color]; + $color = '#'.dechex($colorInt); } $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); if(null !== $colorRole) { $message->member->addRole($colorRole); $message->delete();