public ChangelogEntry NewEntry(string type, string text) { var newEntry = new ChangelogEntry(NextEntryId, type, text); nextEntryId++; entries.Add(newEntry); return(newEntry); }
public async Task PublishEntry(ChangelogEntry entry, SocketTextChannel channel) { await UnpublishEntry(entry, channel.Guild); if (!entryTypes.TryGetValue(entry.type, out var entryType)) { throw new BotError($"Unknown entry type: `{entry.type}`."); } var message = await channel.SendMessageAsync($"{entryType.discordPrefix} - #**{entry.entryId}** - **{entryType.name}:** {entry.text}", options : MopBot.optAlwaysRetry); entry.messageId = message.Id; entry.channelId = channel.Id; }
public async Task UnpublishEntry(ChangelogEntry entry, SocketGuild server) { if (entry.messageId == 0 || entry.channelId == 0) { return; } var oldChannel = server.GetChannel(entry.channelId); if (oldChannel != null && oldChannel is SocketTextChannel oldTextChannel) { var oldMessage = await oldTextChannel.GetMessageAsync(entry.messageId); if (oldMessage != null) { await oldMessage.DeleteAsync(); } } }