discord-php / DiscordPHP

An API to interact with the popular messaging app Discord
MIT License
985 stars 236 forks source link

Bot crashes after one reply #107

Closed glieske closed 8 years ago

glieske commented 8 years ago
PHP Notice:  Indirect modification of overloaded property Discord\Parts\Channel\Channel::$members has no effect in /var/bot/vendor/team-reflex/discord-php/src/Discord/WebSockets/Events/GuildCreate.php on line 88
PHP Notice:  Indirect modification of overloaded property Discord\Parts\Channel\Channel::$members has no effect in /var/bot/vendor/team-reflex/discord-php/src/Discord/WebSockets/Events/GuildCreate.php on line 88
Discord WebSocket is ready!
PHP Notice:  Indirect modification of overloaded property Discord\Parts\Channel\Channel::$messages has no effect in /var/bot/vendor/team-reflex/discord-php/src/Discord/WebSockets/Events/MessageCreate.php on line 43
PHP Fatal error:  Uncaught Error: Call to a member function push() on null in /var/bot/vendor/team-reflex/discord-php/src/Discord/Parts/Channel/Channel.php:412
Stack trace:
#0 /var/bot/vendor/team-reflex/discord-php/src/Discord/Parts/Channel/Message.php(80): Discord\Parts\Channel\Channel->sendMessage('<@1097394306962...')
#1 /var/bot/app/init.php(46): Discord\Parts\Channel\Message->reply('pong!')
#2 [internal function]: {closure}(Object(Discord\Parts\Channel\Message), Object(Discord\Discord), Object(Discord\Discord), Object(Discord\WebSockets\WebSocket))
#3 /var/bot/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(64): call_user_func_array(Object(Closure), Array)
#4 /var/bot/vendor/team-reflex/discord-php/src/Discord/WebSockets/WebSocket.php(777): Evenement\EventEmitter->emit('MESSAGE_CREATE', Array)
#5 /var/bot/vendor/team-reflex/discord-php/src/Discord/WebSockets/WebSocket.php(286): Discord\WebSockets\WebSocket in /var/bot/vendor/team-reflex/discord-php/src/Discord/Parts/Channel/Channel.php on line 412

PHP : PHP 7.0.6-1+donate.sury.org~xenial+1 (cli) ( NTS ) Distributor ID: Ubuntu Description: Ubuntu 16.04 LTS Release: 16.04 Codename: xenial

init.php is almost the same as basic.php from examples

bot answers one time, after that crashes

davidcole1340 commented 8 years ago

Don't think this is happening anymore, talk to us in the Discord API server if it still does.

haolink commented 8 years ago

I'm having exactly the same issue:

PHP Fatal error:  Uncaught Error: Call to a member function push() on null in /srv/link/mikubot/mikubot/vendor/team-reflex/discord-php/src/Discord/Parts/Channel/Channel.php:436
Stack trace:
#0 /srv/link/mikubot/mikubot/vendor/team-reflex/discord-php/src/Discord/Parts/Channel/Message.php(81): Discord\Parts\Channel\Channel->sendMessage('<@1473357399217...')
#1 /srv/link/mikubot/mikubot/src/bot.php(57): Discord\Parts\Channel\Message->reply('pong!')
#2 [internal function]: {closure}(Object(Discord\Parts\Channel\Message), Object(Discord\Discord), Object(Discord\Discord), Object(Discord\WebSockets\WebSocket))
#3 /srv/link/mikubot/mikubot/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(64): call_user_func_array(Object(Closure), Array)
#4 /srv/link/mikubot/mikubot/vendor/team-reflex/discord-php/src/Discord/WebSockets/WebSocket.php(791): Evenement\EventEmitter->emit('MESSAGE_CREATE', Array)
#5 /srv/link/mikubot/mikubot/vendor/team-reflex/discord-php/src/Discord/WebSockets/WebSocket.php(284): Discord\WebSockets\WebSocket- in /srv/link/mikubot/mikubot/vendor/team-reflex/discord-php/src/Discord/Parts/Channel/Channel.php on line 436

I made sure I have the newest version, I even tested a dev version. On my test guild it instantly crashes. I fear the ticket has to be reopened.

davidcole1340 commented 8 years ago

Could you come onto the Discord API server and ask for help in #php_discordphp? @haolink

haolink commented 8 years ago

I was asking - and barely got replies. And sadly not helpful ones. I dug in deep using xdebug and I found the issue.

DiscordPHP used APC as a cache to store messages in. As the APC module was loaded, commands such as if (function_exists('apc_cache_info')) worked.

However, in my configuration apc.enable_cli was NOT enabled. So while the APC module was enabled, APC itself was not enabled. Switching this and it started working.