2022-08-08 18:19:56 +05:00
|
|
|
const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js");
|
|
|
|
const BaseCommand = require("../../base/BaseCommand");
|
|
|
|
|
|
|
|
class Goodbye extends BaseCommand {
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
*/
|
|
|
|
constructor(client) {
|
|
|
|
super({
|
|
|
|
command: new SlashCommandBuilder()
|
|
|
|
.setName("goodbye")
|
|
|
|
.setDescription(client.translate("administration/goodbye:DESCRIPTION"))
|
2022-10-13 00:05:36 +05:00
|
|
|
.setDMPermission(false)
|
2022-11-09 21:33:45 +05:00
|
|
|
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
2022-08-08 18:19:56 +05:00
|
|
|
.addSubcommand(subcommand => subcommand.setName("test")
|
2022-12-15 21:02:38 +05:00
|
|
|
.setDescription(client.translate("administration/goodbye:TEST")),
|
2022-08-08 18:19:56 +05:00
|
|
|
)
|
|
|
|
.addSubcommand(subcommand => subcommand.setName("config")
|
|
|
|
.setDescription(client.translate("administration/goodbye:CONFIG"))
|
|
|
|
.addBooleanOption(option => option.setName("state")
|
|
|
|
.setDescription(client.translate("common:STATE"))
|
|
|
|
.setRequired(true))
|
|
|
|
.addChannelOption(option => option.setName("channel")
|
|
|
|
.setDescription(client.translate("common:CHANNEL")))
|
|
|
|
.addStringOption(option => option.setName("message")
|
|
|
|
.setDescription(client.translate("common:MESSAGE")))
|
|
|
|
.addBooleanOption(option => option.setName("image")
|
2022-12-15 21:02:38 +05:00
|
|
|
.setDescription(client.translate("administration/goodbye:IMAGE"))),
|
2022-08-08 18:19:56 +05:00
|
|
|
),
|
|
|
|
aliases: [],
|
|
|
|
dirname: __dirname,
|
2022-12-15 21:02:38 +05:00
|
|
|
ownerOnly: false,
|
2022-08-08 18:19:56 +05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
*/
|
|
|
|
async onLoad() {
|
|
|
|
//...
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
2022-08-09 23:48:33 +05:00
|
|
|
* @param {Object} data
|
2022-08-08 18:19:56 +05:00
|
|
|
*/
|
|
|
|
async execute(client, interaction, data) {
|
|
|
|
const command = interaction.options.getSubcommand();
|
|
|
|
|
|
|
|
if (command === "test") {
|
|
|
|
client.emit("guildMemberRemove", interaction.member);
|
2023-01-09 01:39:13 +05:00
|
|
|
|
|
|
|
interaction.success("administration/goodbye:TEST_SUCCESS", null, { ephemeral: true });
|
2022-08-08 18:19:56 +05:00
|
|
|
} else {
|
|
|
|
const state = interaction.options.getBoolean("state");
|
|
|
|
|
|
|
|
if (!state) {
|
|
|
|
data.guildData.plugins.goodbye = {
|
|
|
|
enabled: false,
|
|
|
|
message: null,
|
|
|
|
channelID: null,
|
2022-12-15 21:02:38 +05:00
|
|
|
withImage: null,
|
2022-08-08 18:19:56 +05:00
|
|
|
};
|
|
|
|
data.guildData.markModified("plugins.goodbye");
|
|
|
|
await data.guildData.save();
|
|
|
|
|
|
|
|
interaction.success("administration/goodbye:DISABLED");
|
|
|
|
} else {
|
|
|
|
const channel = interaction.options.getChannel("channel");
|
2022-08-14 23:07:44 +05:00
|
|
|
const message = interaction.options.getString("message") || interaction.translate("administration/goodbye:DEFAULT_MESSAGE");
|
2022-08-08 18:19:56 +05:00
|
|
|
const image = interaction.options.getBoolean("image");
|
|
|
|
|
|
|
|
data.guildData.plugins.goodbye = {
|
|
|
|
enabled: true,
|
|
|
|
channel: channel.id,
|
|
|
|
message: message,
|
|
|
|
withImage: image,
|
|
|
|
};
|
|
|
|
data.guildData.markModified("plugins.goodbye");
|
|
|
|
await data.guildData.save();
|
|
|
|
|
|
|
|
interaction.success("administration/goodbye:ENABLED", {
|
2022-12-15 21:02:38 +05:00
|
|
|
channel: `<#${data.guildData.plugins.goodbye.channel}>`,
|
2022-11-09 22:47:56 +05:00
|
|
|
}, { ephemeral: true });
|
2022-08-08 18:19:56 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Goodbye;
|