Ejemplo n.º 1
0
        //Announce users leaving the guild if enabled
        private async Task UserLeaveGuild(DiscordClient client, GuildMemberRemoveEventArgs e)
        {
            if (e.Member.IsCurrent)
            {
                return;
            }

            var GuildSettings = await this.Config.FindGuildSettings(e.Guild);

            DiscordChannel channel;

            //Check notification settings
            switch (GuildSettings.NotificationChannel)
            {
            case 0:
                return;

            case 1:
                channel = e.Guild.GetDefaultChannel();
                break;

            default:
                channel = e.Guild.GetChannel(GuildSettings.NotificationChannel);
                break;
            }
            if (channel == null)
            {
                return;
            }

            //Check if the user was banned
            DiscordBan UserBan = await e.Guild.GetBanAsync(e.Member);

            if (UserBan != null)
            {
                await channel.SendMessageAsync($"{e.Member.Mention} ({e.Member.Username}#{e.Member.Discriminator}) was banned from the guild with the reason `{UserBan.Reason}`");

                return;
            }

            //Check if the user was kicked
            //The only way to determine this is through the audit logs which can make this inconsistent
            var L = await e.Guild.GetAuditLogsAsync(1, action_type : AuditLogActionType.Kick);

            DiscordAuditLogKickEntry LastKick = (DiscordAuditLogKickEntry)L.FirstOrDefault();

            if (LastKick != null && LastKick.Target == e.Member)
            {
                await channel.SendMessageAsync($"{e.Member.Mention} ({e.Member.Username}#{e.Member.Discriminator}) was kicked from the guild with the reason `{LastKick.Reason}`");

                return;
            }

            //The user left on their own
            await channel.SendMessageAsync($"{e.Member.Mention} ({e.Member.Username}#{e.Member.Discriminator}) left the guild.");
        }
Ejemplo n.º 2
0
 private async Task ProcessDiscordAuditLogKickEntry(DiscordAuditLogKickEntry entry, DiscordEmbedBuilder builder)
 {
 }