From 32242c9cb4011955983919e553eef2a62e611327 Mon Sep 17 00:00:00 2001 From: Adam R Grey Date: Wed, 22 Feb 2023 16:45:49 -0500 Subject: [PATCH] more shtikbot error handling --- Features.cs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/Features.cs b/Features.cs index 9cc269b..0764c47 100644 --- a/Features.cs +++ b/Features.cs @@ -23,14 +23,16 @@ namespace silverworker_discord ytdl.FFmpegPath = "ffmpeg"; ytdl.OutputFolder = ""; ytdl.OutputFileTemplate = "tiktokbad.%(ext)s"; - var res = await ytdl.RunVideoDownload(link.ToString()); - if (!res.Success) + try { - Console.Error.WriteLine("tried to dl, failed. \n" + string.Join('\n', res.ErrorOutput)); - await message.AddReactionAsync(Emote.Parse("<:problemon:859453047141957643>")); - await message.Channel.SendMessageAsync("tried to dl, failed. \n" + string.Join('\n', res.ErrorOutput)); - } - else + var res = await ytdl.RunVideoDownload(link.ToString()); + if (!res.Success) + { + Console.Error.WriteLine("tried to dl, failed. \n" + string.Join('\n', res.ErrorOutput)); + await message.AddReactionAsync(Emote.Parse("<:problemon:859453047141957643>")); + await message.Channel.SendMessageAsync("tried to dl, failed. \n" + string.Join('\n', res.ErrorOutput)); + } + else { string path = res.Data; if (File.Exists(path)) @@ -51,6 +53,12 @@ namespace silverworker_discord await message.AddReactionAsync(Emote.Parse("<:problemon:859453047141957643>")); } } + } + catch (Exception e) + { + Console.Error.WriteLine(e); + await message.AddReactionAsync(Emote.Parse("<:problemon:859453047141957643>")); + } } public static async void deheic(SocketUserMessage message, Attachment att) {