discord-php / DiscordPHP

An API to interact with the popular messaging app Discord
MIT License
1k stars 237 forks source link

bot check #991

Closed ocvcoin closed 1 year ago

ocvcoin commented 1 year ago

Hi I have a problem. For some reason I can't understand, var_dump rarely shows true for the same user & same command. Why could this happen?

PHP 7.4.3 discord-php v7.3.3

$discord->listenCommand('ocv', function (Interaction $interaction) {

        //target_userid is bot??
        var_dump (  (@$interaction->data ->resolved ->users[$target_userid]->bot !== NULL)  );

});
key2peace commented 1 year ago

please don't use the Bug label, it is meant for bugs in DiscordPHP not in your code. also, bot is bool, so either true or false and also you need to remove the spaces

SQKo commented 1 year ago

bot is always true when resolved target is a bot, otherwise it's sometimes null or false, depends on the users cache. You should refrain from using the @ silent error so var_dump() doesn't confuse error with null values.

ocvcoin commented 1 year ago

Thank you. It's clarified.