protected virtual async Task SendMessage(Embed result) { if (Statics.Debug) { await Statics.DebugSendMessageToChannelAsync(Client, result); } else { await ReplyAsync(embed : result); } }
private async Task SendMessage(Embed result) { if (Statics.Debug) { await Statics.DebugSendMessageToChannelAsync(_client, result); } else { await ReplyAsync(embed : result); } }
//gameName is for Twitch. protected virtual async Task <string> UpdateSocialMedia(IEnumerable <SocialMediaUserData> socialMediaUsers, Tuple <string, string> streamerInfo = null) { //Save guild ID's and channel ID's to avoid repetition List <ulong> usedGuildIDs = new List <ulong>(); List <ulong> usedChannelIDs = new List <ulong>(); List <SocialMediaUserData> users = socialMediaUsers.ToList(); //Loop through all updated social media. string message = string.Empty; for (int i = 0; i < users.Count; i++) { ulong debugGuildId = ulong.Parse(Config["IDs:Guild"]); ulong guildId = Statics.Debug ? debugGuildId : users[i].GuildId; ulong channelId = Statics.Debug ? Statics.DebugChannelId : users[i].ChannelId; //Checks if usedGuildIDs contains anything to see if the IDs has been posted already. if (usedGuildIDs.Count > 0) { //Checks if both guild and channel ID's has been used. if (UsedId(usedGuildIDs, guildId) && UsedId(usedChannelIDs, channelId)) { continue; } } //Loops through updated social media with the same channel and guild ID. for (int j = 0; j < users.Count; j++) { //Adds all updated social media within the same server and channel. //Adds them into a string so the bot can post once. if ((guildId == users[j].GuildId && channelId == users[j].ChannelId) || Statics.Debug) { //Add more cases here if more social media is added. switch (TypeOfSocialMedia) { case "twitch": message += GetStreamerUrlAndGame(users[j], streamerInfo); break; case "twitter": message += GetTwitterUrl(users[j]); break; case "youtube": message += GetYouTuber(users[j]); break; } usedGuildIDs.Add(guildId); usedChannelIDs.Add(channelId); } } if (string.IsNullOrEmpty(message)) { continue; } //Posts the updated social media. if (Statics.Debug) { await Statics.DebugSendMessageToChannelAsync(Client, message); } else { try { await Client.GetGuild(guildId).GetTextChannel(channelId).SendMessageAsync(message); } catch { //Ignore } } return(await Task.FromResult(message)); } return(await Task.FromResult(string.Empty)); }