2023-07-03 21:13:08 +05:00
|
|
|
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js");
|
2022-08-08 18:19:56 +05:00
|
|
|
const BaseCommand = require("../../base/BaseCommand");
|
|
|
|
|
|
|
|
class Welcome extends BaseCommand {
|
|
|
|
/**
|
|
|
|
*
|
2023-11-05 16:03:23 +05:00
|
|
|
* @param {import("../../base/Client")} client
|
2022-08-08 18:19:56 +05:00
|
|
|
*/
|
|
|
|
constructor(client) {
|
|
|
|
super({
|
|
|
|
command: new SlashCommandBuilder()
|
|
|
|
.setName("welcome")
|
|
|
|
.setDescription(client.translate("administration/welcome:DESCRIPTION"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.setDescriptionLocalizations({
|
2023-07-05 00:58:06 +05:00
|
|
|
uk: client.translate("administration/welcome:DESCRIPTION", null, "uk-UA"),
|
|
|
|
ru: client.translate("administration/welcome:DESCRIPTION", null, "ru-RU"),
|
2023-06-15 19:46:27 +05:00
|
|
|
})
|
2022-10-13 00:05:36 +05:00
|
|
|
.setDMPermission(false)
|
2023-07-03 21:13:08 +05:00
|
|
|
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageGuild)
|
2023-07-05 00:58:06 +05:00
|
|
|
.addSubcommand(subcommand =>
|
|
|
|
subcommand
|
|
|
|
.setName("test")
|
|
|
|
.setDescription(client.translate("administration/goodbye:TEST"))
|
|
|
|
.setDescriptionLocalizations({
|
|
|
|
uk: client.translate("administration/goodbye:TEST", null, "uk-UA"),
|
|
|
|
ru: client.translate("administration/goodbye:TEST", null, "ru-RU"),
|
|
|
|
}),
|
2022-08-08 18:19:56 +05:00
|
|
|
)
|
2023-07-05 00:58:06 +05:00
|
|
|
.addSubcommand(subcommand =>
|
|
|
|
subcommand
|
|
|
|
.setName("config")
|
|
|
|
.setDescription(client.translate("administration/goodbye:CONFIG"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.setDescriptionLocalizations({
|
2023-07-05 00:58:06 +05:00
|
|
|
uk: client.translate("administration/goodbye:CONFIG", null, "uk-UA"),
|
|
|
|
ru: client.translate("administration/goodbye:CONFIG", null, "ru-RU"),
|
2023-06-15 19:46:27 +05:00
|
|
|
})
|
2023-07-05 00:58:06 +05:00
|
|
|
.addBooleanOption(option =>
|
|
|
|
option
|
|
|
|
.setName("state")
|
|
|
|
.setDescription(client.translate("common:STATE"))
|
|
|
|
.setDescriptionLocalizations({
|
|
|
|
uk: client.translate("common:STATE", null, "uk-UA"),
|
|
|
|
ru: client.translate("common:STATE", null, "ru-RU"),
|
|
|
|
})
|
|
|
|
.setRequired(true),
|
|
|
|
)
|
|
|
|
.addChannelOption(option =>
|
|
|
|
option
|
|
|
|
.setName("channel")
|
|
|
|
.setDescription(client.translate("common:CHANNEL"))
|
|
|
|
.setDescriptionLocalizations({
|
|
|
|
uk: client.translate("common:CHANNEL", null, "uk-UA"),
|
|
|
|
ru: client.translate("common:CHANNEL", null, "ru-RU"),
|
|
|
|
}),
|
|
|
|
)
|
|
|
|
.addStringOption(option =>
|
|
|
|
option
|
|
|
|
.setName("message")
|
|
|
|
.setDescription(client.translate("administration/goodbye:MESSAGE"))
|
|
|
|
.setDescriptionLocalizations({
|
|
|
|
uk: client.translate("administration/goodbye:MESSAGE", null, "uk-UA"),
|
|
|
|
ru: client.translate("administration/goodbye:MESSAGE", null, "ru-RU"),
|
|
|
|
}),
|
|
|
|
),
|
2024-07-13 15:43:14 +05:00
|
|
|
// .addBooleanOption(option =>
|
|
|
|
// option
|
|
|
|
// .setName("image")
|
|
|
|
// .setDescription(client.translate("administration/goodbye:IMAGE"))
|
|
|
|
// .setDescriptionLocalizations({
|
|
|
|
// uk: client.translate("administration/goodbye:IMAGE", null, "uk-UA"),
|
|
|
|
// ru: client.translate("administration/goodbye:IMAGE", null, "ru-RU"),
|
|
|
|
// }),
|
|
|
|
// ),
|
2022-08-08 18:19:56 +05:00
|
|
|
),
|
|
|
|
dirname: __dirname,
|
2022-12-15 21:02:38 +05:00
|
|
|
ownerOnly: false,
|
2022-08-08 18:19:56 +05:00
|
|
|
});
|
|
|
|
}
|
2024-02-06 21:45:53 +05:00
|
|
|
|
2022-08-08 18:19:56 +05:00
|
|
|
/**
|
|
|
|
*
|
2023-11-05 16:03:23 +05:00
|
|
|
* @param {import("../../base/Client")} client
|
2022-08-08 18:19:56 +05:00
|
|
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
|
|
|
*/
|
2024-02-09 23:26:57 +05:00
|
|
|
async execute(client, interaction) {
|
2024-07-13 15:43:14 +05:00
|
|
|
await interaction.deferReply({ ephemeral: true });
|
|
|
|
|
2024-02-09 23:26:57 +05:00
|
|
|
const guildData = interaction.data.guild,
|
|
|
|
command = interaction.options.getSubcommand();
|
2022-08-08 18:19:56 +05:00
|
|
|
|
|
|
|
if (command === "test") {
|
2024-07-13 15:43:14 +05:00
|
|
|
client.emit("guildMemberAdd", client, interaction.member);
|
2023-01-09 01:39:13 +05:00
|
|
|
|
2024-07-13 15:43:14 +05:00
|
|
|
interaction.success("administration/goodbye:TEST_SUCCESS", null, { edit: true });
|
2022-08-08 18:19:56 +05:00
|
|
|
} else {
|
|
|
|
const state = interaction.options.getBoolean("state");
|
|
|
|
|
|
|
|
if (!state) {
|
2024-02-09 23:26:57 +05:00
|
|
|
guildData.plugins.welcome = {
|
2022-08-08 18:19:56 +05:00
|
|
|
enabled: false,
|
|
|
|
message: null,
|
|
|
|
channelID: null,
|
2022-12-15 21:02:38 +05:00
|
|
|
withImage: null,
|
2022-08-08 18:19:56 +05:00
|
|
|
};
|
2023-09-25 21:42:43 +05:00
|
|
|
|
2024-07-13 15:43:14 +05:00
|
|
|
guildData.markModified("plugins.welcome");
|
2024-02-09 23:26:57 +05:00
|
|
|
await guildData.save();
|
2022-08-08 18:19:56 +05:00
|
|
|
|
2024-07-13 15:43:14 +05:00
|
|
|
interaction.success("administration/welcome:DISABLED", null);
|
2022-08-08 18:19:56 +05:00
|
|
|
} else {
|
2023-06-17 00:44:47 +05:00
|
|
|
const channel = interaction.options.getChannel("channel") || interaction.channel;
|
2022-08-14 23:07:44 +05:00
|
|
|
const message = interaction.options.getString("message") || interaction.translate("administration/welcome:DEFAULT_MESSAGE");
|
2024-07-13 15:43:14 +05:00
|
|
|
const image = false; // interaction.options.getBoolean("image") || false;
|
2022-08-08 18:19:56 +05:00
|
|
|
|
2024-02-09 23:26:57 +05:00
|
|
|
guildData.plugins.welcome = {
|
2022-08-08 18:19:56 +05:00
|
|
|
enabled: true,
|
|
|
|
channel: channel.id,
|
|
|
|
message: message,
|
|
|
|
withImage: image,
|
|
|
|
};
|
2023-09-25 21:42:43 +05:00
|
|
|
|
2024-07-13 15:43:14 +05:00
|
|
|
guildData.markModified("plugins.welcome");
|
2024-02-09 23:26:57 +05:00
|
|
|
await guildData.save();
|
2022-08-08 18:19:56 +05:00
|
|
|
|
|
|
|
interaction.success("administration/welcome:ENABLED", {
|
2024-01-29 18:49:14 +05:00
|
|
|
channel: `${channel.toString()}`,
|
2024-07-13 15:43:14 +05:00
|
|
|
}, { edit: true });
|
2022-08-08 18:19:56 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-05 00:58:06 +05:00
|
|
|
module.exports = Welcome;
|