faq.rst 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. ===
  2. FAQ
  3. ===
  4. ``Class 'X' not found``
  5. ======================
  6. You most likely haven't imported the class that you are trying to use. Please check the `class reference <http://discord-php.github.io/DiscordPHP/namespaces/discord>`_ and search for the class that you are trying to use. Add an import statement at the top of the file like shown on the right.
  7. .. code-block:: php
  8. <?php
  9. use Discord\X;
  10. If you don't want to have to import a class every time, you should look into the PHP Intelephense language server (written above) which will do automatic imports for you.
  11. There are less members and/or users than expected
  12. =================================================
  13. Server members are guarded by a priviliged server intent which must be enabled in the `Discord Developer Portal <https://discord.com/developers/applications>`_. Note that you will need to verify your bot if you use this intent and pass 100 guilds.
  14. You also need to enable the ``loadAllMembers`` option in your code, as shown on the right.
  15. .. code-block:: php
  16. $discord = new Discord([
  17. 'token' => '...',
  18. 'loadAllMembers' => true, // Enable this option
  19. ]);
  20. If you are using DiscordPHP Version 6 or greater, you need to enable the ``GUILD_MEMBERS`` intent as well as the ``loadAllMembers`` option. The shown code will enable all intents minus the ``GUILD_PRESENCES`` intent (which is also priviliged).
  21. .. code-block:: php
  22. $discord = new Discord([
  23. 'token' => '...',
  24. 'loadAllMembers' => true,
  25. 'intents' => Intents::getDefaultIntents() | Intents::GUILD_MEMBERS // Enable the `GUILD_MEMBERS` intent
  26. ])