Ejemplo n.º 1
0
        private async void SaveUserSettings()
        {
            var modify = new DiscordAPI.API.User.Models.ModifyUserSettings(LocalState.Settings);

            if (Filtering2.IsChecked == true)
            {
                modify.ExplicitContentFilter = 2;
            }
            else if (Filtering1.IsChecked == true)
            {
                modify.ExplicitContentFilter = 1;
            }
            else
            {
                modify.ExplicitContentFilter = 0;
            }

            //modify.FriendSourceFlag.All = FriendRequest0.IsChecked == true;
            //modify.FriendSourceFlag.MutualFriends = FriendRequest1.IsChecked == true;
            //modify.FriendSourceFlag.MutualGuilds = FriendRequest2.IsChecked == true;

            LocalState.Settings = await RESTCalls.ModifyUserSettings(modify);

            CloseButton_Click(null, null);
        }
Ejemplo n.º 2
0
        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);
        }