Open solaris7x opened 2 years ago
Hey! 👋 Thanks for reporting this. From that related issue it looks like this is an API limitation. I wonder if it's possible to return flags here though: https://github.com/mrbbot/slshx/blob/77c5d8c466843232da8caa1001c032f25874488c/src/interactions/response.ts#L48-L51 Could maybe do something like:
function beepGen(): CommandHandler<Env> {
useDescription("Send a boop");
return async function* (interaction, env, ctx) {
// Remove yield below and message will be ephemeral as expected
yield $ephemeral;
return <Message ephemeral>🤖 Boop from slshx 🤖</Message>;
};
}
As far as I understand from the referred issue , the ephemeral state cannot be changed by the follow up message but only the content , thus to make a message ephemeral , the 1st instance of it should be passed flag ephemeral
I think this could be done by passing the flags
to data
property of APIInteractionResponseDeferredChannelMessageWithSource
export interface APIInteractionResponseDeferredChannelMessageWithSource {
type: InteractionResponseType.DeferredChannelMessageWithSource;
data?: Pick<APIInteractionResponseCallbackData, 'flags'>;
}
TL;DR :
Messages are not set as ephemeral when deferring response using yield in function generators
Info:
I need to perform an async request thus I use function generator to defer the discord response until my network operations are complete , To do so I used function generators to yield discord then return proper response after the network operation.
Using
yield
causes discord message to NOT be ephemeral and thus visible to everyone . I tried both<Message>
and returning Object with content +flags: 64
Demo command handler:
Expected:
Message response for above function to be ephemeral and only visible to invoker of discord command
Related
https://github.com/discordjs/discord.js/issues/5702