// Tweets for announcments to discord public async void GetTweetAsync(object source, ElapsedEventArgs e) { try { var twitter = new Twitter { OAuthConsumerKey = Creds.TwitterOauthKey, OAuthConsumerSecret = Creds.TwitterOauthSecret, AccessToken = Creds.TwitterAccessToken, AccessKey = Creds.TwitterAccessSecret }; ulong channelid = new ulong(); string tweetchannel = ""; bool everyonetag = false; using (var db = new LiteDatabase(@"Config.db")) { var DatabaseConfig = db.GetCollection <DatabaseConfig>("DatabaseConfig"); var config = DatabaseConfig.FindOne(x => x.Id.Equals(1)); if (DatabaseConfig.Count() == 0) { config = new DatabaseConfig { Everyonetag = false, TweetChannel = "announcements" }; DatabaseConfig.Insert(config); } tweetchannel = config.TweetChannel; everyonetag = config.Everyonetag; } // Guardian ID 405513567681642517 // Bot Test 486327167035244554 foreach (var channelparser in Client.GetGuild(405513567681642517).TextChannels) { if (channelparser.Name.Trim().ToLower() == tweetchannel.ToLower().Trim()) { channelid = channelparser.Id; break; } } List <Tweet> twitts = twitter.GetTwitts("GuardianWire", 15); bool tweeted = false; foreach (var t in twitts) { if (Lastrun <= t.created_at) { if (t.text != String.Empty) { await Client.GetGuild(405513567681642517).GetTextChannel(channelid).SendMessageAsync(t.text); tweeted = true; } if (t.media != null && t.video == null) { await Client.GetGuild(405513567681642517).GetTextChannel(channelid).SendMessageAsync(t.media); tweeted = true; } if (t.url != null) { await Client.GetGuild(405513567681642517).GetTextChannel(channelid).SendMessageAsync(t.url); tweeted = true; } if (t.video != null) { await Client.GetGuild(405513567681642517).GetTextChannel(channelid).SendMessageAsync(t.video); tweeted = true; } } } if (tweeted == true) { if (everyonetag == true) { await Client.GetGuild(405513567681642517).GetTextChannel(channelid).SendMessageAsync("@everyone"); } } Lastrun = DateTime.UtcNow; } catch { } }