Logging updated
This commit is contained in:
		@@ -23,14 +23,17 @@ namespace NadekoBot.Modules.Administration
 | 
				
			|||||||
        [Group]
 | 
					        [Group]
 | 
				
			||||||
        public class LogCommands : ModuleBase
 | 
					        public class LogCommands : ModuleBase
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					            private const string clockEmojiUrl = "https://cdn.discordapp.com/attachments/155726317222887425/258309524966866945/clock.png";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            private static ShardedDiscordClient _client { get; }
 | 
					            private static ShardedDiscordClient _client { get; }
 | 
				
			||||||
            private static Logger _log { get; }
 | 
					            private static Logger _log { get; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            private static string prettyCurrentTime => $"【{DateTime.Now:HH:mm:ss}】";
 | 
					            private static string prettyCurrentTime => $"【{DateTime.Now:HH:mm:ss}】";
 | 
				
			||||||
 | 
					            private static string currentTime = $"{DateTime.Now:HH:mm:ss}";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            public static ConcurrentDictionary<ulong, LogSetting> GuildLogSettings { get; }
 | 
					            public static ConcurrentDictionary<ulong, LogSetting> GuildLogSettings { get; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            private static ConcurrentDictionary<ITextChannel, List<string>> UserPresenceUpdates { get; } = new ConcurrentDictionary<ITextChannel, List<string>>();
 | 
					            private static ConcurrentDictionary<ITextChannel, List<string>> PresenceUpdates { get; } = new ConcurrentDictionary<ITextChannel, List<string>>();
 | 
				
			||||||
            private static Timer timerReference { get; }
 | 
					            private static Timer timerReference { get; }
 | 
				
			||||||
            private IGoogleApiService _google { get; }
 | 
					            private IGoogleApiService _google { get; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -50,20 +53,20 @@ namespace NadekoBot.Modules.Administration
 | 
				
			|||||||
                {
 | 
					                {
 | 
				
			||||||
                    try
 | 
					                    try
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        var keys = UserPresenceUpdates.Keys.ToList();
 | 
					                        var keys = PresenceUpdates.Keys.ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        await Task.WhenAll(keys.Select(async key =>
 | 
					                        await Task.WhenAll(keys.Select(async key =>
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            List<string> messages;
 | 
					                            List<string> messages;
 | 
				
			||||||
                            if (UserPresenceUpdates.TryRemove(key, out messages))
 | 
					                            if (PresenceUpdates.TryRemove(key, out messages))
 | 
				
			||||||
                                try { await key.SendMessageAsync(string.Join(Environment.NewLine, messages)); } catch { }
 | 
					                                try { await key.SendConfirmAsync("Presence Updates", string.Join(Environment.NewLine, messages)); } catch { }
 | 
				
			||||||
                        }));
 | 
					                        }));
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    catch (Exception ex)
 | 
					                    catch (Exception ex)
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        _log.Warn(ex);
 | 
					                        _log.Warn(ex);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }, null, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(10));
 | 
					                }, null, TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                sw.Stop();
 | 
					                sw.Stop();
 | 
				
			||||||
                _log.Debug($"Loaded in {sw.Elapsed.TotalSeconds:F2}s");
 | 
					                _log.Debug($"Loaded in {sw.Elapsed.TotalSeconds:F2}s");
 | 
				
			||||||
@@ -91,22 +94,17 @@ namespace NadekoBot.Modules.Administration
 | 
				
			|||||||
                MuteCommands.UserUnmuted += MuteCommands_UserUnmuted;
 | 
					                MuteCommands.UserUnmuted += MuteCommands_UserUnmuted;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            private static async void _client_UserUpdated(SocketUser before, SocketUser after)
 | 
					            private static async void _client_UserUpdated(SocketUser before, SocketUser uAfter)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                try
 | 
					                try
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    var str = "";
 | 
					                    var after = uAfter as SocketGuildUser;
 | 
				
			||||||
                    if (before.Username != after.Username)
 | 
					 | 
				
			||||||
                        str = $"👤__**{before.Username}#{before.Discriminator}**__ **| Name Changed |** 🆔 `{before.Id}`\n\t\t`New:` **{after.ToString()}**";
 | 
					 | 
				
			||||||
                    else if (before.AvatarUrl != after.AvatarUrl)
 | 
					 | 
				
			||||||
                        str = $"👤__**{before.Username}#{before.Discriminator}**__ **| Avatar Changed |** 🆔 `{before.Id}`\n\t🖼 {await NadekoBot.Google.ShortenUrl(before.AvatarUrl)} `=>` {await NadekoBot.Google.ShortenUrl(after.AvatarUrl)}";
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (string.IsNullOrWhiteSpace(str))
 | 
					                    if (after == null)
 | 
				
			||||||
                        return;
 | 
					                        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    var guildsMemberOf = NadekoBot.Client.GetGuilds().Where(g => g.Users.Select(u => u.Id).Contains(before.Id)).ToList();
 | 
					                    var g = after.Guild;
 | 
				
			||||||
                    foreach (var g in guildsMemberOf)
 | 
					
 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                    LogSetting logSetting;
 | 
					                    LogSetting logSetting;
 | 
				
			||||||
                    if (!GuildLogSettings.TryGetValue(g.Id, out logSetting)
 | 
					                    if (!GuildLogSettings.TryGetValue(g.Id, out logSetting)
 | 
				
			||||||
                        || (logSetting.UserUpdatedId == null))
 | 
					                        || (logSetting.UserUpdatedId == null))
 | 
				
			||||||
@@ -116,8 +114,48 @@ namespace NadekoBot.Modules.Administration
 | 
				
			|||||||
                    if ((logChannel = await TryGetLogChannel(g, logSetting, LogType.UserUpdated)) == null)
 | 
					                    if ((logChannel = await TryGetLogChannel(g, logSetting, LogType.UserUpdated)) == null)
 | 
				
			||||||
                        return;
 | 
					                        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        try { await logChannel.SendMessageAsync(str).ConfigureAwait(false); } catch { }
 | 
					                    var embed = new EmbedBuilder();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (before.Username != after.Username)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        embed.WithAuthor(eab => eab.WithName("Username Changed"))
 | 
				
			||||||
 | 
					                            .WithTitle($"{before.Username}#{before.Discriminator} | {before.Id}")
 | 
				
			||||||
 | 
					                            .AddField(fb => fb.WithName("Old Name").WithValue($"{before.Username}").WithIsInline(true))
 | 
				
			||||||
 | 
					                            .AddField(fb => fb.WithName("New Name").WithValue($"{after.Username}").WithIsInline(true))
 | 
				
			||||||
 | 
					                            .WithFooter(fb => fb.WithText(currentTime))
 | 
				
			||||||
 | 
					                            .WithOkColor();
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					                    else if (before.AvatarUrl != after.AvatarUrl)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        embed.WithAuthor(eab => eab.WithName("Avatar Changed"))
 | 
				
			||||||
 | 
					                            .WithTitle($"{before.Username}#{before.Discriminator} | {before.Id}")
 | 
				
			||||||
 | 
					                            .WithThumbnailUrl(before.AvatarUrl)
 | 
				
			||||||
 | 
					                            .WithImageUrl(after.AvatarUrl)
 | 
				
			||||||
 | 
					                            .WithFooter(fb => fb.WithText(currentTime))
 | 
				
			||||||
 | 
					                            .WithOkColor();
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        return;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    await logChannel.EmbedAsync(embed).ConfigureAwait(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //var guildsMemberOf = NadekoBot.Client.GetGuilds().Where(g => g.Users.Select(u => u.Id).Contains(before.Id)).ToList();
 | 
				
			||||||
 | 
					                    //foreach (var g in guildsMemberOf)
 | 
				
			||||||
 | 
					                    //{
 | 
				
			||||||
 | 
					                    //    LogSetting logSetting;
 | 
				
			||||||
 | 
					                    //    if (!GuildLogSettings.TryGetValue(g.Id, out logSetting)
 | 
				
			||||||
 | 
					                    //        || (logSetting.UserUpdatedId == null))
 | 
				
			||||||
 | 
					                    //        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //    ITextChannel logChannel;
 | 
				
			||||||
 | 
					                    //    if ((logChannel = await TryGetLogChannel(g, logSetting, LogType.UserUpdated)) == null)
 | 
				
			||||||
 | 
					                    //        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //    try { await logChannel.SendMessageAsync(str).ConfigureAwait(false); } catch { }
 | 
				
			||||||
 | 
					                    //}
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                catch
 | 
					                catch
 | 
				
			||||||
                { }
 | 
					                { }
 | 
				
			||||||
@@ -146,7 +184,7 @@ namespace NadekoBot.Modules.Administration
 | 
				
			|||||||
                    if ((logChannel = await TryGetLogChannel(usr.Guild, logSetting, LogType.VoicePresenceTTS)) == null)
 | 
					                    if ((logChannel = await TryGetLogChannel(usr.Guild, logSetting, LogType.VoicePresenceTTS)) == null)
 | 
				
			||||||
                        return;
 | 
					                        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    string str = null;
 | 
					                    var str = "";
 | 
				
			||||||
                    if (beforeVch?.Guild == afterVch?.Guild)
 | 
					                    if (beforeVch?.Guild == afterVch?.Guild)
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        str = $"{usr.Username} moved from {beforeVch.Name} to {afterVch.Name}";
 | 
					                        str = $"{usr.Username} moved from {beforeVch.Name} to {afterVch.Name}";
 | 
				
			||||||
@@ -190,9 +228,15 @@ namespace NadekoBot.Modules.Administration
 | 
				
			|||||||
                            mutes = "text and voice chat";
 | 
					                            mutes = "text and voice chat";
 | 
				
			||||||
                            break;
 | 
					                            break;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    await logChannel.SendMessageAsync($"‼️🕕`{prettyCurrentTime}`👤__**{usr.Username}#{usr.Discriminator}**__🔇 **| User muted from the {mutes}. |** 🆔 `{usr.Id}`").ConfigureAwait(false);
 | 
					
 | 
				
			||||||
 | 
					                    var embed = new EmbedBuilder().WithAuthor(eab => eab.WithName("User Muted from " + mutes))
 | 
				
			||||||
 | 
					                            .WithTitle($"{usr.Username}#{usr.Discriminator} | {usr.Id}")
 | 
				
			||||||
 | 
					                            .WithFooter(fb => fb.WithText(currentTime))
 | 
				
			||||||
 | 
					                            .WithOkColor();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    await logChannel.EmbedAsync(embed).ConfigureAwait(false);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                catch (Exception ex) { _log.Warn(ex); }
 | 
					                catch { }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            private static async void MuteCommands_UserUnmuted(IGuildUser usr, MuteCommands.MuteType muteType)
 | 
					            private static async void MuteCommands_UserUnmuted(IGuildUser usr, MuteCommands.MuteType muteType)
 | 
				
			||||||
@@ -221,9 +265,15 @@ namespace NadekoBot.Modules.Administration
 | 
				
			|||||||
                            mutes = "text and voice chat";
 | 
					                            mutes = "text and voice chat";
 | 
				
			||||||
                            break;
 | 
					                            break;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    await logChannel.SendMessageAsync($"‼️🕕`{prettyCurrentTime}`👤__**{usr.Username}#{usr.Discriminator}**__🔊 **| User unmuted from the {mutes}. |** 🆔 `{usr.Id}`").ConfigureAwait(false);
 | 
					
 | 
				
			||||||
 | 
					                    var embed = new EmbedBuilder().WithAuthor(eab => eab.WithName("User Unmuted from " + mutes))
 | 
				
			||||||
 | 
					                            .WithTitle($"{usr.Username}#{usr.Discriminator} | {usr.Id}")
 | 
				
			||||||
 | 
					                            .WithFooter(fb => fb.WithText($"{currentTime}"))
 | 
				
			||||||
 | 
					                            .WithOkColor();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    await logChannel.EmbedAsync(embed).ConfigureAwait(false);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                catch (Exception ex) { _log.Warn(ex); }
 | 
					                catch { }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            public static async Task TriggeredAntiProtection(IGuildUser[] users, PunishmentAction action, ProtectionType protection)
 | 
					            public static async Task TriggeredAntiProtection(IGuildUser[] users, PunishmentAction action, ProtectionType protection)
 | 
				
			||||||
@@ -245,22 +295,25 @@ namespace NadekoBot.Modules.Administration
 | 
				
			|||||||
                    if (action == PunishmentAction.Mute)
 | 
					                    if (action == PunishmentAction.Mute)
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        punishment = "🔇 MUTED";
 | 
					                        punishment = "🔇 MUTED";
 | 
				
			||||||
                        //punishment = "MUTED";
 | 
					 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    else if (action == PunishmentAction.Kick)
 | 
					                    else if (action == PunishmentAction.Kick)
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        punishment = "☣ SOFT-BANNED (KICKED)";
 | 
					                        punishment = "☣ SOFT-BANNED (KICKED)";
 | 
				
			||||||
                        //punishment = "KICKED";
 | 
					 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    else if (action == PunishmentAction.Ban)
 | 
					                    else if (action == PunishmentAction.Ban)
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        punishment = "⛔️ BANNED";
 | 
					                        punishment = "⛔️ BANNED";
 | 
				
			||||||
                        //punishment = "BANNED";
 | 
					 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    await logChannel.SendMessageAsync(String.Join("\n", users.Select(user => $"‼️ {Format.Bold(user.ToString())} got **{punishment}** due to __**{protection}**__ protection on **{user.Guild.Name}** server.")))
 | 
					
 | 
				
			||||||
                                    .ConfigureAwait(false);
 | 
					                    var embed = new EmbedBuilder().WithAuthor(eab => eab.WithName($"Anti-{protection}"))
 | 
				
			||||||
 | 
					                            .WithTitle($"Users " + punishment)
 | 
				
			||||||
 | 
					                            .WithDescription(String.Join("\n", users.Select(u => u.ToString())))
 | 
				
			||||||
 | 
					                            .WithFooter(fb => fb.WithText($"{currentTime}"))
 | 
				
			||||||
 | 
					                            .WithOkColor();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    await logChannel.EmbedAsync(embed).ConfigureAwait(false);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                catch (Exception ex) { _log.Warn(ex); }
 | 
					                catch { }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            private static async void _client_GuildUserUpdated(SocketGuildUser before, SocketGuildUser after)
 | 
					            private static async void _client_GuildUserUpdated(SocketGuildUser before, SocketGuildUser after)
 | 
				
			||||||
@@ -275,27 +328,35 @@ namespace NadekoBot.Modules.Administration
 | 
				
			|||||||
                    ITextChannel logChannel;
 | 
					                    ITextChannel logChannel;
 | 
				
			||||||
                    if ((logChannel = await TryGetLogChannel(before.Guild, logSetting, LogType.UserUpdated)) == null)
 | 
					                    if ((logChannel = await TryGetLogChannel(before.Guild, logSetting, LogType.UserUpdated)) == null)
 | 
				
			||||||
                        return;
 | 
					                        return;
 | 
				
			||||||
                    var str = "";
 | 
					                    var embed = new EmbedBuilder().WithOkColor().WithFooter(efb => efb.WithText(currentTime))
 | 
				
			||||||
 | 
					                        .WithTitle($"{before.Username}#{before.Discriminator} | {before.Id}");
 | 
				
			||||||
                    if (before.Nickname != after.Nickname)
 | 
					                    if (before.Nickname != after.Nickname)
 | 
				
			||||||
                        str = $"👤__**{before.Username}#{before.Discriminator}**__ **| Nickname Changed |** 🆔 `{before.Id}`\n\t\t`Old:` **{before.Nickname}**\n\t\t`New:` **{after.Nickname}**";
 | 
					                    {
 | 
				
			||||||
 | 
					                        embed.WithAuthor(eab => eab.WithName("Nickname Changed"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            .AddField(efb => efb.WithName("Old Nickname").WithValue($"{before.Nickname}#{before.Discriminator}"))
 | 
				
			||||||
 | 
					                            .AddField(efb => efb.WithName("New Nickname").WithValue($"{after.Nickname}#{after.Discriminator}"));
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
                    else if (!before.RoleIds.SequenceEqual(after.RoleIds))
 | 
					                    else if (!before.RoleIds.SequenceEqual(after.RoleIds))
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        if (before.RoleIds.Count < after.RoleIds.Count)
 | 
					                        if (before.RoleIds.Count < after.RoleIds.Count)
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            var diffRoles = after.RoleIds.Where(r => !before.RoleIds.Contains(r)).Select(r => "**" + before.Guild.GetRole(r).Name + "**");
 | 
					                            var diffRoles = after.RoleIds.Where(r => !before.RoleIds.Contains(r)).Select(r => before.Guild.GetRole(r).Name);
 | 
				
			||||||
                            str = $"👤__**{before.ToString()}**__ **| User's Role Added |** 🆔 `{before.Id}`\n\t✅ {string.Join(", ", diffRoles).SanitizeMentions()}\n\t\t⚔ **`{string.Join(", ", after.GetRoles().Select(r => r.Name)).SanitizeMentions()}`** ⚔";
 | 
					                            embed.WithAuthor(eab => eab.WithName("User's Role Added"))
 | 
				
			||||||
 | 
					                                .WithDescription(string.Join(", ", diffRoles).SanitizeMentions());
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                        else if (before.RoleIds.Count > after.RoleIds.Count)
 | 
					                        else if (before.RoleIds.Count > after.RoleIds.Count)
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            var diffRoles = before.RoleIds.Where(r => !after.RoleIds.Contains(r)).Select(r => "**" + before.Guild.GetRole(r).Name + "**");
 | 
					                            var diffRoles = before.RoleIds.Where(r => !after.RoleIds.Contains(r)).Select(r => before.Guild.GetRole(r).Name);
 | 
				
			||||||
                            str = $"👤__**{before.ToString()}**__ **| User's Role Removed |** 🆔 `{before.Id}`\n\t🚮 {string.Join(", ", diffRoles).SanitizeMentions()}\n\t\t⚔ **`{string.Join(", ", after.GetRoles().Select(r => r.Name)).SanitizeMentions()}`** ⚔";
 | 
					                            embed.WithAuthor(eab => eab.WithName("User's Role Removed"))
 | 
				
			||||||
 | 
					                                .WithDescription(string.Join(", ", diffRoles).SanitizeMentions());
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    else
 | 
					                    else
 | 
				
			||||||
                        return;
 | 
					                        return;
 | 
				
			||||||
                    try { await logChannel.SendMessageAsync($"🕔`{prettyCurrentTime}` " + str).ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); }
 | 
					                    await logChannel.EmbedAsync(embed).ConfigureAwait(false);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                catch (Exception ex) { _log.Warn(ex); }
 | 
					                catch { }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            private static async void _client_ChannelUpdated(IChannel cbefore, IChannel cafter)
 | 
					            private static async void _client_ChannelUpdated(IChannel cbefore, IChannel cafter)
 | 
				
			||||||
@@ -316,16 +377,30 @@ namespace NadekoBot.Modules.Administration
 | 
				
			|||||||
                    ITextChannel logChannel;
 | 
					                    ITextChannel logChannel;
 | 
				
			||||||
                    if ((logChannel = await TryGetLogChannel(before.Guild, logSetting, LogType.ChannelUpdated)) == null)
 | 
					                    if ((logChannel = await TryGetLogChannel(before.Guild, logSetting, LogType.ChannelUpdated)) == null)
 | 
				
			||||||
                        return;
 | 
					                        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    var embed = new EmbedBuilder().WithOkColor().WithFooter(efb => efb.WithText(currentTime));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    var beforeTextChannel = cbefore as ITextChannel;
 | 
				
			||||||
 | 
					                    var afterTextChannel = cafter as ITextChannel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (before.Name != after.Name)
 | 
					                    if (before.Name != after.Name)
 | 
				
			||||||
                        await logChannel.SendMessageAsync($@"🕓`{prettyCurrentTime}`ℹ️ **| Channel Name Changed |** #⃣ `{after.Name} ({after.Id})`
 | 
					                    {
 | 
				
			||||||
    `Old:` {before.Name}
 | 
					                        embed.WithTitle("Channel Name Changed")
 | 
				
			||||||
    **`New:`** {after.Name}").ConfigureAwait(false);
 | 
					                            .AddField(efb => efb.WithName("Id").WithValue(before.Id.ToString()))
 | 
				
			||||||
                    else if ((before as ITextChannel).Topic != (after as ITextChannel).Topic)
 | 
					                            .AddField(efb => efb.WithName("Old Name").WithValue(before.Name))
 | 
				
			||||||
                        await logChannel.SendMessageAsync($@"🕘`{prettyCurrentTime}`ℹ️ **| Channel Topic Changed |** #⃣ `{after.Name} ({after.Id})`
 | 
					                            .AddField(efb => efb.WithName("New name").WithValue(after.Name));
 | 
				
			||||||
    `Old:` {((ITextChannel)before).Topic}
 | 
					 | 
				
			||||||
    **`New:`** {((ITextChannel)after).Topic}").ConfigureAwait(false);
 | 
					 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                catch (Exception ex) { _log.Warn(ex); }
 | 
					                    else if (beforeTextChannel?.Topic != afterTextChannel?.Topic)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        embed.WithTitle("Channel Topic Changed")
 | 
				
			||||||
 | 
					                            .AddField(efb => efb.WithName("Id").WithValue(before.Id.ToString()))
 | 
				
			||||||
 | 
					                            .AddField(efb => efb.WithName("Old Topic").WithValue(beforeTextChannel.Topic))
 | 
				
			||||||
 | 
					                            .AddField(efb => efb.WithName("New Topic").WithValue(afterTextChannel.Topic));
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    await logChannel.EmbedAsync(embed).ConfigureAwait(false);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                catch { }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            private static async void _client_ChannelDestroyed(IChannel ich)
 | 
					            private static async void _client_ChannelDestroyed(IChannel ich)
 | 
				
			||||||
@@ -346,9 +421,13 @@ namespace NadekoBot.Modules.Administration
 | 
				
			|||||||
                    if ((logChannel = await TryGetLogChannel(ch.Guild, logSetting, LogType.ChannelDestroyed)) == null)
 | 
					                    if ((logChannel = await TryGetLogChannel(ch.Guild, logSetting, LogType.ChannelDestroyed)) == null)
 | 
				
			||||||
                        return;
 | 
					                        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    await logChannel.SendMessageAsync($"🕕`{prettyCurrentTime}`🗑 **| {(ch is IVoiceChannel ? "Voice" : "Text")} Channel Deleted #⃣ {ch.Name}** `({ch.Id})`").ConfigureAwait(false);
 | 
					                    await logChannel.EmbedAsync(new EmbedBuilder()
 | 
				
			||||||
 | 
					                        .WithOkColor()
 | 
				
			||||||
 | 
					                        .WithTitle((ch is IVoiceChannel ? "Voice" : "Text") + " Channel Destroyed")
 | 
				
			||||||
 | 
					                        .WithDescription($"{ch.Name} | {ch.Id}")
 | 
				
			||||||
 | 
					                        .WithFooter(efb => efb.WithText(currentTime))).ConfigureAwait(false);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                catch (Exception ex) { _log.Warn(ex); }
 | 
					                catch { }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            private static async void _client_ChannelCreated(IChannel ich)
 | 
					            private static async void _client_ChannelCreated(IChannel ich)
 | 
				
			||||||
@@ -368,7 +447,11 @@ namespace NadekoBot.Modules.Administration
 | 
				
			|||||||
                    if ((logChannel = await TryGetLogChannel(ch.Guild, logSetting, LogType.ChannelCreated)) == null)
 | 
					                    if ((logChannel = await TryGetLogChannel(ch.Guild, logSetting, LogType.ChannelCreated)) == null)
 | 
				
			||||||
                        return;
 | 
					                        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    await logChannel.SendMessageAsync($"🕓`{prettyCurrentTime}`🆕 **| {(ch is IVoiceChannel ? "Voice" : "Text")} Channel Created: #⃣ {ch.Name}** `({ch.Id})`").ConfigureAwait(false);
 | 
					                    await logChannel.EmbedAsync(new EmbedBuilder()
 | 
				
			||||||
 | 
					                        .WithOkColor()
 | 
				
			||||||
 | 
					                        .WithTitle((ch is IVoiceChannel ? "Voice" : "Text") + " Channel Created")
 | 
				
			||||||
 | 
					                        .WithDescription($"{ch.Name} | {ch.Id}")
 | 
				
			||||||
 | 
					                        .WithFooter(efb => efb.WithText(currentTime))).ConfigureAwait(false);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                catch (Exception ex) { _log.Warn(ex); }
 | 
					                catch (Exception ex) { _log.Warn(ex); }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -410,12 +493,9 @@ namespace NadekoBot.Modules.Administration
 | 
				
			|||||||
                        str = $"🎙`{prettyCurrentTime}`👤__**{usr.Username}#{usr.Discriminator}**__ has left **{beforeVch.Name}** voice channel.";
 | 
					                        str = $"🎙`{prettyCurrentTime}`👤__**{usr.Username}#{usr.Discriminator}**__ has left **{beforeVch.Name}** voice channel.";
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    if (str != null)
 | 
					                    if (str != null)
 | 
				
			||||||
                        UserPresenceUpdates.AddOrUpdate(logChannel, new List<string>() { str }, (id, list) => { list.Add(str); return list; });
 | 
					                        PresenceUpdates.AddOrUpdate(logChannel, new List<string>() { str }, (id, list) => { list.Add(str); return list; });
 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                catch (Exception ex)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    _log.Warn(ex);
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					                catch { }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            private static async void _client_UserPresenceUpdated(Optional<SocketGuild> optGuild, SocketUser usr, SocketPresence before, SocketPresence after)
 | 
					            private static async void _client_UserPresenceUpdated(Optional<SocketGuild> optGuild, SocketUser usr, SocketPresence before, SocketPresence after)
 | 
				
			||||||
@@ -438,11 +518,11 @@ namespace NadekoBot.Modules.Administration
 | 
				
			|||||||
                        return;
 | 
					                        return;
 | 
				
			||||||
                    string str;
 | 
					                    string str;
 | 
				
			||||||
                    if (before.Status != after.Status)
 | 
					                    if (before.Status != after.Status)
 | 
				
			||||||
                        str = $"🔵`{prettyCurrentTime}`👤__**{usr.Username}**__ is now **{after.Status}**.";
 | 
					                        str = $"🎭`{prettyCurrentTime}`👤__**{usr.Username}**__ is now **{after.Status}**.";
 | 
				
			||||||
                    else
 | 
					                    else
 | 
				
			||||||
                        str = $"👾`{prettyCurrentTime}`👤__**{usr.Username}**__ is now playing **{after.Game}**.";
 | 
					                        str = $"👾`{prettyCurrentTime}`👤__**{usr.Username}**__ is now playing **{after.Game}**.";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    UserPresenceUpdates.AddOrUpdate(logChannel, new List<string>() { str }, (id, list) => { list.Add(str); return list; });
 | 
					                    PresenceUpdates.AddOrUpdate(logChannel, new List<string>() { str }, (id, list) => { list.Add(str); return list; });
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                catch { }
 | 
					                catch { }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -459,7 +539,13 @@ namespace NadekoBot.Modules.Administration
 | 
				
			|||||||
                    ITextChannel logChannel;
 | 
					                    ITextChannel logChannel;
 | 
				
			||||||
                    if ((logChannel = await TryGetLogChannel(usr.Guild, logSetting, LogType.UserLeft)) == null)
 | 
					                    if ((logChannel = await TryGetLogChannel(usr.Guild, logSetting, LogType.UserLeft)) == null)
 | 
				
			||||||
                        return;
 | 
					                        return;
 | 
				
			||||||
                    await logChannel.SendMessageAsync($"❗️🕛`{prettyCurrentTime}`👤__**{usr.Username}#{usr.Discriminator}**__❌ **| USER LEFT |** 🆔 `{usr.Id}`").ConfigureAwait(false);
 | 
					
 | 
				
			||||||
 | 
					                    await logChannel.EmbedAsync(new EmbedBuilder()
 | 
				
			||||||
 | 
					                        .WithOkColor()
 | 
				
			||||||
 | 
					                        .WithTitle("User Left")
 | 
				
			||||||
 | 
					                        .WithThumbnailUrl(usr.AvatarUrl)
 | 
				
			||||||
 | 
					                        .WithDescription($"{usr} | {usr.Id}")
 | 
				
			||||||
 | 
					                        .WithFooter(efb => efb.WithText(currentTime))).ConfigureAwait(false);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                catch { }
 | 
					                catch { }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -477,7 +563,12 @@ namespace NadekoBot.Modules.Administration
 | 
				
			|||||||
                    if ((logChannel = await TryGetLogChannel(usr.Guild, logSetting, LogType.UserJoined)) == null)
 | 
					                    if ((logChannel = await TryGetLogChannel(usr.Guild, logSetting, LogType.UserJoined)) == null)
 | 
				
			||||||
                        return;
 | 
					                        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    await logChannel.SendMessageAsync($"❕🕓`{prettyCurrentTime}`👤__**{usr.Username}#{usr.Discriminator}**__✅ **| USER JOINED |** 🆔 `{usr.Id}`").ConfigureAwait(false);
 | 
					                    await logChannel.EmbedAsync(new EmbedBuilder()
 | 
				
			||||||
 | 
					                        .WithOkColor()
 | 
				
			||||||
 | 
					                        .WithTitle("User Joined")
 | 
				
			||||||
 | 
					                        .WithThumbnailUrl(usr.AvatarUrl)
 | 
				
			||||||
 | 
					                        .WithDescription($"{usr} | {usr.Id}")
 | 
				
			||||||
 | 
					                        .WithFooter(efb => efb.WithText(currentTime))).ConfigureAwait(false);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                catch (Exception ex) { _log.Warn(ex); }
 | 
					                catch (Exception ex) { _log.Warn(ex); }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -495,7 +586,11 @@ namespace NadekoBot.Modules.Administration
 | 
				
			|||||||
                    if ((logChannel = await TryGetLogChannel(guild, logSetting, LogType.UserUnbanned)) == null)
 | 
					                    if ((logChannel = await TryGetLogChannel(guild, logSetting, LogType.UserUnbanned)) == null)
 | 
				
			||||||
                        return;
 | 
					                        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    await logChannel.SendMessageAsync($"❕🕘`{prettyCurrentTime}`👤__**{usr.Username}#{usr.Discriminator}**__♻️ **| USER UN-BANNED |** 🆔 `{usr.Id}`").ConfigureAwait(false);
 | 
					                    await logChannel.EmbedAsync(new EmbedBuilder()
 | 
				
			||||||
 | 
					                        .WithOkColor()
 | 
				
			||||||
 | 
					                        .WithTitle("User Unbanned")
 | 
				
			||||||
 | 
					                        .WithDescription($"{usr} | {usr.Id}")
 | 
				
			||||||
 | 
					                        .WithFooter(efb => efb.WithText(currentTime))).ConfigureAwait(false);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                catch (Exception ex) { _log.Warn(ex); }
 | 
					                catch (Exception ex) { _log.Warn(ex); }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -512,7 +607,11 @@ namespace NadekoBot.Modules.Administration
 | 
				
			|||||||
                    ITextChannel logChannel;
 | 
					                    ITextChannel logChannel;
 | 
				
			||||||
                    if ((logChannel = await TryGetLogChannel(guild, logSetting, LogType.UserBanned)) == null)
 | 
					                    if ((logChannel = await TryGetLogChannel(guild, logSetting, LogType.UserBanned)) == null)
 | 
				
			||||||
                        return;
 | 
					                        return;
 | 
				
			||||||
                    await logChannel.SendMessageAsync($"‼️🕕`{prettyCurrentTime}`👤__**{usr.Username}#{usr.Discriminator}**__🚫 **| USER BANNED |** 🆔 `{usr.Id}`").ConfigureAwait(false);
 | 
					                    await logChannel.EmbedAsync(new EmbedBuilder()
 | 
				
			||||||
 | 
					                        .WithOkColor()
 | 
				
			||||||
 | 
					                        .WithTitle("User Banned")
 | 
				
			||||||
 | 
					                        .WithDescription($"{usr} | {usr.Id}")
 | 
				
			||||||
 | 
					                        .WithFooter(efb => efb.WithText(currentTime))).ConfigureAwait(false);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                catch (Exception ex) { _log.Warn(ex); }
 | 
					                catch (Exception ex) { _log.Warn(ex); }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -539,13 +638,19 @@ namespace NadekoBot.Modules.Administration
 | 
				
			|||||||
                    ITextChannel logChannel;
 | 
					                    ITextChannel logChannel;
 | 
				
			||||||
                    if ((logChannel = await TryGetLogChannel(channel.Guild, logSetting, LogType.MessageDeleted)) == null || logChannel.Id == msg.Id)
 | 
					                    if ((logChannel = await TryGetLogChannel(channel.Guild, logSetting, LogType.MessageDeleted)) == null || logChannel.Id == msg.Id)
 | 
				
			||||||
                        return;
 | 
					                        return;
 | 
				
			||||||
                    var str = $@"🕔`{prettyCurrentTime}`👤__**{msg.Author.Username}#{msg.Author.Discriminator}**__ **| Deleted Message |** 🆔 `{msg.Author.Id}` #⃣ `{channel.Name}`
 | 
					                    var embed = new EmbedBuilder()
 | 
				
			||||||
🗑 {msg.Resolve(userHandling: TagHandling.FullName)}";
 | 
					                        .WithOkColor()
 | 
				
			||||||
 | 
					                        .WithAuthor(eab => eab.WithName("Message Deleted"))
 | 
				
			||||||
 | 
					                        .WithTitle($"{msg.Author}")
 | 
				
			||||||
 | 
					                        .WithDescription($"{msg.Resolve(userHandling: TagHandling.FullName)}")
 | 
				
			||||||
 | 
					                        .AddField(efb => efb.WithName("Message Id").WithValue(msg.Id.ToString()).WithIsInline(false))
 | 
				
			||||||
 | 
					                        .WithFooter(efb => efb.WithText(currentTime));
 | 
				
			||||||
                    if (msg.Attachments.Any())
 | 
					                    if (msg.Attachments.Any())
 | 
				
			||||||
                        str += $"{Environment.NewLine}📎 {string.Join(", ", msg.Attachments.Select(a => a.ProxyUrl))}";
 | 
					                        embed.AddField(efb => efb.WithName("Attachments").WithValue(string.Join(", ", msg.Attachments.Select(a => a.ProxyUrl))).WithIsInline(false));
 | 
				
			||||||
                    await logChannel.SendMessageAsync(str.SanitizeMentions()).ConfigureAwait(false);
 | 
					
 | 
				
			||||||
 | 
					                    await logChannel.EmbedAsync(embed).ConfigureAwait(false);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                catch (Exception ex) { _log.Warn(ex); }
 | 
					                catch { }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            private static async void _client_MessageUpdated(Optional<SocketMessage> optmsg, SocketMessage imsg2)
 | 
					            private static async void _client_MessageUpdated(Optional<SocketMessage> optmsg, SocketMessage imsg2)
 | 
				
			||||||
@@ -576,11 +681,19 @@ namespace NadekoBot.Modules.Administration
 | 
				
			|||||||
                    ITextChannel logChannel;
 | 
					                    ITextChannel logChannel;
 | 
				
			||||||
                    if ((logChannel = await TryGetLogChannel(channel.Guild, logSetting, LogType.MessageUpdated)) == null || logChannel.Id == after.Channel.Id)
 | 
					                    if ((logChannel = await TryGetLogChannel(channel.Guild, logSetting, LogType.MessageUpdated)) == null || logChannel.Id == after.Channel.Id)
 | 
				
			||||||
                        return;
 | 
					                        return;
 | 
				
			||||||
                    await logChannel.SendMessageAsync($@"🕔`{prettyCurrentTime}`👤__**{before.Author.Username}#{before.Author.Discriminator}**__ **| 📝 Edited Message |** 🆔 `{before.Author.Id}` #⃣ `{channel.Name}`
 | 
					
 | 
				
			||||||
        `Old:` {before.Resolve(userHandling: TagHandling.FullName).SanitizeMentions()}
 | 
					                    var embed = new EmbedBuilder()
 | 
				
			||||||
        **`New:`** {after.Resolve(userHandling: TagHandling.FullName).SanitizeMentions()}").ConfigureAwait(false);
 | 
					                        .WithOkColor()
 | 
				
			||||||
 | 
					                        .WithAuthor(eab => eab.WithName("Message Updated"))
 | 
				
			||||||
 | 
					                        .WithTitle($"{after.Author}")
 | 
				
			||||||
 | 
					                        .AddField(efb => efb.WithName("Old Message").WithValue(before.Resolve(userHandling: TagHandling.FullName)).WithIsInline(false))
 | 
				
			||||||
 | 
					                        .AddField(efb => efb.WithName("New Message").WithValue(after.Resolve(userHandling: TagHandling.FullName)).WithIsInline(false))
 | 
				
			||||||
 | 
					                        .AddField(efb => efb.WithName("Message Id").WithValue(after.Id.ToString()).WithIsInline(false))
 | 
				
			||||||
 | 
					                        .WithFooter(efb => efb.WithText(currentTime));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    await logChannel.EmbedAsync(embed).ConfigureAwait(false);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                catch (Exception ex) { _log.Warn(ex); }
 | 
					                catch { }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            public enum LogType
 | 
					            public enum LogType
 | 
				
			||||||
@@ -763,6 +876,7 @@ namespace NadekoBot.Modules.Administration
 | 
				
			|||||||
                    logSetting.ChannelUpdatedId =
 | 
					                    logSetting.ChannelUpdatedId =
 | 
				
			||||||
                    logSetting.LogUserPresenceId =
 | 
					                    logSetting.LogUserPresenceId =
 | 
				
			||||||
                    logSetting.LogVoicePresenceId =
 | 
					                    logSetting.LogVoicePresenceId =
 | 
				
			||||||
 | 
					                    logSetting.UserMutedId =
 | 
				
			||||||
                    logSetting.LogVoicePresenceTTSId = (action.Value ? channel.Id : (ulong?)null);
 | 
					                    logSetting.LogVoicePresenceTTSId = (action.Value ? channel.Id : (ulong?)null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    await uow.CompleteAsync().ConfigureAwait(false);
 | 
					                    await uow.CompleteAsync().ConfigureAwait(false);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user