#Missing 1 required positional argument: 'self'

1 messages · Page 1 of 1 (latest)

silver blaze
#

The goal is to send a message on the channel by using ctx.send if button is pressed ^^

fervent sleet
#

thats not how it works..

#

do the message sending INSIDE the button code

silver blaze
#

;/

#

is it because it all takes longer than 3 secs or what

fervent sleet
#

show your code

silver blaze
#
class MyView(discord.ui.View):
    def __init__(self, ctx):
        self.ctx = ctx

    @discord.ui.button(label="A button", style=discord.ButtonStyle.primary)
    async def button_callback(self, button, interaction):
        button.disabled = True # set button.disabled to True to disable the button
        button.label = "No more pressing!" # change the button's label to something else
        await self.ctx.send("You pressed the button!") # send a message to the context

@bot.slash_command(guilds=serwery)
async def wyznaj(
    ctx: discord.ApplicationContext,
    treść: Option(
        str, "Treść anonimowej wiadomości którą chcesz wysłać.", 
        min_length=1, 
        max_length=2000)):

    # Get the current confession number and increment it by 1 for the preview purposes. 
    preview_number = Confession.get_last_confession_number()
    preview_number += 1

    # Preview the message before sending it
    await ctx.respond(f"**You're sure you want to send this?**", view=MyView(ctx), embed=Confession.preview_message(treść, preview_number), ephemeral=True)```
fervent sleet
#

i'd do interaction.channel.send but doesnt matter

#

can you show what you see in discord

silver blaze
#

When it comes to console, nothing

silver blaze
#

I mean I see a lot of things such as fetch_channel, get_channel, get_channel_or_thread and by simply looking at those docs I can't see what differs them

tranquil plume
#

ctx.send is related to the slash command, not the button

silver blaze
#

I know, but I want to send an embed to channel anonymously, so others don't necessarily see who has executed command

tranquil plume
#

you can use ephemeral=True on send_message