2021-10-21 19:28:23 +01:00
|
|
|
// SupportBot | Emerald Services
|
2021-10-24 22:41:46 +01:00
|
|
|
// Ticket Remove Command
|
2021-10-21 19:28:23 +01:00
|
|
|
|
|
|
|
|
const fs = require("fs");
|
|
|
|
|
|
|
|
|
|
const Discord = require("discord.js");
|
2021-10-24 22:41:46 +01:00
|
|
|
const yaml = require("js-yaml");
|
2021-10-27 19:30:10 -05:00
|
|
|
const supportbot = yaml.load(
|
|
|
|
|
fs.readFileSync("./Configs/supportbot.yml", "utf8")
|
|
|
|
|
);
|
|
|
|
|
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
2021-10-21 19:28:23 +01:00
|
|
|
|
|
|
|
|
const Command = require("../Structures/Command.js");
|
|
|
|
|
|
|
|
|
|
async function asyncForEach(array, callback) {
|
2021-10-24 22:41:46 +01:00
|
|
|
for (let index = 0; index < array.length; index++) {
|
|
|
|
|
await callback(array[index], index, array);
|
2021-10-21 19:28:23 +01:00
|
|
|
}
|
2021-10-24 22:41:46 +01:00
|
|
|
}
|
2021-10-21 19:28:23 +01:00
|
|
|
|
|
|
|
|
module.exports = new Command({
|
2021-10-24 22:41:46 +01:00
|
|
|
name: cmdconfig.TicketRemove,
|
|
|
|
|
description: cmdconfig.TicketRemoveDesc,
|
|
|
|
|
slashCommandOptions: [
|
|
|
|
|
{
|
|
|
|
|
name: "user",
|
|
|
|
|
description: "User to remove",
|
|
|
|
|
type: "USER",
|
|
|
|
|
required: true,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
permission: "SEND_MESSAGES",
|
2021-10-21 19:28:23 +01:00
|
|
|
|
2021-10-24 22:41:46 +01:00
|
|
|
async run(interaction) {
|
|
|
|
|
let SupportStaff =
|
|
|
|
|
interaction.guild.roles.cache.find(
|
|
|
|
|
(SupportTeam) => SupportTeam.name === supportbot.Staff
|
|
|
|
|
) ||
|
|
|
|
|
interaction.guild.roles.cache.find(
|
|
|
|
|
(SupportTeam) => SupportTeam.id === supportbot.Staff
|
|
|
|
|
);
|
|
|
|
|
let Admins =
|
|
|
|
|
interaction.guild.roles.cache.find(
|
|
|
|
|
(AdminUser) => AdminUser.name === supportbot.Admin
|
|
|
|
|
) ||
|
|
|
|
|
interaction.guild.roles.cache.find(
|
|
|
|
|
(AdminUser) => AdminUser.id === supportbot.Admin
|
|
|
|
|
);
|
2021-10-21 19:28:23 +01:00
|
|
|
|
2021-10-24 22:41:46 +01:00
|
|
|
const NoPerms = new Discord.MessageEmbed()
|
|
|
|
|
.setTitle("Invalid Permissions!")
|
|
|
|
|
.setDescription(
|
|
|
|
|
`${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\` or \`${supportbot.Admin}\``
|
|
|
|
|
)
|
|
|
|
|
.setColor(supportbot.WarningColour);
|
2021-10-21 19:28:23 +01:00
|
|
|
|
2021-10-24 22:41:46 +01:00
|
|
|
if (
|
|
|
|
|
interaction.member.roles.cache.has(SupportStaff.id) ||
|
|
|
|
|
interaction.member.roles.cache.has(Admins.id)
|
|
|
|
|
) {
|
2021-10-27 19:39:07 -05:00
|
|
|
if (!interaction.channel.name.startsWith(`${supportbot.TicketPrefix}`)) {
|
2021-10-24 22:41:46 +01:00
|
|
|
const Exists = new Discord.MessageEmbed()
|
|
|
|
|
.setTitle("No Ticket Found!")
|
|
|
|
|
.setDescription(`${supportbot.NoValidTicket}`)
|
|
|
|
|
.setColor(supportbot.WarningColour);
|
|
|
|
|
return interaction.reply({ embeds: [Exists] });
|
|
|
|
|
}
|
2021-10-21 19:28:23 +01:00
|
|
|
|
2021-10-24 22:41:46 +01:00
|
|
|
let uMember = interaction.options.getUser("user");
|
|
|
|
|
const UserNotExist = new Discord.MessageEmbed()
|
|
|
|
|
.setTitle("User Not Found!")
|
|
|
|
|
.setDescription(
|
|
|
|
|
`${supportbot.UserNotFound}\n\nTry Again:\`/${cmdconfig.TicketRemove} <user#0000>\``
|
|
|
|
|
)
|
|
|
|
|
.setColor(supportbot.ErrorColour);
|
2021-10-21 19:28:23 +01:00
|
|
|
|
2021-10-24 22:41:46 +01:00
|
|
|
if (!uMember) return interaction.reply({ embeds: [UserNotExist] });
|
2021-10-21 19:28:23 +01:00
|
|
|
|
2021-10-24 22:41:46 +01:00
|
|
|
interaction.channel.permissionOverwrites.edit(uMember, {
|
|
|
|
|
VIEW_CHANNEL: false,
|
|
|
|
|
READ_MESSAGE_HISTORY: false,
|
|
|
|
|
SEND_MESSAGES: false,
|
|
|
|
|
});
|
2021-10-21 19:28:23 +01:00
|
|
|
|
2021-10-24 22:41:46 +01:00
|
|
|
const Complete = new Discord.MessageEmbed()
|
|
|
|
|
.setTitle("User Removed!")
|
|
|
|
|
.setDescription(supportbot.RemovedUser.replace(/%user%/g, uMember.id))
|
|
|
|
|
.setTimestamp()
|
|
|
|
|
.setColor(supportbot.EmbedColour);
|
|
|
|
|
interaction.reply({ embeds: [Complete] });
|
|
|
|
|
} else {
|
|
|
|
|
return interaction.reply({ embeds: [NoPerms] });
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|