#How do I check whether a server nickname was changed?

1 messages · Page 1 of 1 (latest)

random parrot
#

Hi, I wanted to ask if anyone can see the problem why my code doesn't reach that last errorLogChannel output that a nickname change was triggered.
Code:

// in main method
// ...
_client.GuildMemberUpdated += GuildMemberUpdatedHandler;
// ...
// still in Program.cs
        private async Task GuildMemberUpdatedHandler(Cacheable<SocketGuildUser, ulong> beforeCached, SocketGuildUser after) 
         { 
             Console.WriteLine("Guild Member updated."); 
             var before = await beforeCached.GetOrDownloadAsync(); 
             var eventHandler = new UserUpdatedHandler(_redis, _client, before, after); 
             await eventHandler.StartHandlerAsync(); 
         }
// in UserUpdatedHandler
        public async Task StartHandlerAsync() 
         { 
             await UpdateUserLog(); 
         }

        private async Task UpdateUserLog() 
         {
            // some code

            if (_userBefore.Roles != _userAfter.Roles) 
                 {
                      // code for that
                  }
              else if (_userBefore.Username != _userAfter.Username)
                  {
                       // code for that
                  }
               else if (_userBefore.Nickname != _userAfter.Nickname)
                  {
                      // some code
                      await errorLogChannel.SendMessageAsync("nickname update triggered");
                   }
                 // ....

No errors are thrown but no nickname update is sent either...

vestal niche
#

Use debugger and step through your code. But I'd imagine the first if statement with the Roles will always be true.

random parrot
random parrot
#

ok I changed it to roles.count now and it works, so thanks!

vestal niche