@Python_snake

Почему у меня ошибка модуля discord-ui?

Добрового дня / вечера, столкнулся с проблемой модуля discord-ui.

Сам код:

import discord
from discord.ext import commands
from discord_ui import UI ,Components, Button, SelectMenu, SelectOption

client = commands.Bot (command_prefix=PREFIX, intents = discord.Intents.all(), case_insensitive=True)

ui = UI(client)

@client.command( pass_context=True )
@client.listen()
async def on_message( message ):
	if message.content == '!Button':
		await ui.components.send( message.channel, '**Поддержка**', components=[
			Button( 'Начать чат', 'my_custom_id', 'green' ),
			Button( 'Меню', 'my_custom_id', 'black' ),
			SelectMenu(options=[
				SelectOption('Чат')
			], custom_id='another_custom_id', placeholder='Выберите тип поддержки' )
		]  )


Ошибка:

Traceback (most recent call last):
File "\OneDrive\Рабочий стол\RIMOбот\RIMO.py", line 7, in
from discord_ui import UI ,components, Button, SelectMenu, SelectOption
File "\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord_ui\__init__.py", line 34, in
from .client import *
File "\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord_ui\client.py", line 1, in
from .cogs import BaseCallable, InteractionableCog, ListeningComponent
File "\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord_ui\cogs.py", line 5, in
from .slash.types import BaseCommand, ContextCommand, MessageCommand, SlashCommand, SlashSubcommand, UserCommand
File "\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord_ui\slash\__init__.py", line 20, in
from . import ext
File "\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord_ui\slash\ext\__init__.py", line 13, in
from .builder import *
File "\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord_ui\slash\ext\builder.py", line 2, in
from ...enums import CommandType, OptionType
File "\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord_ui\enums.py", line 13, in
discord.StoreChannel,
^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'discord' has no attribute 'StoreChannel'. Did you mean: 'StageChannel'?
  • Вопрос задан
  • 89 просмотров
Пригласить эксперта
Ответы на вопрос 1
SoreMix
@SoreMix
yellow
Либа в архиве уже год, а последний релиз и того был полтора года назад, и зависит она от такого же трупа, давно поотваливалось всякое на последних версиях.

Можно попробовать вырезать этот discord.StoreChannel из файлов, заменив StoreChannel на какой нибудь свой типа
class StoreChannel(_BaseGuildChannel):
    type: Literal[13]
    bitrate: int
    user_limit: int
    rtc_region: NotRequired[Optional[str]]
    topic: NotRequired[str]

Может схавает
Ответ написан
Ваш ответ на вопрос

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

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