<commit_before>"use strict";
const { Base, User } = require("eris");
const { Client } = require("sosamba");
const s = require("snekfetch");
const ErisEndpoints = require("eris/lib/rest/Endpoints");
const ModLog = require("./modlog");
const WorkerManager = require("../util/worker");
const resolveInvite = require("../util/resolveInvite");
const DBProvider = require("./DBProvider");
class TTBotClient extends Client {
    constructor(token, options, db) {
        super(token, options);
        this.modLog = new ModLog(this);
        this.workers = new WorkerManager();
        const dbClass = db.provider(this);
        if (!(dbClass.prototype instanceof DBProvider))
            throw new Error("The database provider must inherit from the DBProvider class");
        this.db = new dbClass(db.options);
    }

    async postStatsTo(key = "", url = "", pld = { server_count: this.guilds.size }) {
        if (!key || !url || !pld) return;
        const data = await s.post(url)
            .set("Authorization", key)
            .send(pld);
        if (data.status <= 200 && data.status < 300) throw {
            message: "Can't post, access text or body property for more info.",
            text: data.text,
            body: data.body
        };
        return;
    }
    passesRoleHierarchy(member1, member2) {
        if (member1.guild.id !== member2.guild.id) throw new TypeError("Members aren't in the same guild");
        if (member1.guild.ownerID === member1.id) return true;
        if (member1.guild.ownerID === member2.id) return false;
        if (member1.roles.length === 0) return false;
        if (member2.roles.length === 0) return true;
        const member1Roles = member1.roles.map(r => member1.guild.roles.get(r))
            .sort((a, b) => b.position - a.position);
        const member2Roles = member2.roles.map(r => member2.guild.roles.get(r))
            .sort((a, b) => b.position - a.position);
        return member1Roles[0].position > member2Roles[0].position;
    }
    async isModerator(member, botOwnerIsMod = true) {
        if (this.isAdmin(member, botOwnerIsMod)) return true;
        const server = await this.db.getGuildConfig(member.guild.id);
        const defaultModRole = member.guild.roles
        .find(r => r.name.toLowerCase() === "tt.bot mod");
        return member.roles.includes((server && server.modRole)
            ? server.modRole
            : (defaultModRole && defaultModRole.id));
    }

    isAdmin(member, botOwnerIsAdmin = true) {
        if (botOwnerIsAdmin && isO({ author: member.user })) return true;
        if (member.permission.has("manageGuild")) return true;
        if (member.guild.ownerID === member.id) return true;
    }

    get botCollectionServers() {
        return this.guilds.filter(g => ((g.members.filter(member => member.bot).length) / g.memberCount * 100) >= 75);
    }
    // eslint disable no-useless-escape
    escapeMarkdown(string) {
        const replacedItallicsAndBold = string.replace(/\*/g, "\\*");
        const replacedBackticks = replacedItallicsAndBold.replace(/\`/g, "\\`");
        const replacedUnderscores = replacedBackticks.replace(/\_/g, "\\_");
        const replacedBrackets = replacedUnderscores.replace(/\[/g, "\\[").replace(/\(/, "\\(").replace(/\]/g, "\\]").replace(/\)/g, "\\)");
        return replacedBrackets;
    }
    //actually Client.getRESTUser, but bypasses the need of options.restMode
    getUserWithoutRESTMode(userID) {
        return this.requestHandler.request("GET", ErisEndpoints.USER(userID), true).then((user) => new User(user, this));
    }

    getBaseObject(id) {
        return new Base(id);
    }<commit_msg>Fix linting issues for 0baa69842b8a570eb7957094b74ba6ac7fc4d676<commit_after>"use strict";
const { Base, User } = require("eris");
const { Client } = require("sosamba");
const s = require("snekfetch");
const ErisEndpoints = require("eris/lib/rest/Endpoints");
const ModLog = require("./modlog");
const WorkerManager = require("../util/worker");
const resolveInvite = require("../util/resolveInvite");
const DBProvider = require("./DBProvider");
class TTBotClient extends Client {
    constructor(token, options, db) {
        super(token, options);
        this.modLog = new ModLog(this);
        this.workers = new WorkerManager();
        const dbClass = db.provider(this);
        if (!(dbClass.prototype instanceof DBProvider))
            throw new Error("The database provider must inherit from the DBProvider class");
        this.db = new dbClass(db.options);
    }

    async postStatsTo(key = "", url = "", pld = { server_count: this.guilds.size }) {
        if (!key || !url || !pld) return;
        const data = await s.post(url)
            .set("Authorization", key)
            .send(pld);
        if (data.status <= 200 && data.status < 300) throw {
            message: "Can't post, access text or body property for more info.",
            text: data.text,
            body: data.body
        };
        return;
    }
    passesRoleHierarchy(member1, member2) {
        if (member1.guild.id !== member2.guild.id) throw new TypeError("Members aren't in the same guild");
        if (member1.guild.ownerID === member1.id) return true;
        if (member1.guild.ownerID === member2.id) return false;
        if (member1.roles.length === 0) return false;
        if (member2.roles.length === 0) return true;
        const member1Roles = member1.roles.map(r => member1.guild.roles.get(r))
            .sort((a, b) => b.position - a.position);
        const member2Roles = member2.roles.map(r => member2.guild.roles.get(r))
            .sort((a, b) => b.position - a.position);
        return member1Roles[0].position > member2Roles[0].position;
    }
    async isModerator(member, botOwnerIsMod = true) {
        if (this.isAdmin(member, botOwnerIsMod)) return true;
        const server = await this.db.getGuildConfig(member.guild.id);
        const defaultModRole = member.guild.roles
            .find(r => r.name.toLowerCase() === "tt.bot mod");
        return member.roles.includes((server && server.modRole)
            ? server.modRole
            : (defaultModRole && defaultModRole.id));
    }

    isAdmin(member, botOwnerIsAdmin = true) {
        if (botOwnerIsAdmin && isO({ author: member.user })) return true;
        if (member.permission.has("manageGuild")) return true;
        if (member.guild.ownerID === member.id) return true;
    }

    get botCollectionServers() {
        return this.guilds.filter(g => ((g.members.filter(member => member.bot).length) / g.memberCount * 100) >= 75);
    }
    // eslint disable no-useless-escape
    escapeMarkdown(string) {
        const replacedItallicsAndBold = string.replace(/\*/g, "\\*");
        const replacedBackticks = replacedItallicsAndBold.replace(/\`/g, "\\`");
        const replacedUnderscores = replacedBackticks.replace(/\_/g, "\\_");
        const replacedBrackets = replacedUnderscores.replace(/\[/g, "\\[").replace(/\(/, "\\(").replace(/\]/g, "\\]").replace(/\)/g, "\\)");
        return replacedBrackets;
    }
    //actually Client.getRESTUser, but bypasses the need of options.restMode
    getUserWithoutRESTMode(userID) {
        return this.requestHandler.request("GET", ErisEndpoints.USER(userID), true).then((user) => new User(user, this));
    }

    getBaseObject(id) {
        return new Base(id);
    }
{'fraction_non_alphanumeric': 0.15202610824041338, 'fraction_numerical': 0.012374218112591786, 'mean_word_length': 2.7583035258048034, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, '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': '3338689', 'n_tokens_mistral': 2328, 'n_tokens_neox': 2248, 'n_words': 504}