T
T
Telmor2021-10-20 20:12:13
Python
Telmor, 2021-10-20 20:12:13

How to mention a person by getting only their id in discord.py?

I have code:

await ctx.send(f'**Упомяните** пользователя у которого хотите **забрать** доступ к комнате!. Для этого у вас есть 20 секунд!', delete_after=20)
                        res = await self.bot.wait_for("message", check=lambda i: i.author == member, timeout=20)
                        await res.delete()
                        id_mem = res.content\
                            .replace("<", "")\
                            .replace("@", "")\
                            .replace("!", "")\
                            .replace(">", "")
                        print(id_mem)
                        user = ctx.guild.get_member(id_mem)
                        await ctx.send(f'пользователь: {user}')
                        channel4 = self.bot.get_channel(channel1)
                        await channel4.set_permissions(user, connect=False)
                        await ctx.send(f'{member.mention}, вы **закрыли доступ** в комнату пользователю {user.mention}')

He, after pressing the button and a couple of checks, receives the next message from the user in this chat, And this message must contain a mention of the person. And through conversion - we get the user id. And from id we must make a variable in order to close the user access to the channel - which we also indicated.
The problem arises at the moment of converting id into a variable for use after.
Bot throws an error: user: None
Tried: ctx.guild.get_member() ; self.bot.get_user() ; self.bot.get_member(id) . And none of this works.
Please help me with this issue.
(I write the code in cogs)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavlosik, 2021-10-21
@Pavlosik

You can use member.name.id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question