private async void SaveGuildSettings(object sender, RoutedEventArgs e) { saveBTNtext.Opacity = 0; SaveButton.IsEnabled = false; saveBTNprog.Visibility = Visibility.Visible; try { DiscordAPI.API.Guild.Models.ModifyGuild modifyguild; if (string.IsNullOrEmpty(base64img)) { modifyguild = new DiscordAPI.API.Guild.Models.ModifyGuild() { Name = GuildName.Text, AfkTimeout = LocalState.Guilds[guildId].Raw.AfkTimeout, VerificationLevel = GetVfLvl(), ExplicitContentFilter = GetECFLvl() } } ; else { modifyguild = new DiscordAPI.API.Guild.Models.ModifyGuildIcon() { Name = GuildName.Text, Icon = base64img, AfkTimeout = LocalState.Guilds[guildId].Raw.AfkTimeout, VerificationLevel = GetVfLvl(), ExplicitContentFilter = GetECFLvl() } }; if (DeletedImage) { modifyguild = new DiscordAPI.API.Guild.Models.ModifyGuildIcon() { Name = GuildName.Text, Icon = null, AfkTimeout = LocalState.Guilds[guildId].Raw.AfkTimeout, VerificationLevel = GetVfLvl(), ExplicitContentFilter = GetECFLvl() } } ; await Task.Run(async() => { await RESTCalls.ModifyGuild(guildId, modifyguild); }); CloseButton_Click(null, null); } catch (Exception) { MessageDialog md = new MessageDialog("Something went wrong, and we weren't able to delete the invite.", "Sorry :/"); saveBTNtext.Opacity = 1; SaveButton.IsEnabled = true; saveBTNprog.Visibility = Visibility.Collapsed; } var settings = LocalState.Settings; var modify = new DiscordAPI.API.User.Models.ModifyUserSettings(LocalState.Settings); if (AllowDMs.IsChecked == true && modify.RestrictedGuilds != null && modify.RestrictedGuilds.Contains(guildId)) { var list = modify.RestrictedGuilds.ToList(); list.Remove(guildId); modify.RestrictedGuilds = list.ToArray(); } else if (modify.RestrictedGuilds != null && !modify.RestrictedGuilds.Contains(guildId)) { var list = modify.RestrictedGuilds.ToList(); list.Add(guildId); modify.RestrictedGuilds = list.ToArray(); } else { modify.RestrictedGuilds = new string[] { guildId }; } LocalState.Settings = await RESTCalls.ModifyUserSettings(modify); }