#Help write to a user and shows incorrect user status

1 messages · Page 1 of 1 (latest)

sullen lagoon
sullen lagoon
#

When using the /users command, the bot issues an incorrect user status

undone token
#

Kinda hard to follow when all your variables are in another language.
Maybe try the RU disnake server?

#info

#

But I see dislash in your imports. Might want to not use that deprecated lib. It hasn't been touched in 2 years.

#

-d disnake.Member

mortal tuskBOT
#

class disnake.Member```
Represents a Discord member to a [`Guild`](https://docs.disnake.dev/en/latest/api/guilds.html#disnake.Guild "disnake.Guild").

This implements a lot of the functionality of [`User`](https://docs.disnake.dev/en/latest/api/users.html#disnake.User "disnake.User").

x == y Checks if two members are equal. Note that this works with [`User`](https://docs.disnake.dev/en/latest/api/users.html#disnake.User "disnake.User") instances too.

x != y Checks if two members are not equal. Note that this works with [`User`](https://docs.disnake.dev/en/latest/api/users.html#disnake.User "disnake.User") instances too.

hash(x) Returns the member’s hash.

str(x) Returns the member’s username (with discriminator, if not migrated to new system yet).
sullen lagoon
#
    @commands.slash_command(name="user", description="Получить информацию об пользователе")
    async def user_info(self, ctx, пользователь: disnake.Member = None):
        
        if пользователь is None:
            пользователь = ctx.author

        roles_info = "\n".join(role.mention for role in пользователь.roles[1:])  # Пропускаем @everyone роль

        user_status = ctx.author.status
        status_emojis = {
            disnake.Status.online: "🟢",
            disnake.Status.invisible: "⚫",
            disnake.Status.idle: "🟠",
            disnake.Status.do_not_disturb: "🔴",
        }

        status_text = status_emojis.get(user_status, "Неизвестно")

        embed = disnake.Embed(title="Информация о пользователе", color=пользователь.color)
        if пользователь.avatar:
            embed.set_thumbnail(url=пользователь.avatar.url)
        embed.add_field(name="Имя", value=пользователь.display_name, inline=False)
        embed.add_field(name="Тэг", value=пользователь, inline=False)
        embed.add_field(name="ID", value=пользователь.id, inline=False)
        embed.add_field(name="Создан аккаунт", value=пользователь.created_at.strftime('%Y-%m-%d %H:%M:%S'), inline=False)
        embed.add_field(name="Зашел на сервер", value=пользователь.joined_at.strftime('%Y-%m-%d %H:%M:%S'), inline=False)
        embed.add_field(name="Всего ролей", value=str(len(пользователь.roles) - 1), inline=False)
        
        roles_with_admin = [role for role in пользователь.roles[1:] if role.permissions.administrator]
        roles_info_with_admin = roles_info
        if roles_with_admin:
            roles_info_with_admin += "\n" + "\n".join(role.mention + " (права администратора)" for role in roles_with_admin)
        
#
        embed.add_field(name="Роли", value=roles_info_with_admin, inline=False)

        # Используем метод mobile_status


        embed.add_field(name="Статус", value=status_text, inline=False)

        embed.add_field(name="Активность", value=пользователь.activity.name if пользователь.activity else "Нет активности", inline=False)
        embed.add_field(name="Топ роль", value=пользователь.top_role.mention, inline=False)
        
        # Дополнительные идеи:
        embed.add_field(name="Бот?", value="Да" if пользователь.bot else "Нет", inline=False)

        # Информация обо мне

        # Количество и название значков
        badges_info = "\n".join(badge.name for badge in пользователь.public_flags.all())
        embed.add_field(name="Количество значков", value=str(len(пользователь.public_flags.all())), inline=False)
        embed.add_field(name="Название значков", value=badges_info, inline=False)

        await ctx.send(embed=embed)