Когда я пишу команду из кода, то появляется эта ошибка:
Бот запущен
Вы вошли как Modern Saphire#0477
Ignoring exception in command verif:
Traceback (most recent call last):
File "C:\Users\Fenix\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\Fenix\Desktop\bots\Modern Saphire (мой серв)\bot.py", line 1373, in verif
await ctx.send(embed = emb, components = [row])
File "C:\Users\Fenix\AppData\Local\Programs\Python\Python39\lib\site-packages\discord_components\client.py", line 46, in send_component_msg_prop
return await self.send_component_msg(ctxorchannel.channel, *args, **kwargs)
File "C:\Users\Fenix\AppData\Local\Programs\Python\Python39\lib\site-packages\discord_components\client.py", line 177, in send_component_msg
data = await self.bot.http.request(
File "C:\Users\Fenix\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\http.py", line 254, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.0.components.0: The specified component type is invalid in this context
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Fenix\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Fenix\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\Fenix\AppData\Local\Programs\Python\Python39\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: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.0.components.0: The specified component type is invalid in this context
Её нет когда я вставляю код в пустой файл.
Сам код:
import discord
from discord import member
from discord.ext import commands
from dislash import InteractionClient, ActionRow, Button, ButtonStyle
intents = discord.Intents.all()
bot = commands.Bot(command_prefix = "!", intents = intents)
bot.remove_command("help")
inter_client = InteractionClient(bot)
@bot.event
async def on_ready():
print(f'Вы вошли как {bot.user}')
@bot.command()
async def verif(ctx):
emb = discord.Embed(
description =
f"""
Здраствуйте вы попали на сервер {ctx.guild.name}, пройдите верификацию чтобы получить доступ к другим каналам.
""",
colour = 0xFF8C00
)
emb.set_thumbnail(url = 'https://cdn.discordapp.com/attachments/772850448892690462/880752123418136596/947d1f802c858b540b84bc3000fc2439_1_-removebg-preview.png')
emb.set_author(name = 'Верификация')
row = ActionRow(
Button(
style = ButtonStyle.gray,
label = 'Верифицироваться',
custom_id = 'verif_button'
)
)
msg = await ctx.send(embed = emb, components = [row])
@bot.event
async def on_button_click(inter):
res = 'Вы успешно верифицировались!' # ваш вывод сообщение что человек получил роль
guild = bot.get_guild(inter.guild.id)
if inter.component.id == "verif_button":
verif = guild.get_role(839599752319598662)
member = inter.author
await member.add_roles(verif)
await inter.reply(res, ephemeral = True)
bot.run("TOKEN")