#help with auto deletion of my bot message

1 messages · Page 1 of 1 (latest)

unborn sapphire
#

.NET Framework is unsupported, on a side note

sage swallow
#

How can I do it, is there a different method?

unborn sapphire
#

but yeah this is a quirk of interactions: to get the object you have to call context.GetOriginalResponseAsync

sage swallow
#

.

unborn sapphire
#

well, you can only get the message after creating it

sage swallow
#

var originalResponse = await ctx.GetOriginalResponseAsync();

like this?

unborn sapphire
#

yes

sage swallow
#

i tried, but its not deleted.

unborn sapphire
#

try DeleteResponseAsync

sage swallow
#

DeleteResponseAsync is not found

unborn sapphire
#

... on the context

magic karma
#

await ctx.DeleteResponseAsync(); works for me

sage swallow
#

Its not work for me.

magic karma
#
await ctx.CreateResponseAsync("...", true);
await ctx.DeleteResponseAsync();

Works for me

#

So not sure what the issue is

unborn sapphire
#

mind telling us what the error at work is

sage swallow
#
  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);
        }
    }
unborn sapphire
sage swallow
#

all my codes

magic karma
#

Any error messages?

sage swallow
#

nope

unborn sapphire
#

have you hooked SlashCommandErrored

#

actually, come to think of it, try removing the .AsEphemeral

#

for testing purposes anyway

sage swallow
#

ok i solve thanks.

#

❤️

#

actually its was deleting it, I looked at the different message lol.