<commit_before>const search_members = require("./search_members");

function eat(message, options) {
    let found_obj = search_members(message.channel.guild.members, message.content.split(" "));
    Object.keys(found_obj).forEach(key => {
        message.content = message.content.replace(key, found_obj[key]);
    });
    
    return new Promise(resolve => {
        let searches = Object.keys(options);
        let responses = {};

        for (let search in options) {
            let type = options[search];
            let split = message.content.split(" ");
            let not_search = searches.slice(0);
            not_search.splice(searches.indexOf(search), 1);

            let first_found = split.includes(search) ? split.indexOf(search) : false;

            let outer_bound = false;
            not_search.forEach(term => {
                if (split.indexOf(term) > split.indexOf(search)) outer_bound = split.indexOf(term);
            });

            if (first_found) {
                let res = split.slice(first_found + 1, outer_bound || split.length);
                switch (type) {
                case "string":
                    responses[search] = res.join(" ");
                    break;
                case "member":
                    responses[search] = res;
                    break;
                }
            }
        }

        resolve(responses);
    });
}

module.exports = eat;
<commit_msg>actualy fix weird member issue<commit_after>const search_members = require("./search_members");

function eat(message, options) {
    return new Promise(resolve => {
        let searches = Object.keys(options);
        let responses = {};

        for (let search in options) {
            let type = options[search];
            let content = message.content.slice();

            if (search == "member") {
                let found_obj = search_members(message.channel.guild.members, content.split(" "));
                Object.keys(found_obj).forEach(key => {
                    content = content.replace(key, found_obj[key]);
                });
            }

            let split = content.split(" ");
            let not_search = searches.slice(0);
            not_search.splice(searches.indexOf(search), 1);

            let first_found = split.includes(search) ? split.indexOf(search) : false;

            let outer_bound = false;
            not_search.forEach(term => {
                if (split.indexOf(term) > split.indexOf(search)) outer_bound = split.indexOf(term);
            });

            if (first_found) {
                let res = split.slice(first_found + 1, outer_bound || split.length);
                switch (type) {
                case "string":
                    responses[search] = res.join(" ");
                    break;
                case "member":
                    responses[search] = res;
                    break;
                }
            }
        }

        resolve(responses);
    });
}

module.exports = eat;

{'fraction_non_alphanumeric': 0.11980033277870217, 'fraction_numerical': 0.0019966722129783694, 'mean_word_length': 1.6507936507936507, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3335078', 'n_tokens_mistral': 804, 'n_tokens_neox': 763, 'n_words': 160}