public async Task SendReminderAsync(int reminderId) { var reminderInfo = _dynamicConfiguration.ScheduledReminderInfos.SingleOrDefault(m => m.ReminderId == reminderId); if (reminderInfo == null) { return; } var(channelID, message) = reminderInfo.GetReminderDetails(); await _discordAccess.CreateBotMessagesInChannelAsync(channelID, new[] { message }); }
public async Task ApplyRoleAsync() { var birthdayRoleId = (DiscordRoleId)_dynamicConfiguration.DiscordMapping[BirthdayRoleIdKey]; var birthdayUsers = await _birthdayProvider.GetBirthdaysAsync(DateOnly.FromDateTime(DateTime.UtcNow)); var userIdsWithAppliedRole = new List <DiscordUserId>(birthdayUsers.Length); foreach (var userId in birthdayUsers) { if (!_discordAccess.CanManageRolesForUser(userId)) { continue; } var(success, _) = await _discordAccess.TryAddNonMemberRole(userId, birthdayRoleId); if (success) { userIdsWithAppliedRole.Add(userId); } else { await _discordAccess.LogToDiscord($"{_discordAccess.GetLeadershipMention()}: " + $"Failed to apply role {birthdayRoleId.ToMention()} to {userId.ToMention()}."); } } if (userIdsWithAppliedRole.Count == 0) { return; } var birthdayAnnouncementChannelId = (DiscordChannelId)_dynamicConfiguration.DiscordMapping[BirthdayAnnouncementChannelIdKey]; var messages = userIdsWithAppliedRole.Select(m => "HoU wishes a Happy Birthday to our latest Birthday Yata, " + $"{m.ToMention()}. Have an amazing day filled with fun!!!") .ToArray(); await _discordAccess.CreateBotMessagesInChannelAsync(birthdayAnnouncementChannelId, messages); }