示例#1
0
 private async Task _client_UserUpdated(USerDTO arg1, SocketUser arg2, ulong GuildID)
 {
     foreach (var item in List)
     {
         if (GuildID == item.GuildID)
         {
             if (((arg1.Status == UserStatus.Offline || arg1.Status == UserStatus.Invisible) && (arg2.Status == UserStatus.Online || arg2.Status == UserStatus.Idle || arg2.Status == UserStatus.AFK || arg2.Status == UserStatus.DoNotDisturb)) || item.allstatus)
             {
                 try
                 {
                     var channel = _client.GetChannel(item.ChannelID) as SocketTextChannel;
                     if (item.prefix != null)
                     {
                         await channel.SendMessageAsync(item.prefix.Replace("[USER]", arg1.Username).Replace("[STATUS1]", arg1.Status.ToString()).Replace("[STATUS2]", arg2.Status.ToString()));
                     }
                     else
                     {
                         await channel.SendMessageAsync(arg1.Username + " went from status " + arg1.Status.ToString() + " to " + arg2.Status.ToString());
                     }
                 }
                 catch (Exception)
                 {
                     await Program.Log("Cant find channel!", ConsoleColor.Red);
                 }
             }
         }
     }
 }
示例#2
0
 private void TimerEvent()
 {
     foreach (var guild in _client.Guilds)
     {
         if (guildAndUsers.Exists(x => x.Guild.Id == guild.Id))
         {
             var thing = guildAndUsers.Single(x => x.Guild.Id == guild.Id);
             foreach (var user in guild.Users)
             {
                 if (!thing.Users.Exists(x => x.UserID == user.Id))
                 {
                     USerDTO u = new USerDTO();
                     u.UserID   = user.Id;
                     u.Username = user.Username;
                     u.Status   = user.Status;
                     thing.Users.Add(u);
                 }
                 else
                 {
                     var thinguser = thing.Users.Single(x => x.UserID == user.Id);
                     if (thinguser.Status != user.Status)
                     {
                         _client_UserUpdated(thinguser, user, guild.Id);
                         thinguser.Status = user.Status;
                     }
                 }
             }
         }
         else
         {
             GuildAndUsers Item = new GuildAndUsers();
             Item.Guild = guild;
             List <USerDTO> newitup = new List <USerDTO>();
             foreach (var user in guild.Users)
             {
                 USerDTO u = new USerDTO();
                 u.UserID   = user.Id;
                 u.Username = user.Username;
                 u.Status   = user.Status;
                 newitup.Add(u);
             }
             Item.Users = newitup;
             guildAndUsers.Add(Item);
         }
     }
 }