aboutsummaryrefslogtreecommitdiff
path: root/bot/src/storage/functions.js
blob: c689659f1d6ff71b09857923261f9dac8ba87128 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { blacklistGuild, blacklistUser } from '../db/models/blacklist.js';
import { MessageFlags } from 'discord.js';

export function error(e) {
    return `**Something went wrong. [Submit an issue at the AleeBot repository.](<https://github.com/Alee14/AleeBot/issues>)**\nMessage:\n\`\`\`js\n${e.stack}\`\`\``;
}

export async function blacklistCheck(interaction) {
    const blacklistedUser = await blacklistUser.findOne({ where: { userID: interaction.user.id } });
    const blacklistedGuild = await blacklistGuild.findOne({ where: { guildID: interaction.guild.id } });

    if (blacklistedUser || blacklistedGuild) {
        await interaction.reply({ content: blacklistedUser ? 'You are banned from using this command.' : 'This server is banned from using this command.', flags: MessageFlags.Ephemeral });
        return true;
    }

    return false;
}