Add slash command builder to lock

imgbot
Kieran 2022-08-27 21:23:02 +01:00
parent ffe862dada
commit 1895916d61
2 changed files with 22 additions and 16 deletions

View File

@ -1,20 +1,26 @@
const { Discord, Client, Message, MessageEmbed, Permissions } = require('discord.js');
const { Client, CommandInteraction, Permissions } = require("discord.js");
const { SlashCommandBuilder } = require('@discordjs/builders');
const { PermissionFlagsBits } = require('discord-api-types/v10');
module.exports = {
name: 'lock',
aliases: [''],
...new SlashCommandBuilder()
.setName('lock')
.setDescription('Lock a channel')
.setDefaultMemberPermissions(PermissionFlagsBits.KickMembers | PermissionFlagsBits.BanMembers),
/**
*
* @param {Client} client
* @param {Message} message
* @param {CommandInteraction} interaction
* @param {String[]} args
*/
run: async(client, message, args) => {
const permission = message.member.permissions.has(Permissions.FLAGS.MANAGE_CHANNELS)
if (!permission)return message.reply({ contents: "You don't have permission to use this command" });
run: async (client, interaction, args) => {
message.channel.permissionOverwrites.edit(message.guild.roles.everyone.id, {SEND_MESSAGES: false});
const permission = interaction.member.permissions.has(Permissions.FLAGS.MANAGE_CHANNELS)
if (!permission)return interaction.reply({ contents: "You don't have permission to use this command", ephemeral: true });
interaction.channel.permissionOverwrites.edit(interaction.guild.roles.everyone.id, {SEND_MESSAGES: false});
interaction.reply("Channel has been locked.")
message.channel.send("Channel has been locked.")
}
}
},
};

View File

@ -6,7 +6,7 @@ client.on("interactionCreate", async (interaction) => {
if (interaction.isCommand()) {
const cmd = client.slashCommands.get(interaction.commandName);
if (!cmd)
return interaction.reply({ content: "An error has occured " });
return interaction.reply({ content: "An error has occurred" });
const args = [];