Esempio n. 1
0
        public async Task <bool> TryBlockEarly(IGuild guild, IUserMessage usrMsg)
        {
            if (guild == null)
            {
                return(false);
            }
            try
            {
                var channel = usrMsg?.Channel as SocketTextChannel;

                if (channel == null || usrMsg == null || usrMsg.IsAuthor(_client))
                {
                    return(false);
                }
                if (!RatelimitingChannels.TryGetValue(channel.Id, out Ratelimiter limiter))
                {
                    return(false);
                }

                if (limiter.CheckUserRatelimit(usrMsg.Author.Id, channel.Guild.Id, usrMsg.Author as SocketGuildUser))
                {
                    await usrMsg.DeleteAsync();

                    return(true);
                }
            }
            catch (Exception ex)
            {
                _log.Warn(ex);
            }
            return(false);
        }