public async Task AlertTeam(SocketGuildUser user) { // Locate TownGuild in the database var guild = database.GetGuild(user.Guild); // TextChannel where Notifications go var alertChannel = user.Guild.GetTextChannel(guild.LeaverChannel); // Fetch the user's TownResident entry var townUser = database.GetUser(user); await alertChannel.SendMessageAsync("The user: "******" left. They joined: " + townUser.InitialJoin.ToString("dd/MMM/yyyy hh:mm: tt")); }
Task Handle(SocketMessage message) { TownUser user = database.GetUser(message.Author); if (user.Scoring == null) { user.Scoring = new UserScoring(); } UserScoring scoring = user.Scoring; DateTime now = DateTime.UtcNow; if ((now - scoring.LastMessage).TotalMinutes > 1) { if (scoring.UsedHourPoints > 0) { if ((now - scoring.UsedFirstHourPoint).TotalHours > 1) { scoring.UsedHourPoints = 0; } } if (scoring.UsedHourPoints < 20) { if (scoring.UsedHourPoints == 0) { scoring.UsedFirstHourPoint = now; } scoring.UsedHourPoints++; scoring.Score += 10; scoring.LastMessage = now; } } return Task.CompletedTask; }