hey guys this is the first time I ever use this framework this should be an easy one for you
i'm trying to have my response to slash command visible to everyone but I struggle to set ephemeral value
it's default is false so everyone should see the message I don't know what's wrong
i was experimenting with FollowupAsync, RespondAsync, ReplyAsync methods but none worked for me
help much appreciated
#issue with setting ephemeral while responding to slash command
1 messages · Page 1 of 1 (latest)
`using Discord.Commands;
using Discord.Interactions;
using DiscordUrbanDictionaryBot.Service.Command;
using Summary = Discord.Interactions.SummaryAttribute;
namespace DiscordUrbanDictionaryBot.Service.Modules;
public class DictionaryModule(IUrbanDictionaryCommand command) : InteractionModuleBase
{
[SlashCommand("urbandictionary", "Print the first definition found on urban dictionary for a given phrase")]
public async Task UrbanDictionary([Summary("phrase", "the phrase you want to look up in the dictionary")] string phrase, [Summary("public", "whether you want everyone to see the response")] bool @public = false)
{
var deferTask = DeferAsync(true);
var dictionaryResult = await command.ExecuteAsync(phrase);
var messageToPrint = string.Join(Environment.NewLine, dictionaryResult.Messages);
await deferTask;
if (@public && dictionaryResult.Success)
{
//await ReplyAsync($"{Context.User.Mention} {messageToPrint}");
await FollowupAsync("test2",ephemeral: false);
//await ModifyOriginalResponseAsync(r =>
//{
// r.Content = "Command executed.";
//});
}
else
{
await ModifyOriginalResponseAsync(r =>
{
r.Content = messageToPrint;
});
}
}
}`
if you DeferAsync() and then do something like ModifyAsync() or FollowupAsync() and you want the repsonse to be ephemeral you have to set it in the DeferAsync()
so by setting DeferAsync(true) your repsonse no matter what you specifiy in the other methods will be ephemeral (afaik)
oh yeah I forgot there is this parameter too