This commit is contained in:
2022-02-15 15:50:36 -06:00
parent c2447b180e
commit 2956e24684
10 changed files with 133 additions and 30 deletions

12
dist/util/discord.js vendored
View File

@@ -5,9 +5,7 @@ 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;
@@ -18,9 +16,7 @@ function getMember(interaction) {
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;
@@ -29,11 +25,19 @@ function getChannel(interaction) {
return channel;
}
exports.getChannel = getChannel;
/**
* get the TextChannel of an interaction
* @throws errorMessage class if the Member cannot be read
*/
function memberIsMod(interaction) {
const member = getMember(interaction);
return member.permissionsIn(interaction.channelId).has('MANAGE_MESSAGES');
}
exports.memberIsMod = memberIsMod;
/**
* get the TextChannel of an interaction
* @throws errorMessage class if the Member cannot be read or if Member is not a mod
*/
function memberIsModThrow(interaction) {
if (!memberIsMod(interaction))
throw (0, main_1.emsg)('discord.notMod');