"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.memberIsModThrow = exports.memberIsMod = exports.getChannel = exports.getMember = void 0; const discord_js_1 = require("discord.js"); const main_1 = require("./main"); /** * get the GuildMember of an interaction * @param interaction * @throws errorMessage class if it cannot be read * @returns member */ function getMember(interaction) { const member = interaction.member; if (!(member instanceof discord_js_1.GuildMember)) throw (0, main_1.emsg)('general.noMember'); return member; } exports.getMember = getMember; /** * get the TextChannel of an interaction * @param interaction * @throws errorMessage class if it cannot be read * @returns member */ function getChannel(interaction) { const channel = interaction.channel; if (!(channel instanceof discord_js_1.TextChannel)) throw (0, main_1.emsg)('general.noChannel'); return channel; } exports.getChannel = getChannel; function memberIsMod(interaction) { const member = getMember(interaction); return member.permissionsIn(interaction.channelId).has('MANAGE_MESSAGES'); } exports.memberIsMod = memberIsMod; function memberIsModThrow(interaction) { if (!memberIsMod(interaction)) throw (0, main_1.emsg)('discord.notMod'); } exports.memberIsModThrow = memberIsModThrow;