Archived
0
0
Fork 0

fix: crashing if user nickname is null

This commit is contained in:
Daryl Ronningen 2021-12-23 19:14:38 -08:00
parent 70bbade763
commit 6b75d8e446
Signed by: Daryl Ronningen
GPG key ID: FD23F0C934A5EC6B

View file

@ -259,12 +259,15 @@ namespace chord
foreach (var users in roles.Members)
{
var userName = Regex.Replace(users.Username, @"[^\u0000-\u007F]+", string.Empty);
var userNick = Regex.Replace(users.Nickname, @"[^\u0000-\u007F]+", string.Empty);
node.Children.Add(new TreeNode($"{userNick}#{users.Discriminator} ({userNick})"));
string userNick = string.Empty;
if (users.Nickname != null)
userNick = Regex.Replace(users.Nickname, @"[^\u0000-\u007F]+", string.Empty);
node.Children.Add(new TreeNode($"{userName}#{users.Discriminator} ({userNick})"));
}
rolesDict.Add(roles.Position, node);
rolesDict.TryAdd(roles.Position, node);
}
foreach (var role in rolesDict)
@ -276,7 +279,8 @@ namespace chord
rpcClient.UpdateState($"In channel {client.GetGuild(currentSelectedGuild).GetTextChannel(currentSelectedChannel).Name}");
rpcClient.UpdateStartTime();
}
} catch {
} catch(Exception err) {
Console.WriteLine(err);
await chatBoxList.SetSourceAsync(new List<string>());
}
};