public async Task CleanTempDir([Summary("The type of temp files to delete. Possible values: `images, media, text, all (default value)`")] string filter = "all") { AttachmentFilter filterType; switch (filter) { case "all": default: filterType = AttachmentFilter.All; break; case "images": filterType = AttachmentFilter.Images; break; case "media": filterType = AttachmentFilter.Media; break; case "text": filterType = AttachmentFilter.Plaintext; break; } List <string> files = AttachmentHelper.GetTempAssets(filterType); if (files.Count == 0) { await ReplyAsync("No temp files to delete."); } else { AttachmentHelper.DeleteFiles(files); await ReplyAsync($"Deleted {files.Count} temp files."); } }
public async Task ListTempDir() { List <string> tempFiles = AttachmentHelper.GetTempAssets(); if (tempFiles.Count == 0) { await ReplyAsync("`empty`"); } else { string fileList = string.Empty; //build a list of filenames (no paths included) foreach (string filePath in tempFiles) { fileList += Path.GetFileName(filePath) + Environment.NewLine; } fileList = $"```{Environment.NewLine}{fileList}{Environment.NewLine}```"; await ReplyAsync(fileList); } }