/// <summary> /// Posts a new announcement message /// </summary> /// <param name="embed">Message to post</param> /// <returns>No object or value is returned by this method when it completes.</returns> private async Task PostAnnounce(Discord.Embed embed) { var announceIDKeyValue = await DataBaseUtil.GetKeyValueAsync("AnnounceID"); var announceNameKeyValue = await DataBaseUtil.GetKeyValueAsync("AnnounceName"); AnnounceMessage = await _dataService.AnnouncementChannel.SendMessageAsync("", false, embed) as IUserMessage; await GetAlbum(); //If data exists, just delete it so it can be remade with the new test info. if (announceIDKeyValue != null) { await DataBaseUtil.DeleteKeyValueAsync(announceIDKeyValue); await DataBaseUtil.DeleteKeyValueAsync(announceNameKeyValue); announceNameKeyValue = null; announceIDKeyValue = null; } //Create the text file containing the announce message if (announceIDKeyValue == null) { await DataBaseUtil.AddKeyValueAsync("AnnounceID", $"{AnnounceMessage.Id}"); await DataBaseUtil.AddKeyValueAsync("AnnounceName", CurrentEventInfo[2]); } await _dataService.ChannelLog("Posting Playtest Announcement", $"Posting Playtest for {CurrentEventInfo[2]}"); LastEventInfo = CurrentEventInfo; }
public async Task Announce() { //Attempt to get Keys from DB var announceNameKeyValue = await DataBaseUtil.GetKeyValueAsync("AnnounceName"); var announceIDKeyValue = await DataBaseUtil.GetKeyValueAsync("AnnounceID"); //First program run and a previous announce exists. if (_firstRun && announceIDKeyValue != null) { _firstRun = false; await LaunchSuppress(); GetPreviousAnnounceAsync(announceIDKeyValue, announceNameKeyValue); } _caltick++; if (_dataService.CalUpdateTicks < _caltick) { _caltick = 0; CurrentEventInfo = EventCalendarService.GetEvents(); if (AnnounceMessage == null) //No current message. { await PostAnnounce(await FormatPlaytestInformationAsync(CurrentEventInfo, false)); } else if (CurrentEventInfo[2] == LastEventInfo[2]) //Title is same. { await UpdateAnnounce(await FormatPlaytestInformationAsync(CurrentEventInfo, false)); } else //Title is different, scrub and rebuild { await RebuildAnnounce(); } } }