@bot.slash_command(name="help", description="See all avaiable bot commands")
async def help(ctx):
with open('config.json') as f:
config = json.load(f)
bot_invite_link = config['bot_invite_link']
embed = nextcord.Embed(title="Command List", color=0x00ff00)
button1 = nextcord.ui.Button(style=nextcord.ButtonStyle.blurple, label="γ‘ Developer", emoji="π§βπ»")
button2 = nextcord.ui.Button(style="link", url=bot_invite_link, label="γ‘ Invite Me", emoji="π§·")
view = nextcord.ui.View()
view.add_item(button1)
view.add_item(button2)
embed.add_field(name="", value="
ping, help, purge, embed
", inline=False)
embed.set_footer(text="Made by: 479u", icon_url="https://cdn3.emoji.gg/emojis/4205-orange-discord-pfp.png")
await ctx.send(embed=embed, view=view)
dev = await bot.wait_for("button_click", timeout=10)
if dev.custom_id == "button2":
await ctx.message.send("Bot Developer: `479u`", ephemeral=True)```
it doesnt send message when button2 clicked. please help me
#π Help command
97 messages Β· Page 1 of 1 (latest)
@tawdry crater
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Closes after a period of inactivity, or when you send !close.
it doesnt send message when button2 clicked. please help me
of course it is a link
???
button 2 doesnt work
i mean when i click it i want to it send message
but it doesnt
no error
@bot.slash_command(name="help", description="See all avaiable bot commands")
async def help(ctx):
with open('config.json') as f:
config = json.load(f)
bot_invite_link = config['bot_invite_link']
embed = nextcord.Embed(title="Command List", color=0x00ff00)
button1 = nextcord.ui.Button(style=nextcord.ButtonStyle.blurple, label="γ‘ Developer", emoji="π§βπ»")
button2 = nextcord.ui.Button(style="link", url=bot_invite_link, label="γ‘ Invite Me", emoji="π§·")
view = nextcord.ui.View()
view.add_item(button1)
view.add_item(button2)
embed.add_field(name="", value="
ping, help, purge, embed
", inline=False)
embed.set_footer(text="Made by: 479u", icon_url="https://cdn3.emoji.gg/emojis/4205-orange-discord-pfp.png")
await ctx.send(embed=embed, view=view)
dev = await bot.wait_for("button_click", timeout=10)
if dev.custom_id == "button2":
await ctx.message.send("Bot Developer: `479u`", ephemeral=True)```
it doesnt send message when button2 clicked. please help me
@sinful scroll
everything works
no errors
but i made it
and i wanted it after clicking button to send this message
but it doesnt
wym?
i dont understand
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1264.0_x64__qbz5n2kfra8p0\Lib\asyncio\tasks.py", line 520, in wait_for
return await fut
^^^^^^^^^
asyncio.exceptions.CancelledError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Radek\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\nextcord\application_command.py", line 918, in invoke_callback_with_hooks
await self(interaction, *args, **kwargs)
File "c:\Users\Radek\Desktop\Pliki\Python\Discord Bot\main.py", line 36, in help
dev = await bot.wait_for("button_click", timeout=10)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1264.0_x64__qbz5n2kfra8p0\Lib\asyncio\tasks.py", line 519, in wait_for
async with timeouts.timeout(timeout):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1264.0_x64__qbz5n2kfra8p0\Lib\asyncio\timeouts.py", line 115, in __aexit__
raise TimeoutError from exc_val
TimeoutError
The above exception was the direct cause of the following exception:
nextcord.errors.ApplicationInvokeError: Command raised an exception: TimeoutError:```
i get this
@sinful scroll
send now code
its the same
@bot.slash_command(name="help", description="See all avaiable bot commands")
async def help(ctx):
with open('config.json') as f:
config = json.load(f)
bot_invite_link = config['bot_invite_link']
embed = nextcord.Embed(title="Command List", color=0x00ff00)
button1 = nextcord.ui.Button(style=nextcord.ButtonStyle.blurple, label="γ‘ Developer", emoji="π§βπ»")
button2 = nextcord.ui.Button(style="link", url=bot_invite_link, label="γ‘ Invite Me", emoji="π§·")
view = nextcord.ui.View()
view.add_item(button1)
view.add_item(button2)
embed.add_field(name="", value="ping, help, purge, embed", inline=False)
embed.set_footer(text="Made by: 479u", icon_url="https://cdn3.emoji.gg/emojis/4205-orange-discord-pfp.png")
await ctx.send(embed=embed, view=view)
dev = await bot.wait_for("button_click", timeout=10)
if dev.custom_id == "button2":
await ctx.message.send("Bot Developer: `479u`", ephemeral=True)```
and when i click this button2 it send me error in console in vsc
The timeout has expired and you are setting a timeout of 10 seconds
so what schould i change in this code?
you can set more waiting time
It would be better if you make a separate class for the view and buttons and can handle the interactions there.
What library do you use?
I don't use that library, but can you see if the ctx parameter has the respond() method?
await ctx.respond(...)
still doesnt work ;/
@bot.slash_command(name="help", description="See all avaiable bot commands")
async def help(ctx):
with open('config.json') as f:
config = json.load(f)
bot_invite_link = config['bot_invite_link']
embed = nextcord.Embed(title="Command List", color=0x00ff00)
button1 = nextcord.ui.Button(style=nextcord.ButtonStyle.blurple, label="γ‘ Developer", emoji="π§βπ»")
button2 = nextcord.ui.Button(style="link", url=bot_invite_link, label="γ‘ Invite Me", emoji="π§·")
view = nextcord.ui.View()
view.add_item(button1)
view.add_item(button2)
embed.add_field(name="", value="ping, help, purge, embed", inline=False)
embed.set_footer(text="Made by: 479u", icon_url="https://cdn3.emoji.gg/emojis/4205-orange-discord-pfp.png")
await ctx.send(embed=embed, view=view)
dev = await bot.wait_for("button_click", timeout=100)
if dev.custom_id == "button2":
await ctx.respond("Bot Developer: `479u`", ephemeral=True)
How do you have your bot instance defined?
You can follow the examples from the repository:
GitHub
A Python wrapper for the Discord API forked from discord.py - nextcord/nextcord
Oh no
The Client object only contains events, if you want to use commands you must use the Bot object
GitHub
A Python wrapper for the Discord API forked from discord.py - nextcord/nextcord
but when i change client to bot it sends error
i mean
i want use my bot globally
so without this guild it
i have it on 3 servers
so what schould i change here?
In the documentation it says it should be bot = commands.Bot()
alr
sec
i changed
but still it doesnt
send me anything when i click
button ;/
Remove the command buttons and make a separate class. There are examples in the repository.
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1264.0_x64__qbz5n2kfra8p0\Lib\asyncio\tasks.py", line 520, in wait_for
return await fut
^^^^^^^^^
asyncio.exceptions.CancelledError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Radek\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\nextcord\application_command.py", line 918, in invoke_callback_with_hooks
await self(interaction, *args, **kwargs)
File "c:\Users\Radek\Desktop\Pliki\Python\Discord Bot\main.py", line 36, in help
dev = await bot.wait_for("button_click", timeout=100)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1264.0_x64__qbz5n2kfra8p0\Lib\asyncio\tasks.py", line 519, in wait_for
async with timeouts.timeout(timeout):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1264.0_x64__qbz5n2kfra8p0\Lib\asyncio\timeouts.py", line 115, in __aexit__
raise TimeoutError from exc_val
TimeoutError
The above exception was the direct cause of the following exception:
nextcord.errors.ApplicationInvokeError: Command raised an exception: TimeoutError:```
.
Try simple things, don't try to do complex things yet
GitHub
A Python wrapper for the Discord API forked from discord.py - nextcord/nextcord
explore all examples and practice
but what exactly
idk what i am looking for
i just want my button to respond when clicked
then look at this example:
https://github.com/nextcord/nextcord/blob/master/examples%2Fviews%2Fconfirm.py
GitHub
A Python wrapper for the Discord API forked from discord.py - nextcord/nextcord
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.