public function listen()
    {
        $this->Discord->on('ready', function ($discord) {
            $discord->on('message', function ($message) {
                if ($this->Discord->id === $message->author->id) {
                    return;
                }

                $content = Message::parse($message->content);
                $wrapper = Wrapper::getInstance()->setInstances($message, $this->ModuleManager);

                //Handle the type of the message.
                //Note : The order is very important !
                if ($wrapper->Channel->is_private === true) {
                    $this->ModuleManager->onPrivateMessage($wrapper, $content);
                } elseif ($content['commandCode'] === Configure::read('Command.prefix') &&
                            isset(Configure::read('Commands')[$content['command']])) {
                    $command = Configure::read('Commands')[$content['command']];

                    if ((isset($command['admin']) && $command['admin'] === true) &&
                            !User::hasPermission($wrapper->Message->author->id, Configure::read('Bot.admins'))) {
                        $wrapper->Message->reply('You are not administrator of the bot.');

                        return;
                    }

                    if (count($content['arguments']) < $command['params']) {
                        $wrapper->Message->reply(Command::syntax($content));

                        return;
                    }

                    $this->ModuleManager->onCommandMessage($wrapper, $content);
                } else {
                    $this->ModuleManager->onChannelMessage($wrapper, $content);
                }
            });
        });
    }
public function listen()
    {
        $this->Discord->on('ready', function ($discord) {
            $discord->on('message', function ($message) {
                if ($this->Discord->id === $message->author->id) {
                    return;
                }

                $content = Message::parse($message->content);
                $wrapper = Wrapper::getInstance()->setInstances($message, $this->ModuleManager);

                //Handle the type of the message.
                //Note : The order is very important !
                if ($wrapper->Channel->is_private === true) {
                    $this->ModuleManager->onPrivateMessage($wrapper, $content);
                } elseif ($content['commandCode'] === Configure::read('Command.prefix') &&
                            isset(Configure::read('Commands')[$content['command']])) {
                    $command = Configure::read('Commands')[$content['command']];

                    if ((isset($command['admin']) && $command['admin'] === true) &&
                            !User::hasPermission($wrapper->Message->author->id, Configure::read('Bot.admins'))) {
                        $wrapper->Message->reply('You are not administrator of the bot.');

                        return;
                    }

                    if (count($content['arguments']) < $command['params']) {
                        $wrapper->Message->reply(Command::syntax($content));

                        return;
                    }

                    $this->ModuleManager->onCommandMessage($wrapper, $content);
                } else {
                    $this->ModuleManager->onChannelMessage($wrapper, $content);
                }
            });
        });
    }
public function listen ( ) { $ this -> Discord -> on ( 'ready' , function ( $ discord ) { $ discord -> on ( 'message' , function ( $ message ) { if ( $ this -> Discord -> id === $ message -> author -> id ) { return ; } $ content = Message :: parse ( $ message -> content ) ; $ wrapper = Wrapper :: getInstance ( ) -> setInstances ( $ message , $ this -> ModuleManager ) ; //Handle the type of the message. //Note : The order is very important ! if ( $ wrapper -> Channel -> is_private === true ) { $ this -> ModuleManager -> onPrivateMessage ( $ wrapper , $ content ) ; } elseif ( $ content [ 'commandCode' ] === Configure :: read ( 'Command.prefix' ) && isset ( Configure :: read ( 'Commands' ) [ $ content [ 'command' ] ] ) ) { $ command = Configure :: read ( 'Commands' ) [ $ content [ 'command' ] ] ; if ( ( isset ( $ command [ 'admin' ] ) && $ command [ 'admin' ] === true ) && ! User :: hasPermission ( $ wrapper -> Message -> author -> id , Configure :: read ( 'Bot.admins' ) ) ) { $ wrapper -> Message -> reply ( 'You are not administrator of the bot.' ) ; return ; } if ( count ( $ content [ 'arguments' ] ) < $ command [ 'params' ] ) { $ wrapper -> Message -> reply ( Command :: syntax ( $ content ) ) ; return ; } $ this -> ModuleManager -> onCommandMessage ( $ wrapper , $ content ) ; } else { $ this -> ModuleManager -> onChannelMessage ( $ wrapper , $ content ) ; } } ) ; } ) ; }
Handle the events.

@return void
Handle the events .