Use the built in permission check for users

pull/1/head
Supositware 2 years ago
parent d36d086388
commit 069639a4c5

@ -4,9 +4,9 @@ import db from '../../models/index.js';
export default {
data: new SlashCommandBuilder()
.setName('autoresponse')
.setDescription('Enable or disable autoresponse'),
.setDescription('Enable or disable autoresponse')
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages),
category: 'admin',
userPermissions: [PermissionFlagsBits.ManageMessages],
async execute(interaction, args, client) {
const autoresponseStat = await db.autoresponseStat.findOne({ where: { serverID: interaction.guild.id } });

@ -4,9 +4,9 @@ import db from '../../models/index.js';
export default {
data: new SlashCommandBuilder()
.setName('quotation')
.setDescription('Enable or disable quotations'),
.setDescription('Enable or disable quotations')
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages),
category: 'admin',
userPermissions: [PermissionFlagsBits.ManageMessages],
async execute(interaction, args, client) {
const quotationstat = await db.quotationstat.findOne({ where: { serverID: interaction.guild.id } });

@ -37,7 +37,7 @@ export default {
}
// Check if the bot has the needed permissions
if (command.clientPermissions) {
if (command.default_permission) {
const clientMember = await interaction.guild.members.fetch(client.user.id);
if (!clientMember.permissions.has(command.clientPermissions)) {
return interaction.reply({ content: `❌ I am missing one of the following permission(s): \`${new PermissionFlagsBits(command.clientPermissions).toArray()}\``, ephemeral: true });
@ -45,11 +45,13 @@ export default {
}
// Check if the user has the needed permissions
if (command.userPermissions) {
/*
if (command.default_member_permissions) {
if (!interaction.member.permissions.has(command.userPermissions)) {
return interaction.reply({ content: `❌ You are missing one of the following permission(s): \`${new PermissionFlagsBits(command.userPermissions).toArray()}\``, ephemeral: true });
}
}
*/
try {
const date = new Date();
@ -77,7 +79,6 @@ export default {
const args = [];
interaction.options.data.forEach(arg => {
console.log(arg);
if (arg.type === 'MENTIONABLE') {
return args.push(arg.member);
}

@ -7,8 +7,6 @@ import db from '../../models/index.js';
import { rand } from '../../utils/rand.js';
const ratelimit = {};
import dotenv from 'dotenv';
dotenv.config();
const { ownerId, prefix } = process.env;
const prefixs = prefix.split(',');
@ -308,8 +306,8 @@ export default {
}
// Check if the user has the needed permissions
if (command.userPermissions) {
if (!message.member.permissions.has(command.userPermissions)) {
if (command.default_member_permissions) {
if (!message.member.permissions.has(command.default_member_permissions)) {
return message.reply({ content: `❌ You are missing one of the following permission(s): \`${new PermissionFlagsBits(command.userPermissions).toArray()}\``, ephemeral: true });
}
}

Loading…
Cancel
Save