fix: crashing if user nickname is null
This commit is contained in:
parent
70bbade763
commit
6b75d8e446
1 changed files with 8 additions and 4 deletions
12
Program.cs
12
Program.cs
|
@ -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>());
|
||||
}
|
||||
};
|
||||
|
|
Reference in a new issue