Reputation: 34
I have been searching for an answer that works for my code, and I honestly cannot find one. I know how to create the buttons and add them to the bottom of my embed, but i cant get them to send a hidden message. This is my button code:
buttons = [
create_button(style=ButtonStyle.green, label="I liked it"),
create_button(style=ButtonStyle.grey, label="I'm neutral"),
create_button(style=ButtonStyle.red, label="I did not like it")
]
action_row = create_actionrow(*buttons)
bcc2 = await bcc.send(embed=embed, components=[action_row])
It is in a repeating function that occurs at a specific time a day. However, when I try to link the response, it just full on ignores it. Any recommendations? Here is my response attempt:
@slash.component_callback()
async def hello(ctx: ComponentContext):
await ctx.send(content="You pressed a button!", hidden=True)
In the end I want the message sent to be a hidden message.
Upvotes: 1
Views: 1741
Reputation: 332
You can't do this with discord.py, but you can do it with pycord, which is a fork of discord.py. The newest version of pycord (2.0.0) supports slash commands, message components, and ephemeral messages.
You can install it by running this in your terminal:
pip install -U git+https://github.com/Pycord-Development/pycord
To make the bot send a hidden message, you do this:
await ctx.send('This is a hidden message', ephemeral=True)
You can also use the built in slash command feature with pycord, without needing to install a third-party library. You can check the docs here for more info. This tutorial explains how to create views and buttons with pycord.
Upvotes: 2