// Misc. public async void TryToken() { try { DiscordAPI d = new DiscordAPI(); JToken res = await d.GetSelfAsync(config.Token); _pfp.Source = new BitmapImage(GetAvatarUri(res)); _preUsername.Text = "Logged in as:"; _username.Text = res["username"].ToString(); this._refreshServerList.IsEnabled = true; } catch { _accountComboBox.IsDropDownOpen = true; //_username.Text = "[Invalid token!]"; } }
public async void DetectTokens(object sender, RoutedEventArgs e) { // if list is empty and you hover over it, then load it, otherwise dont trigger loading if (sender is ComboBox && AccountsComboBox.Count != 0) { return; } AccountsComboBox.Clear(); try { DiscordAPI d = new DiscordAPI(); JToken res = await d.GetSelfAsync(config.Token); ViewGuild itp = new ViewGuild { Image = new BitmapImage(GetAvatarUri(res)), Name = res["username"].ToString(), Id = config.Token, IsSelectable = true }; AccountsComboBox.Add(itp); } catch { ViewGuild itp = new ViewGuild { Image = new BitmapImage(new Uri(@"pack://*****:*****@"[A-Za-z0-9_\./\\-]*")) { foreach (Capture capture in match.Captures) { // theoretically it should be (capture.Value.Length == 88 || capture.Value.Length == 59) // but I don't trust it with the whole 2FA etc, so we will take more chances, doesnt matter for the user if (capture.Value.Length < 95 && capture.Value.Length > 50) { // don't attempt to use this token if its already in the config if (AccountsComboBox.Where(cb => cb.Id == capture.Value).Count() > 0) { continue; } try { DiscordAPI d = new DiscordAPI(); JToken res = await d.GetSelfAsync(capture.Value); ViewGuild itp = new ViewGuild { Image = new BitmapImage(GetAvatarUri(res)), Name = res["username"].ToString(), Id = capture.Value, IsSelectable = true }; AccountsComboBox.Add(itp); } catch { // ... } } } } } } }