From 10ce3e28257401a73da7147a53aeedcad04c45ea Mon Sep 17 00:00:00 2001 From: GianC-Dev Date: Fri, 14 Aug 2020 14:59:18 +0300 Subject: [PATCH] Update | Beta 5.0.3 --- src/Bot.php | 2 +- src/Model/Command/Command.php | 2 +- src/Model/EventListener/EventListener.php | 39 +++++++++-------------- 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/src/Bot.php b/src/Bot.php index 38bcc5b..a36786e 100644 --- a/src/Bot.php +++ b/src/Bot.php @@ -105,7 +105,7 @@ class Bot * @param string $callback_name Dispatch name * @param string|Callable $callback Callback to execute when dispatching action */ - public function addDispatch($type, $callback_name, $callback) + public function addDispatch($type, $callback) { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-*."é~,;<>'; diff --git a/src/Model/Command/Command.php b/src/Model/Command/Command.php index 9e2982d..ecdfb1b 100644 --- a/src/Model/Command/Command.php +++ b/src/Model/Command/Command.php @@ -35,7 +35,7 @@ abstract class Command */ public function __construct($bot, $command_name) { - $bot->addDispatch('MESSAGE_CREATE', $command_name, function ($json) use ($command_name, $bot) { + $bot->addDispatch('MESSAGE_CREATE', function ($json) use ($command_name, $bot) { $this->json = $json->d; if (str_starts_with($json->d->content, $bot->prefix . $command_name)) { $res = $this->execute($json->d, $bot); diff --git a/src/Model/EventListener/EventListener.php b/src/Model/EventListener/EventListener.php index 61cd856..f913c98 100644 --- a/src/Model/EventListener/EventListener.php +++ b/src/Model/EventListener/EventListener.php @@ -21,15 +21,6 @@ abstract class EventListener */ public $token; - private function generateRandomString($length = 10) { - $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; - $charactersLength = strlen($characters); - $randomString = ''; - for ($i = 0; $i < $length; $i++) { - $randomString .= $characters[rand(0, $charactersLength - 1)]; - } - return $randomString; - } /** * @@ -39,50 +30,50 @@ public function __construct($bot) { $this->bot = $bot; $this->token = $bot->getToken(); - $bot->addDispatch('GUILD_CREATE',$this->generateRandomString(), function ($json) { + $bot->addDispatch('GUILD_CREATE', function ($json) { $this->onGuildJoin($json->d, $this->bot); }); - $bot->addDispatch('GUILD_MEMBER_ADD',$this->generateRandomString(), function ($json) { + $bot->addDispatch('GUILD_MEMBER_ADD', function ($json) { $this->onGuildMemberAdd($json->d, $this->bot); }); - $bot->addDispatch('GUILD_MEMBER_UPDATE',$this->generateRandomString(), function ($json) { + $bot->addDispatch('GUILD_MEMBER_UPDATE', function ($json) { $this->onGuildMemberUpdate($json->d, $this->bot); }); - $bot->addDispatch('GUILD_MEMBER_DELETE',$this->generateRandomString(), function ($json) { + $bot->addDispatch('GUILD_MEMBER_DELETE', function ($json) { $this->onGuildMemberDelete($json->d, $this->bot); }); - $bot->addDispatch('GUILD_UPDATE',$this->generateRandomString(), function ($json) { + $bot->addDispatch('GUILD_UPDATE', function ($json) { $this->onGuildDelete($json->d, $this->bot); }); - $bot->addDispatch('GUILD_DELETE',$this->generateRandomString(), function ($json) { + $bot->addDispatch('GUILD_DELETE', function ($json) { $this->onGuildUpdate($json->d, $this->bot); }); - $bot->addDispatch('GUILD_ROLE_CREATE',$this->generateRandomString(), function ($json) { + $bot->addDispatch('GUILD_ROLE_CREATE', function ($json) { $this->onGuildRoleCreate($json->d, $this->bot); }); - $bot->addDispatch('GUILD_ROLE_UPDATE',$this->generateRandomString(), function ($json) { + $bot->addDispatch('GUILD_ROLE_UPDATE', function ($json) { $this->onGuildRoleUpdate($json->d, $this->bot); }); - $bot->addDispatch('GUILD_ROLE_DELETE',$this->generateRandomString(), function ($json) { + $bot->addDispatch('GUILD_ROLE_DELETE', function ($json) { $this->onGuildRoleDelete($json->d, $this->bot); }); - $bot->addDispatch('MESSAGE_CREATE',$this->generateRandomString(), function ($json) { + $bot->addDispatch('MESSAGE_CREATE', function ($json) { $this->onMessageCreate($json->d, $this->bot); }); - $bot->addDispatch('CHANNEL_CREATE',$this->generateRandomString(), function ($json) { + $bot->addDispatch('CHANNEL_CREATE', function ($json) { $this->onChannelCreate($json->d, $this->bot); }); - $bot->addDispatch('CHANNEL_UPDATE',$this->generateRandomString(), function ($json) { + $bot->addDispatch('CHANNEL_UPDATE', function ($json) { $this->onChannelUpdate($json->d, $this->bot); }); - $bot->addDispatch('CHANNEL_DELETE',$this->generateRandomString(), function ($json) { + $bot->addDispatch('CHANNEL_DELETE', function ($json) { $this->onChannelDelete($json->d, $this->bot); }); - $bot->addDispatch('CHANNEL_PINS_UPDATE',$this->generateRandomString(), function ($json) { + $bot->addDispatch('CHANNEL_PINS_UPDATE', function ($json) { $this->onChannelPinsUpdate($json->d, $this->bot); }); - $bot->addDispatch('READY',$this->generateRandomString(), function ($json) { + $bot->addDispatch('READY', function ($json) { $this->onReady($json->d, $this->bot); }); }