private async Task ProcessWithCacheRecordAsync(IMessage message, ISocketMessageChannel channel) { var auditLogRecord = await GetAuditLogRecord(channel, message.Author.Id).ConfigureAwait(false); var streams = new List <Tuple <string, Stream> >(); try { var logEmbedBuilder = new LogEmbedBuilder("Zpráva byla odebrána", LogEmbedType.MessageDeleted); logEmbedBuilder .SetAuthor(message.Author, true) .SetFooter($"MessageID: {message.Id} | AuthorID: {message.Author?.Id}") .AddField("Odesláno v", message.CreatedAt.LocalDateTime.ToLocaleDatetime()) .AddField("Kanál", $"<#{message.Channel.Id}> ({message.Channel.Id})"); if (auditLogRecord != null) { logEmbedBuilder.AddField("Smazal", auditLogRecord.User.GetShortName()); } else { logEmbedBuilder.AddField("Smazal", message.Author.GetShortName()); } if (string.IsNullOrEmpty(message.Content)) { logEmbedBuilder.AddField("Obsah", "-"); } else { logEmbedBuilder.AddCodeBlockField("Obsah", message.Content); } if (message.Attachments.Count > 0) { foreach (var messageAttachment in message.Attachments) { var attachmentStream = await GetAttachmentStreamAsync(messageAttachment).ConfigureAwait(false); if (!string.IsNullOrEmpty(attachmentStream.Item1) && attachmentStream.Item2 != null) { streams.Add(attachmentStream); } } } var loggerChannel = GetLoggerRoom(); await loggerChannel.SendMessageAsync(embed : logEmbedBuilder.Build()).ConfigureAwait(false); foreach (var stream in streams) { await loggerChannel.SendFileAsync(stream.Item2, stream.Item1).ConfigureAwait(false); } } finally { streams.ForEach(o => o.Item2.Dispose()); } }
private async Task SendBoostChange(SocketGuildUser user, string embedMessage) { var logEmbedBuilder = new LogEmbedBuilder(embedMessage, LogEmbedType.BoostUpdated); logEmbedBuilder .SetAuthor(user) .SetFooter($"UserID: {user.Id}"); await SendEmbedToAdminChannel(logEmbedBuilder).ConfigureAwait(false); }
private async Task ProcessWithoutCacheRecordAsync(ulong messageId, ISocketMessageChannel channel) { var logEmbedBuilder = new LogEmbedBuilder("Zpráva byla smazána.", LogEmbedType.MessageDeleted); logEmbedBuilder .SetFooter($"MessageID: {messageId}") .SetTitle("Zpráva nebyla nalezena v cache.") .AddField("Kanál", $"<#{channel.Id}> ({channel.Id})"); await SendEmbedAsync(logEmbedBuilder).ConfigureAwait(false); }
protected async Task <RestUserMessage> SendEmbedAsync(LogEmbedBuilder embedBuilder) { var loggerRoom = GetLoggerRoom(); if (loggerRoom == null) { return(null); } return(await loggerRoom.SendMessageAsync(embed : embedBuilder.Build()).ConfigureAwait(false)); }
public async Task ProcessAsync(SocketGuildUser user) { var logEmbedBuilder = new LogEmbedBuilder("Uživatel opustil server.", LogEmbedType.UserLeft); logEmbedBuilder .SetAuthor(user) .AddField("Počet členů na serveru", user.Guild.MemberCount) .SetFooter($"MemberID: {user.Id}"); await SendEmbedAsync(logEmbedBuilder).ConfigureAwait(false); }
public async Task ProcessAsync(SocketGuildUser user) { var logEmbedBuilder = new LogEmbedBuilder("Připojil se uživatel", LogEmbedType.UserJoined); var createdAt = user.CreatedAt.LocalDateTime.ToLocaleDatetime(); logEmbedBuilder .SetAuthor(user) .SetFooter($"MemberID: {user.Id}") .AddField("Založen", createdAt) .AddField("Počet členů na serveru", user.Guild.MemberCount); await SendEmbedAsync(logEmbedBuilder).ConfigureAwait(false); }
public async Task <bool> ProcessAsync(SocketGuildUser guildUserBefore, SocketGuildUser guildUserAfter) { if (IsBoostAdded(guildUserBefore, guildUserAfter)) { await BoostAdded(guildUserAfter).ConfigureAwait(false); return(true); } else if (IsBoostRemoved(guildUserBefore, guildUserAfter)) { await BoostRemoved(guildUserAfter).ConfigureAwait(false); return(true); } if (!IsChangeDetected(guildUserBefore, guildUserAfter)) { return(false); } var logEmbedBuilder = new LogEmbedBuilder("Uživatel na serveru byl aktualizován.", LogEmbedType.GuildMemberUpdated); logEmbedBuilder .SetAuthor(guildUserBefore) .SetFooter($"UserID: {guildUserBefore.Id}") .AddField("Změny", "---------------------------------------------"); if (guildUserBefore.Nickname != guildUserAfter.Nickname) { if (string.IsNullOrEmpty(guildUserBefore.Nickname) && !string.IsNullOrEmpty(guildUserAfter.Nickname)) { logEmbedBuilder.AddField("Server alias", $"(None) -> {guildUserAfter.Nickname}"); } else if (!string.IsNullOrEmpty(guildUserBefore.Nickname) && string.IsNullOrEmpty(guildUserAfter.Nickname)) { logEmbedBuilder.AddField("Server alias", $"{guildUserBefore.Nickname} -> (None)"); } else { logEmbedBuilder.AddField("Server alias", $"{guildUserBefore.Nickname} -> {guildUserAfter.Nickname}"); } } await SendEmbedAsync(logEmbedBuilder).ConfigureAwait(false); return(true); }
public async Task ProcessAsync(SocketGuildUser user) { var logEmbedBuilder = new LogEmbedBuilder("Uživatel opustil server.", LogEmbedType.UserLeft); var ban = await user.Guild.FindBanAsync(user); logEmbedBuilder = logEmbedBuilder .SetAuthor(user) .AddField("Počet členů na serveru", user.Guild.MemberCount, true) .AddField("Udělen ban", (ban != null).TranslateToCz(), true) .SetFooter($"MemberID: {user.Id}"); if (!string.IsNullOrEmpty(ban?.Reason)) { logEmbedBuilder.AddField("Důvod banu", ban.Reason); } await SendEmbedAsync(logEmbedBuilder).ConfigureAwait(false); }
public async Task <bool> ProcessAsync(Cacheable <IMessage, ulong> messageBefore, SocketMessage messageAfter, ISocketMessageChannel channel) { var oldMessage = messageBefore.HasValue ? messageBefore.Value : MessageCache.Get(messageBefore.Id); if (!IsDetectedChange(oldMessage, messageAfter)) { return(false); } var logEmbedBuilder = new LogEmbedBuilder("Zpráva byla upravena", LogEmbedType.MessageEdited); logEmbedBuilder .SetAuthor(messageAfter.Author) .AddCodeBlockField("Před", oldMessage.Content) .AddCodeBlockField("Po", messageAfter.Content) .AddField("Kanál", $"<#{channel.Id}> ({channel.Id})") .AddField("Odkaz", messageAfter.GetJumpUrl()) .SetFooter($"MessageID: {messageAfter.Id} | AuthorID: {messageAfter.Author.Id}"); await SendEmbedAsync(logEmbedBuilder).ConfigureAwait(false); MessageCache.Update(messageAfter); return(true); }
protected async Task <RestUserMessage> SendEmbedToAdminChannel(LogEmbedBuilder embedBuilder) { var channel = GetLoggerRoom(true); return(await channel.SendMessageAsync(embed : embedBuilder.Build()).ConfigureAwait(false)); }