Ошибка кода:
intents = discord.Intents.default()
intents.members = True
client=commands.Bot(intents=intents, command_prefix = ".")
client.remove_command('help') # удаляем встроенную команду хелпа
@client.command()
async def news(ctx):
guild = ctx.guild
async for member in guild.fetch_members(limit=None):
await member.send("Приветики!")
print("Отправил", member)
Ошибка:
Ignoring exception in command news:
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\Admin\Desktop\bethce\anti-lavan-new.py", line 129, innews
await member.send("Приветики!")
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\abc.py", line 1013, in send
channel = await self._get_channel()
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\member.py", line 299, in _get_channel
ch = await self.create_dm()
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\member.py", line 142, in general
return await 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\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\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'