discord.py — почему моя команда serverinfo показывает владельца как «Нет»?

#discord.py #owner

#discord.py #владелец

Вопрос:

 @client.command()
@commands.guild_only()
async def serverinfo(ctx):
    name = str(ctx.guild.name)
    description = str(ctx.guild.description)

    owner = str(ctx.guild.owner)
    id = str(ctx.guild.id)
    region = str(ctx.guild.region)
    memberCount = str(ctx.guild.member_count)

    icon = str(ctx.guild.icon_url)

    embed = discord.Embed(
        title=name   " Server Information",
        description=description,
        color=discord.Color(0x00000)
    )
    embed.set_thumbnail(url=icon)
    embed.add_field(name="Owner", value=owner, inline=True)
    embed.add_field(name="Server ID", value=id, inline=True)
    embed.add_field(name="Region", value=region, inline=True)
    embed.add_field(name="Member Count", value=memberCount, inline=True)

    await ctx.send(embed=embed)
  

Я пробовал намерения участника сервера, но это не работает. Бот просто выводит значение поля владельца как «Нет».

Комментарии:

1. вы тоже использовали намерение гильдии?

Ответ №1:

Выполните следующие действия: 1. Обновите свой discord.py версия до 1.5.1. 2: Перейдите к https://discord.com/developers/applications . Нажмите на свое бот-приложение. 3. Перейдите на вкладку с надписью Bot и щелкните ее. 4: Прокрутите вниз, пока не увидите Server Members Intent , и щелкните по нему, чтобы он стал синим. 5: Перейдите к своей части кода, где есть client/bot = commands.Bot(command_prefix="your prefix here") 6: добавьте этот код:

 intents = discord.Intents.default()  
intents.members = True  
client/bot = commands.Bot(command_prefix="your prefix here", intents=intents)
  

Это должно работать отлично. Пожалуйста, ответьте на это, если это не сработает.