Exemplo n.º 1
0
        public async Task Add(IgnoreType ignoreType, ulong ignoreId, [Remainder] string allowedString)
        {
            var collection = _mongo.GetCollection <AllowString>(Context.Client);
            var allows     = await collection.GetIgnoresAsync(Context.Guild.Id);

            if (!allows.Any(a =>
                            a.GuildId == Context.Guild.Id && a.IgnoreType == ignoreType && a.IgnoredId == ignoreId &&
                            a.AllowedString.Equals(allowedString, StringComparison.OrdinalIgnoreCase)))
            {
                if (await ValidateUlong(Context, ignoreType, ignoreId))
                {
                    var newEntry = new AllowString(Context.Guild.Id, ignoreType, ignoreId, allowedString);
                    await collection.InsertOneAsync(newEntry);
                    await ReplyAsync(
                        $":white_check_mark: String `{allowedString}` will now be whitelisted for `{ignoreType} {ignoreId}`");
                }
                else
                {
                    await ReplyAsync($"Input {ignoreId} is not a valid {ignoreType}");
                }
            }
            else
            {
                await ReplyAsync("A matching entry is already existent");
            }
        }
Exemplo n.º 2
0
 public static bool CompareAllowedNoCase(this string str, AllowString allowString)
 => str.Equals(allowString.AllowedString, StringComparison.OrdinalIgnoreCase);