Skip to content

Commit

Permalink
Update | Beta 5.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
gncdev committed Aug 14, 2020
1 parent eff8328 commit 10ce3e2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/Bot.php
Original file line number Diff line number Diff line change
Expand Up @@ -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-*."é~,;<>';
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Command/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
39 changes: 15 additions & 24 deletions src/Model/EventListener/EventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
*
Expand All @@ -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);
});
}
Expand Down

0 comments on commit 10ce3e2

Please sign in to comment.