#how do i delete an ephemeral interaction?

1 messages · Page 1 of 1 (latest)

viscid field
#

i tried await e.Interaction.DeleteOriginalResponseAsync();

#

(it gave me error 404)

split cedar
#

you dont

#

only the user can get rid of that message

#

all you can do is update the message to an empty message, or to say "Done" or something like that

viscid field
#

how do i access the original message

#

like "it"

fair elm
split cedar
#

depends if it is the original response or a followup, but generally there should be a Get<Original/Followup>MessageAsync method on your interaction object

split cedar
#

or the user already dismissed it?

viscid field
# fair elm

i struggle to wrap my head around what that means

#

maybe i've been coding for too long

#

i need to use whatever interaction that contained the panel interaction?

#

to delete it?

#

like the slash command?

split cedar
#

i means that you can only delete the ephemeral message through the interaction that made it

viscid field
#

so, in my case, a slash command

split cedar
#

yeah guess so

viscid field
#

but i'm listening to the ComponentInteractionCreatedEvent

#

so it's quite a long reach

#

[2023-02-05 19:38:53 +02:00] [108 /WebSocketRec] [Error] Socket handler suppressed an exception
System.NullReferenceException: Object reference not set to an instance of an object.
at DSharpPlus.DiscordClient.OnReadyEventAsync(ReadyPayload ready, JArray rawGuilds, JArray rawDmChannels)
at DSharpPlus.DiscordClient.HandleDispatchAsync(GatewayPayload payload)
at DSharpPlus.DiscordClient.HandleSocketMessageAsync(String data)
at DSharpPlus.DiscordClient.<InternalConnectAsync>g__SocketOnMessage|484_1(IWebSocketClient sender, SocketMessageEventArgs e)

#

what does mean lol

#

apparently newer versions of dsharpplus are bad

fair elm
#

What version are you using?

viscid field
#

i fixed it by going back to stable 4.3.0

#

i used 4.4.0-nightly-01260 and 4.4.0-nightly-01259

#

gave up after trying those two and reverted to stable

#

idk what i had originally

#

can check if super important (git)

#

more importantly, how do i modify the contents of the interaction 😭 i keep getting 404

fair elm
#

Use nightly 1258

viscid field
#

await e.Message.ModifyAsync("Test");
e.Interaction.EditOriginalResponseAsync(new DiscordWebhookBuilder().WithContent("Test"));

#

none of these worked

viscid field
split cedar
viscid field
#

i'm on the event

#

ComponentInteractionCreatedEvent

#

not on the slash command

#

this is after getting what the user selected

split cedar
#

so you have a slash command that creates an ephemeral message with a button or a dropdown?

viscid field
#

and after it sends the channel, it should delete itself (the first message)

split cedar
#

yeah then you cant delete or modify the message from the componentinteractioncreated event

viscid field
#

i've noticed 😭

#

are there any alternatives

split cedar
#

you could use interactivity to wait for the components event in the slash command method

viscid field
#

this is waiting for the user though

#

user can take 2 sec or a minute

#

is there a safe way to wait for that?

#

how long will the interaction even be alive for?

split cedar
#

as long as you already responded you can take i think up to 5 mins until the interaction goes invalid

viscid field
#

i see

split cedar
#

and interactivity has a timeout you can set, so you can give the user say 2 mins to do what they want, and if they dont thelly have to rerun the command

viscid field
#

i see

#

can i not make it a 1 time use?

#

for that interaction in particular

#

i don't want them to spam mentions easily

split cedar
#

you can make it 2 seconds if you like

viscid field
#

or by accident

#

yes but if they don't use it in 2 seconds (slow hands) f

split cedar
#

yep

viscid field
#

ig i'll just leave it like this for now

#

discord is weird

split cedar
#

you can make it any timespan so...

#

i think default might be 2 mins or so

#

you can change the app wide default in your interactivity configuration, and then you can also specify a per use timeout separately

#

for that you just pass a timespan iirc

#

or you can even pass a CancellationToken

viscid field
#

yeah that seems like an awful lot of work for a first project 😅

#

i'll keep that in mind for my third refactor

split cedar
#

already planning third refactor when doing one rn? xD

shell sky
split cedar
#

Yeah already found

#

Didnt see that update

shell sky
#

Acknowledge the interaction with a response (such as DeferredMessageUpdate) and then delete the original response.

viscid field
#

in the MessageDeletedEvent, the Guild is set to null

#

is that normal?

shell sky
#

Possibly?