I've checked documentation as well as on this discord to find a fix but I don't seem to be finding any?
I tried what was also said in general about sync'ing your PC date and time and that also didn't work.
Essentially the code works correctly, no issues there but despite every part of it working it for some reason throws an "Application did not respond".
The command is a purge command
public class Purge: InteractionModuleBase<SocketInteractionContext>
{
[SlashCommand("purge", "Purges a certain amount of messages")]
[RequireUserPermission(GuildPermission.ManageMessages)]
// Purge a certain amount of messages
public async Task PurgeMessages(int amount)
{
EmbedBuilder embed = new();
embed.WithTitle("Purge Command");
embed.WithColor(0x0502828);
embed.WithCurrentTimestamp();
embed.WithFooter(x => x.Text = "Eclipse - Purge Command");
if (amount <= 0)
{
embed.WithDescription("You did not provide a valid amount of messages to purge.");
await RespondAsync(embeds: new[] { embed.Build() }, ephemeral: true);
return;
}
else if(amount > 100)
{
embed.WithDescription("You cannot purge more than 100 messages at once.");
await RespondAsync(embeds: new[] { embed.Build() }, ephemeral: true);
}
try
{
var messages = await Context.Channel.GetMessagesAsync(amount).FlattenAsync();
await (Context.Channel as SocketTextChannel).DeleteMessagesAsync(messages);
embed.WithDescription("Purged " + amount + " messages.");
var _Message = await ReplyAsync(embeds: new[] { embed.Build() });
await Task.Delay(2000);
await _Message.DeleteAsync();
}
catch (Exception ex)
{
embed.WithDescription("An error occurred while purging messages: " + ex.Message);
await RespondAsync(embeds: new[] { embed.Build() }, ephemeral: true);
}
}
}
I don't have any usings here because I already declared them as globals