コード例 #1
0
        public async Task <ServiceResponse> RemovePattern(ulong guildId, string regexPattern)
        {
            if (!_authorizationService.HasClaim(AuthorizationClaim.ManageMessageContentPatterns))
            {
                return(ServiceResponse.Fail("User does not have claim to manage patterns!"));
            }

            var pattern = await _db
                          .Set <MessageContentPatternEntity>()
                          .Where(x => x.GuildId == guildId)
                          .Where(x => x.Pattern == regexPattern)
                          .SingleOrDefaultAsync();

            if (!(pattern is null))
            {
                _db.Remove(pattern);

                await _db.SaveChangesAsync();
            }

            ClearCacheForGuild(guildId);

            return(ServiceResponse.Ok());
        }