#Message Send&Edit

1 messages · Page 1 of 1 (latest)

west grove
#

I first used ctx.edit_origin for the message
and then I try to use ctx.send and It told me has already acknowledge

this is my code

@listen()
async def on_component(self, event: Component, **kwargs):
    ctx = event.ctx
    match ctx.custom_id:
        case "Fast" | "Relax":
            response = PostAgent.Fast() if ctx.custom_id == "Fast" else PostAgent.Relax()
            if response[0]:
                BotSettings["BotInit"]["Speed"] = ctx.custom_id
                await ctx.edit_origin(components = ButtonClick(ctx, Switch=["BotInit", "Speed"]))
                await ctx.send('Mode Change:{}'.format(ctx.custom_id))
            else:
                await ctx.send(response[1])

I can use it in i.py V4 and now in V5
and can't find help in docs
If something I don't find,Plz tell a docs url thanks

bright pikeBOT
#

Hey! Once your issue is solved, press the button below to close this thread!

west grove
#

And callback
Ignoring exception in Component(): HTTPException: 400|Bad Request || Interaction has already been acknowledged.

west grove
#

Message Send&Edit

prisma bear
west grove
#

ButtonClick() will convert the transmitted component into the component format I need. It does not have any effect, but it is similar to that I change the value of a certain company

#

edit worked fine until I executed edit.origin and ctx.send stopped working

#

In ButtonClick (), I just got the value of ctx.comPonent. It did not change the contents of the ctx direction. The following ctx.custom_id can still be used normally

and this is the code of ButtonClick()

    __tempList = []
    for __action in ctx.message.components:
        __SecList = []
        for __component in __action.components:
            button = Button(style = __component.style, custom_id = __component.custom_id, label = __component.label, disabled = __component.disabled)
            if Switch:
                if __component.custom_id == BotSettings[Switch[0]][Switch[1]] or __component.custom_id == ctx.component.custom_id:
                    button.disabled = False if __component.disabled else True
            else:
                if __component.custom_id == ctx.component.custom_id:
                    button.disabled = disable
                else: pass
            __SecList.append(button)
        __tempList.append(__SecList)
    return __tempList```
Obviously, it goes through all the contained components of the passed ctx and adjusts the state of the components I need
west grove
#

I wonder why does this situation only appear in ComponentContext 😭

pliant agate
west grove
#

Just can run ctx.send normally

#

now it told me Interaction has already been acknowledged.

dim quartz
#

Edit origin is a interaction initial response

#

Send is an interaction initial response

#

You can't mix them

#

Use ctx.edit instead. It can be mixed with the other 2

west grove
dim quartz
west grove
#

it will return a error about Ignoring exception in Component(): HTTPException: 404|Not Found || Unknown Webhook

west grove
# dim quartz Ctx.message.id

it's under @listen() and ctx = event.ctx, event type is Component
I just edit the components when the button clicked

#

And the code I write

    @listen()
    async def on_component(self, event: Component, **kwargs):
        ctx = event.ctx
        # Fast / Relax Mode
        if "Fast" or "Relax" in ctx.custom_id:
            ...
            if response[0]:
                ...
                await ctx.edit(ctx.message.id, components = ActionRow(...))
                await ctx.send("finish")
#

and ComponentContext can't send_modal yet ,emmmmm, anyway can I get others Context in Listen()?

west grove
#

ok
I find a way
use get_channel first ,then I can send anything
maybe it doesn't the simplest way but temporary enough