Answer the question
In order to leave comments, you need to log in
How do I make a user via id in discord.py?
I have a code that, on clicking a button, receives the following message written by the user.
Those. I have an embed with buttons and when a person presses the button, a bot will be sent to him: enter the user. And when the user mentions it, the bot gives an error:
Ignoring exception in command test1:
Traceback (most recent call last):
File "C:\Users\Fenix\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\Fenix\Desktop\modern\Beta(войсы(все))\cogs\private.py", line 165, in createembedforprivateroom
await channel4.set_permissions(user, connect=False)
File "C:\Users\Fenix\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\abc.py", line 648, in set_permissions
raise InvalidArgument('target parameter must be either Member or Role')
discord.errors.InvalidArgument: target parameter must be either Member or Role
await ctx.send(f'**Упомяните** пользователя у которого хотите **забрать** доступ к комнате!. Для этого у вас есть 20 секунд!', delete_after=20)
res = await self.bot.wait_for("message", check=lambda i: i.author == member, timeout=20)
cd = res.content \
.replace("<", "") \
.replace("@", "") \
.replace("!", "") \
.replace(">", "")
user = get(self.bot.get_all_members(), id=cd)
channel4 = self.bot.get_channel(channel1)
await channel4.set_permissions(user, connect=False)
await ctx.send(f'{member.mention}, вы **закрыли доступ** в комнату пользователю {user.mention}')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question