public async Task AnnounceAsync(Embed embed, bool addReactions = true, bool pingRole = true) { var announcements = await _dbContext.Announcements.ToListAsync(); foreach (var announcement in announcements) { var channel = _client.GetGuild(announcement.GuildId) ?.GetTextChannel(announcement.ChannelId); if (channel == null) { continue; } var role = pingRole ? channel.Guild.Roles.FirstOrDefault(x => x.Name == _configuration["UserUpdates:RoleName"]) : null; var message = await channel.SendMessageAsync(role?.Mention, embed : embed); if (message == null) { continue; } await _dataFormatter.AddReactions(message); } }
public async Task CovidAsync() { var embed = _dataFormatter.GetEmbed(); if (embed == null) { await ReplyAsync("Couldn't retrieve recent COVID-19 data."); return; } var message = await ReplyAsync(embed : embed); if (message == null) { return; } await _dataFormatter.AddReactions(message); }