mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-05-15 18:29:52 +00:00
[commands] Add warning if Intent.message_content is not enabled
This commit is contained in:
parent
cdce8fae5b
commit
54ee383585
@ -198,6 +198,23 @@ class BotBase(GroupMixin[None]):
|
|||||||
|
|
||||||
# internal helpers
|
# internal helpers
|
||||||
|
|
||||||
|
async def _async_setup_hook(self) -> None:
|
||||||
|
# self/super() resolves to Client/AutoShardedClient
|
||||||
|
await super()._async_setup_hook() # type: ignore
|
||||||
|
prefix = self.command_prefix
|
||||||
|
|
||||||
|
# This has to be here because for the default logging set up to capture
|
||||||
|
# the logging calls, they have to come after the `Client.run` call.
|
||||||
|
# The best place to do this is in an async init scenario
|
||||||
|
if not self.intents.message_content: # type: ignore
|
||||||
|
trigger_warning = (
|
||||||
|
(callable(prefix) and prefix is not when_mentioned)
|
||||||
|
or isinstance(prefix, str)
|
||||||
|
or (isinstance(prefix, collections.abc.Iterable) and len(list(prefix)) >= 1)
|
||||||
|
)
|
||||||
|
if trigger_warning:
|
||||||
|
_log.warning('Privileged message content intent is missing, commands may not work as expected.')
|
||||||
|
|
||||||
def dispatch(self, event_name: str, /, *args: Any, **kwargs: Any) -> None:
|
def dispatch(self, event_name: str, /, *args: Any, **kwargs: Any) -> None:
|
||||||
# super() will resolve to Client
|
# super() will resolve to Client
|
||||||
super().dispatch(event_name, *args, **kwargs) # type: ignore
|
super().dispatch(event_name, *args, **kwargs) # type: ignore
|
||||||
|
Loading…
x
Reference in New Issue
Block a user