private void SendMessage() { if (_selectedChannel != null) { try { PleaseWait(() => { var embed = CheckWhatToSend_ThreadSafe(); if (embed.Thumbnail == null) { _selectedChannel.SendMessageAsync(null, false, embed); } else { _selectedChannel.SendFileAsync(_selectedImagePath, string.Empty, false, embed, RequestOptions.Default); } }); ShowMessage(this, "Message sent to Discord."); } catch (Exception e) { Debug.WriteLine(e); DumpFile.Create(e); throw; } } else { ShowMessage(this, "Please select a channel to continue.", "Select Channel", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }
private static void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { //update Logs Log.Exception(e.Exception.Message); // Process unhandled exception DumpFile.Create(e.Exception); // Prevent default unhandled exception processing e.Handled = true; }
private static void MyHandler(object sender, UnhandledExceptionEventArgs args) { var e = (Exception)args.ExceptionObject; // update Logs Log.Exception(e.Message); // Process unhandled exception DumpFile.Create(e); }
private void PopulateChannelDropdown() { try { Dispatcher.Invoke(() => { var channelItems = _channels .Select(s => new ComboBoxItem { Content = (s.Category == null ? $"{s.Name} " : $"({s.Category?.Name}) {s.Name} "), Tag = s.Id }) .OrderBy(o => o.Content).ToList(); channelItems.ForEach(item => cmbChannelPicker.Items.Add(item)); }, DispatcherPriority.ContextIdle); } catch (Exception e) { Debug.WriteLine(e); DumpFile.Create(e); throw; } }
private void GetSettings() { try { var settingsFile = myFiles.Json.Settings; if (!File.Exists(settingsFile)) { JsonFile.Create <Settings>(settingsFile, new JsonObjects.Empty().Settings()); } if (File.Exists(settingsFile)) { var settings = JsonFile.Load <Settings>(settingsFile); _serverName = settings.ServerName; _botToken = settings.BotToken; } } catch (Exception e) { Debug.WriteLine(e); DumpFile.Create(e); throw; } }