#help with auto deletion of my bot message
1 messages · Page 1 of 1 (latest)
How can I do it, is there a different method?
but yeah this is a quirk of interactions: to get the object you have to call context.GetOriginalResponseAsync
how should i fix my code where should i add it
.
well, you can only get the message after creating it
var originalResponse = await ctx.GetOriginalResponseAsync();
like this?
yes
i tried, but its not deleted.
try DeleteResponseAsync
DeleteResponseAsync is not found
... on the context
await ctx.DeleteResponseAsync(); works for me
Its not work for me.
await ctx.CreateResponseAsync("...", true);
await ctx.DeleteResponseAsync();
Works for me
So not sure what the issue is
mind telling us what the error at work is
public async Task ValorantCommand(InteractionContext ctx)
{
if (ctx.Channel.Id == 1095631316545962034)
{
DateTime currentTime = DateTime.Now;
ulong userId = ctx.User.Id;
if (lastUsage.ContainsKey(userId))
{
DateTime lastUsageTime = lastUsage[userId];
TimeSpan timeSinceLastUsage = currentTime - lastUsageTime;
TimeSpan timeRemaining = TimeSpan.FromHours(6) - timeSinceLastUsage;
string timeRemainingString = $"{(int)timeRemaining.TotalHours} Saat, {timeRemaining.Minutes} Dakika, {timeRemaining.Seconds} Saniye";
if (timeSinceLastUsage.TotalHours < 6)
{
var embed = new DiscordEmbedBuilder()
.WithTitle("VTP - Discord")
.WithDescription($"Bu komudu kullanmak için {timeRemainingString} beklemelisiniz.")
.WithColor(DiscordColor.Magenta)
.WithFooter($"{currentTime.ToString("dd/MM/yyyy HH:mm:ss")}");
await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder().AddEmbed(embed).AsEphemeral(true));
await ctx.DeleteResponseAsync();
return;
}
}
lastUsage[userId] = currentTime;
await Send(ctx, Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\Valorant.txt", true);
}
}

all my codes
Any error messages?
nope