@Chexit

Ошибка discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'str' object has no attribute 'id'?

Ошибка discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'str' object has no attribute 'id'?
Код:
import discord
from discord.ext import commands
 
from discord_slash import SlashCommand
from discord_slash.utils.manage_commands import create_option
 
client = commands.Bot(command_prefix = '.', intents = discord.Intents.all())
slash = SlashCommand(client, sync_commands = True)
 
@slash.slash(name = 'mko', description = 'добавить в мко', options = [{"name": "member", "description": "пользователь", "type": 6, "requied": True}], guild_ids = [907669402181316638])
@client.command(aliase = ['mko'])
 
async def mko(ctx, member: discord.Member, pass_context=True):
	await member.add_roles("907678577758203915")
  • Вопрос задан
  • 128 просмотров
Решения вопроса 1
retUrn3d
@retUrn3d
Пользователь, просто пользователь...
Достаточно добавить буквально одну строчку к вашему коду.
role = discord.utils.get(member.guild.roles, id=907678577758203915)
await member.add_roles(role)
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы