I made a code that closes the specific channel that you write the command in.
This is my code that redirects each command to its own folder and runs the code in it.
eventsmessage.js
module.exports = (client, message) => {
// Ignore all bots
if (message.author.bot) return;
// Ignore messages not starting with the prefix (in config.json)
if (message.content.indexOf(client.config.prefix) !== 0) return;
// Our standard argument/command name definition.
const args = message.content.slice(client.config.prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
// Grab the command data from the client.commands Enmap
const cmd = client.commands.get(command);
// If that command doesn't exist, silently exit and do nothing
if (!cmd) return;
// Run the command
cmd.run(client, message, args);
};
And my code that deletes the channel the command is written in.
const ms = require('ms');
const Discord = require('discord.js');
const client = new Discord.Client();
exports.run = async (client, message, args) => {
if (!message.member.permissions.has("ADMINISTRATOR", "Ticket Admin"))
return message.reply('You need a specify permission to setup a ticket!');
if (message.author.bot) return;
const msgargs = message.content.slice(client.config.prefix.length).trim().split(/ +/g);
const command = msgargs.shift().toLowerCase();
if(command == "close") {
if(!message.channel.name.includes("ticket-")) return message.channel.send("You cannot use that here!")
message.channel.delete();
}
};
but the problem is that it doesn't want to delete the channel with "ticket-" in his name and it's the channel that the command was written in.
any help will be appreciated.
question from:
https://stackoverflow.com/questions/65945424/how-delete-a-channel-with-a-specific-command 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…