Ejemplo n.º 1
0
        private async Task LogUnmutedChannel(Server server, SocketGuildChannel channel, SocketUser issuedBy)
        {
            try
            {
                SocketTextChannel logChannel;
                if (!server.Config.LogBans || (logChannel = server.Guild.GetTextChannel(server.Config.ModChannelId)) == null)
                {
                    return;
                }

                if (server.Config.ModChannelEmbeds)
                {
                    await logChannel.SendMessageAsync("", embed :
                                                      GetLogEmbed(new Color(server.Config.ModChannelColor), "", "Channel Unmuted",
                                                                  "by: " + (issuedBy?.GetUsername() ?? "<unknown>"),
                                                                  "#" + channel.Name, channel.Id.ToString(),
                                                                  DateTime.UtcNow));
                }
                else
                {
                    await logChannel.SendMessageSafe(
                        GetLogMessage("Channel Unmuted ", (issuedBy == null ? "by unknown" : "by " + issuedBy.GetUsername()),
                                      "#" + channel.Name, channel.Id.ToString(),
                                      Utils.GetTimestamp()));
                }
            }
            catch (HttpException) { }
            catch (Exception exception)
            {
                await this.HandleException(exception, "LogUnmute", server.Id);
            }
        }
Ejemplo n.º 2
0
        private async Task OnUserUnbanned(SocketUser user, SocketGuild guild)
        {
            Server server;

            if (!this.Client.Servers.ContainsKey(guild.Id) || (server = this.Client.Servers[guild.Id]) == null ||
                this.RecentlyUnbannedUserIDs.Contains(user.Id))
            {
                return;
            }

            await LogUnban(server, user.GetUsername(), user.Id, null);
        }
Ejemplo n.º 3
0
        private async Task OnUserBanned(SocketUser user, SocketGuild guild)
        {
            Server server;

            if (!this.Client.Servers.ContainsKey(guild.Id) || (server = this.Client.Servers[guild.Id]) == null ||
                this.RecentlyBannedUserIDs.Contains(user.Id))
            {
                return;
            }

            BanAuditLogData   auditData  = null;
            RestAuditLogEntry auditEntry = null;

            if (guild.CurrentUser.GuildPermissions.ViewAuditLog)
            {
                await Task.Delay(500);

                try
                {
                    auditEntry = await guild.GetAuditLogsAsync(10)?.Flatten()?.FirstOrDefault(e => e != null && e.Action == ActionType.Ban && (auditData = e.Data as BanAuditLogData) != null && auditData.Target.Id == user.Id);

                    //One huge line because black magic from .NET Core?
                }
                catch (Exception) { }
            }

            string  reason = "unknown";
            RestBan ban    = await server.Guild.GetBanAsync(user);

            if (ban != null)
            {
                reason = ban.Reason;
                await this.Client.Events.AddBan(guild.Id, user.Id, TimeSpan.Zero, reason);
            }
            await LogBan(server, user.GetUsername(), user.Id, reason, "permanently", auditEntry?.User as SocketGuildUser);
        }