@Client.command()
@commands.is_owner()
async def dm(ctx, *, message):
for server_member in ctx.message.guild.members:
await server_member.create_dm()
await asyncio.sleep(1)
или
@Client.command()
@commands.is_owner()
async def dm(ctx, *, message):
for server_member in ctx.message.guild.members:
await server_member.create_dm()
await asyncio.sleep(1)
await server_member.send(message)
вызывается ошибка:
spoilerIgnoring exception in command dm:
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main511.py", line 1170, in dm
await server_member.send(message)
File "C:\Users\User\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\abc.py", line 883, in send
channel = await self._get_channel()
File "C:\Users\User\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\member.py", line 257, in _get_channel
ch = await self.create_dm()
File "C:\Users\User\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\member.py", line 110, in general
return getattr(self._user, x)(*args, **kwargs)
AttributeError: 'ClientUser' object has no attribute 'create_dm'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\bot.py", line 902, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\User\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\core.py", line 864, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\User\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'ClientUser' object has no attribute 'create_dm'