Помогите пожалуйста с ботом. Код взял с зарубежных уроков. Там все у них работает, а у меня нет(
import discord
from discord import app_commands
class button_view(discord.ui.View):
def __init__(self) -> None:
super().__init__(timeout = None)
@discord.ui.button(label = “verify”, style = discord.ButtonStyle.green, custom_id = “verify”)
async def verify(self, interaction: discord.Interaction, button: discord.ui.Button):
if type(client.role) is not discord.Role:
client.role = interaction.guild.get_role(980107923646722068)
if client.role not in interaction.user.roles:
await interaction.user.add_roles(client.role)
await interaction.response.send_message(f“I have given you {client.role.mention}!”, ephemeral = True)
else: await interaction.response.send_message(f“You already have {client.role.metion}!”, ephemeral = True)
class aclient(discord.Client):
def __init__(self):
super().__init__(intents = discord.Intents.default())
self.synced = False
self.role = 980107923646722068
self.added = False
async def on_ready(self):
await self.wait_until_ready()
if not self.synced:
#
self.synced = True
if not self.added:
self.add_view(button_view())
self.added = True
print(f“We have logged in as {self.user}.”)
client = aclient()
tree = app_commands.CommandTree(client)
@tree.command(guild = discord.Object(id=979417086570930186), name = ‘button’, description='Launches role button')
async def button(interaction: discord.Interaction):
await interaction.response.send_message(view = button_view())
client.run('my token')
Ошибка вылазит такая:
Traceback (most recent call last):
File “C:\Work\Python\Python Test1\Bot roles эксперементальный\roli — копия.py”, line 1, in <module>
from discord import app_commands
File “C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\app_commands\__init__.py”, line 12, in <module>
from .commands import *
File “C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\app_commands\commands.py”, line 51, in <module>
from ..enums import AppCommandOptionType, AppCommandType
ImportError: cannot import name ‘AppCommandOptionType’ from ‘discord.enums’ (C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\enums.py)
Process finished with exit code 1
Хотя установленные все модули последних версий discord 2+ и т.д.