Пример #1
0
        public async Task HandleMemberJoinAsync(GuildMemberAddEventArgs e, AntiInstantLeaveSettings settings)
        {
            if (!this.newGuildMembers.ContainsKey(e.Guild.Id) && !this.TryAddGuildToWatch(e.Guild.Id))
            {
                throw new ConcurrentOperationException("Failed to add guild to instant-leave watch list...!");
            }

            if (!this.newGuildMembers[e.Guild.Id].Add(e.Member))
            {
                throw new ConcurrentOperationException("Faled to add member to instant-leave watch list...!");
            }

            await Task.Delay(TimeSpan.FromSeconds(settings.Cooldown));

            if (this.newGuildMembers.ContainsKey(e.Guild.Id) && !this.newGuildMembers[e.Guild.Id].TryRemove(e.Member))
            {
                throw new ConcurrentOperationException("Failed to remove member from instant-leave watch list...!");
            }
        }
Пример #2
0
        public async Task <bool> HandleMemberLeaveAsync(GuildMemberRemoveEventArgs e, AntiInstantLeaveSettings settings)
        {
            if (!this.newGuildMembers.ContainsKey(e.Guild.Id) || !this.newGuildMembers[e.Guild.Id].Contains(e.Member))
            {
                return(false);
            }

            await this.PunishMemberAsync(e.Guild, e.Member, PunishmentActionType.PermanentBan);

            return(true);
        }