Показать сообщение отдельно

  #11  
Старый 25.05.2023, 13:48
triazov
Участник форума
Регистрация: 23.08.2022
Сообщений: 263
С нами: 1962097

Репутация: 33
По умолчанию

Class:





Код:
class
Music
(
commands
.
Cog
)
:
def
__init__
(
self
,
bot
:
commands
.
Bot
)
:
self
.
bot
=
bot
        self
.
voice_states
=
{
}
def
get_voice_state
(
self
,
ctx
:
commands
.
Context
)
:
state
=
self
.
voice_states
.
get
(
ctx
.
guild
.
id
)
if
not
state
:
state
=
VoiceState
(
self
.
bot
,
ctx
)
self
.
voice_states
[
ctx
.
guild
.
id
]
=
state
return
state
def
cog_unload
(
self
)
:
for
state
in
self
.
voice_states
.
values
(
)
:
self
.
bot
.
loop
.
create_task
(
state
.
stop
(
)
)
def
cog_check
(
self
,
ctx
:
commands
.
Context
)
:
if
not
ctx
.
guild
:
raise
commands
.
NoPrivateMessage
(
'Эта команда не используется в ЛС (Личные сообщения)'
)
return
True
async
def
cog_before_invoke
(
self
,
ctx
:
commands
.
Context
)
:
ctx
.
voice_state
=
self
.
get_voice_state
(
ctx
)
async
def
cog_command_error
(
self
,
ctx
:
commands
.
Context
,
error
:
commands
.
CommandError
)
:
await
ctx
.
send
(
'Меня это пугает. Произошла какая-то ошибка: {}'
.
format
(
str
(
error
)
)
)


И вот обращение к классу

Обращение к функции и класу:





Код:
bot
.
add_cog
(
Music
(
bot
)
)




Если без кога.

Код почему то не работает

вот лог

Цитата:

←[30;1m2023-05-25 12:48:31←[0m ←[31mERROR ←[0m ←[35mdiscord.ext.commands.bot←[0m Ignoring exception in command None
←[31mdiscord.ext.commands.errors.CommandNotFound: Command "play" is not found←[0m
←[30;1m2023-05-25 12:48:36←[0m ←[31mERROR ←[0m ←[35mdiscord.ext.commands.bot←[0m Ignoring exception in command None
←[31mdiscord.ext.commands.errors.CommandNotFound: Command "join" is not found←[0m
←[30;1m2023-05-25 12:48:52←[0m ←[31mERROR ←[0m ←[35mdiscord.ext.commands.bot←[0m Ignoring exception in command None
←[31mdiscord.ext.commands.errors.CommandNotFound: Command "play" is not found←[0m
 
Ответить с цитированием