 |

23.02.2023, 06:29
|
|
Участник форума
Регистрация: 17.03.2022
Сообщений: 146
С нами:
2190224
Репутация:
23
|
|
делаю селфбота, мне нужно что бы я указывал в коде ID войса и бот к нему подключался.
мои попытки :
Python:
Код:
@client.command
(
)
async
def
join
(
ctx
)
:
channel
.
id
=
'1067526271661256787'
await
channel
.
connect
(
)
Python:
Код:
@client.command
(
)
async
def
join
(
ctx
,
pon
)
:
channel
.
id
=
(
pon
)
await
channel
.
connect
(
)
выдает ошибку :
Код:
Код:
Ignoring exception in command join:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Microsoft\Новая папка (3)\kreora\kreora (фикс крч).py", line 73, in join
channel.id = (pon)
NameError: name 'channel' is not defined
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'channel' is not defined
|
|
|

23.02.2023, 12:23
|
|
Постоянный
Регистрация: 05.11.2021
Сообщений: 634
С нами:
2380746
Репутация:
68
|
|
Сообщение от NORTEX666
делаю селфбота, мне нужно что бы я указывал в коде ID войса и бот к нему подключался.
мои попытки :
Python:
Код:
@client.command
(
)
async
def
join
(
ctx
)
:
channel
.
id
=
'1067526271661256787'
await
channel
.
connect
(
)
Python:
Код:
@client.command
(
)
async
def
join
(
ctx
,
pon
)
:
channel
.
id
=
(
pon
)
await
channel
.
connect
(
)
выдает ошибку :
Код:
Код:
Ignoring exception in command join:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Microsoft\Новая папка (3)\kreora\kreora (фикс крч).py", line 73, in join
channel.id = (pon)
NameError: name 'channel' is not defined
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'channel' is not defined
У тебя есть channel.id, но нет самого объекта channel. Используй
voice_ch = ctx.guild.fetch_channel(channel_id)
voice_ch.connect()
|
|
|

23.02.2023, 15:40
|
|
Участник форума
Регистрация: 17.03.2022
Сообщений: 146
С нами:
2190224
Репутация:
23
|
|
Сообщение от Vtylochka
У тебя есть channel.id, но нет самого объекта channel. Используй
voice_ch = ctx.guild.fetch_channel(channel_id)
voice_ch.connect()
вроде все правильно сделал, что тут не так? можешь пожалуйста прикрепить правильный код с использованием event ?
код:
Код:
@client.command()
async def join(ctx, arg1):
voice_ch.id = (arg1)
voice_ch = ctx.guild.fetch_channel(channel.id)
voice_ch.connect()
ошибка:
Код:
Ignoring exception in command join:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Microsoft\Новая папка (3)\kreora\kreora (фикс крч).py", line 73, in join
voice_ch.id = (arg1)
UnboundLocalError: local variable 'voice_ch' referenced before assignment
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: UnboundLocalError: local variable 'voice_ch' referenced before assignment
|
|
|

23.02.2023, 15:50
|
|
Постоянный
Регистрация: 05.11.2021
Сообщений: 634
С нами:
2380746
Репутация:
68
|
|
Оаоа:
Код:
@client.command
(
)
async
def
join
(
ctx
,
arg1
)
:
voice_ch
=
ctx
.
guild
.
fetch_channel
(
int
(
arg1
)
)
voice_ch
.
connect
(
)
# ЗАЧЕМ ты используешь в имени переменной точку? Точкой обозначается АТРИБУТЫ, вот он не может найти voice_ch, к которому ты хочешь добавить аргумент id.
# ЗАЧЕМ ты создаешь еще одну ненужную переменную, смысл от этого если ты просто дублируешь значение из аргумента
|
|
|

23.02.2023, 17:25
|
|
Участник форума
Регистрация: 17.03.2022
Сообщений: 146
С нами:
2190224
Репутация:
23
|
|
Сообщение от Vtylochka
Оаоа:
Код:
@client.command
(
)
async
def
join
(
ctx
,
arg1
)
:
voice_ch
=
ctx
.
guild
.
fetch_channel
(
int
(
arg1
)
)
voice_ch
.
connect
(
)
# ЗАЧЕМ ты используешь в имени переменной точку? Точкой обозначается АТРИБУТЫ, вот он не может найти voice_ch, к которому ты хочешь добавить аргумент id.
# ЗАЧЕМ ты создаешь еще одну ненужную переменную, смысл от этого если ты просто дублируешь значение из аргумента
oshibka:
Код:
Ignoring exception in command join:
Traceback (most recent call last):
File "C:\Users\Kiril\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Microsoft\Новая папка (3)\kreora\kreora (фикс крч).py", line 73, in join
voice_ch = ctx.guild.fetch_channel(int(arg1))
AttributeError: 'Guild' object has no attribute 'fetch_channel'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Kiril\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Kiril\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\Kiril\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Guild' object has no attribute 'fetch_channel'
|
|
|

23.02.2023, 17:32
|
|
Постоянный
Регистрация: 05.11.2021
Сообщений: 634
С нами:
2380746
Репутация:
68
|
|
Сообщение от NORTEX666
oshibka:
Код:
Ignoring exception in command join:
Traceback (most recent call last):
File "C:\Users\Kiril\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Microsoft\Новая папка (3)\kreora\kreora (фикс крч).py", line 73, in join
voice_ch = ctx.guild.fetch_channel(int(arg1))
AttributeError: 'Guild' object has no attribute 'fetch_channel'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Kiril\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Kiril\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\Kiril\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Guild' object has no attribute 'fetch_channel'
Я не помню точный метод, смотри в документации, скорее всего client.fetch_channel
|
|
|
|
 |
|
Здесь присутствуют: 1 (пользователей: 0 , гостей: 1)
|
|
|
|