#105 Added check if user is assigned during server nickname fetching

This commit is contained in:
Serraniel 2021-12-16 14:41:05 +01:00
parent cced819e77
commit 767b2b35d1
Signed by: Serraniel
GPG key ID: 3690B4E7364525D3

View file

@ -240,7 +240,11 @@ namespace DML.AppCore.Classes
serverName = socketTextChannel.Guild.Name;
serverName = Path.GetInvalidFileNameChars()
.Aggregate(serverName, (current, c) => current.Replace(c, ' '));
nickname = socketTextChannel.GetUser(message.Author.Id).Nickname;
var serverUser =
socketTextChannel.GetUser(message.Author.Id); // can be null if user left the server
if (serverUser != null)
nickname = serverUser.Nickname;
}
var channelName = message.Channel.Name;