Хочу получить пользователя, для этого пишу:
member = await Bot.fetch_user(user_id=user)
Но выдаёт такую ошибку:
TypeError: Client.fetch_user() got some positional-only arguments passed as keyword arguments: 'user_id'
Пытался без
user_id=
:
member = await Bot.fetch_user(user_id)
Но выдаёт такую ошибку:
TypeError: Client.fetch_user() missing 1 required positional argument: 'user_id
Пытался просто ID написать, но ничего не вышло, не понимаю почему так.
Полный код:
@commands.command(name='unban', aliases=['un-ban'], usage = 'faye unban <user id> <reason*>')
async def user_unban(self, ctx, user: int, reason = 'No reason'):
if check_server_reg(ctx.guild.id) == True: # Проверка на существование сервера в БД.
moder_role = get_moder_role(ctx.guild.id)
roles = []
for i in ctx.author.roles:
roles = roles + [str(i)]
moder_role = disnake.utils.get(ctx.guild.roles, id = int(moder_role))
if str(moder_role) in roles or ctx.author.id == ctx.guild.owner_id or ctx.author.id == 572228449897545730:
user_id = int(user)
member = await Bot.fetch_user()
qwe.execute(''' SELECT ban_user FROM ban_table WHERE ban_user=? ''', [member.id])
if qwe.fetchone() is None:
embed = disnake.Embed(title='❗ Error, you did something wrong ❗', description=f'> This user is not banned.', color=0x71368a)
await ctx.reply(embed=embed)
else:
qwe.execute(''' DELETE FROM ban_table WHERE ban_user=? ''', [member.id])
db.commit()
await ctx.guild.unban(member, reason=reason)
embed = disnake.Embed(title=' Successful ', description=f'> {member.name} was unbanned.', color=0x71368a)
await ctx.reply(embed=embed)
Полная ошибка:
Ignoring exception in command unban:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\disnake\ext\commands\core.py", line 173, in wrapped
ret = await coro(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Python\bot\cogs\punish.py", line 296, in user_unban
member = await Bot.fetch_user(user_id=user)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Client.fetch_user() got some positional-only arguments passed as keyword arguments: 'user_id'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\disnake\ext\commands\bot_base.py", line 589, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\disnake\ext\commands\core.py", line 914, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\disnake\ext\commands\core.py", line 182, in wrapped
raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Client.fetch_user() got some positional-only arguments passed as keyword arguments: 'user_id'