0

Делаю что-то типа стратегии в дискорде через бота, основанного на библиотеке discord.py. И возникает проблема с созданием прав для канала переговоров. Следующий код просто создает канал, но его никто не может видеть(кроме администрации). Как бы это можно было решить?

@bot.command()
async def дипломатия(ctx, type: str, country: discord.Member):
    guild = bot.get_guild(1015934332860370965)
    author_id=ctx.author.id
    if type == 'переговоры':
        category = discord.utils.get(guild.categories, name="Дипломатия")
        channel = await guild.create_text_channel(f'{author_id}-{country}', category=category)
        await channel.set_permissions(ctx.guild.default_role, read_messages=False)
        await channel.set_permissions(author_id, read_messages=True, send_messages=True)
        await channel.set_permissions(country, read_messages=True, send_messages=True)

1 ответ 1

0

сообщество! Ответ на вопрос найден мною же и вот мой код:

@bot.command()
async def дипломатия(ctx, type: str, country: discord.Member):
    guild = bot.get_guild(1015934332860370965)
    author_id=ctx.author
    if type == 'переговоры':
        category = discord.utils.get(guild.categories, name="Дипломатия")
        channel = await guild.create_text_channel(f'{author_id}-{country}', category=category)
        await channel.set_permissions(ctx.guild.default_role, read_messages=False)
        await channel.set_permissions(author_id, speak=True, read_messages=True, send_messages=True)
        await channel.set_permissions(country, speak=True, read_messages=True, send_messages=True)

Я надеюсь, что кому-нибудь это понадобится. В общем, ошибка заключалась в author_id=ctx.author.id. Айди добывать не нужно

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.