2024-09-19 23:58:06 +05:00
|
|
|
const { SlashCommandBuilder, InteractionContextType, ApplicationIntegrationType, escapeEscape, escapeCodeBlock, escapeInlineCode } = require("discord.js");
|
2022-08-04 19:26:17 +05:00
|
|
|
const BaseCommand = require("../../base/BaseCommand");
|
|
|
|
|
|
|
|
class Afk extends BaseCommand {
|
|
|
|
/**
|
|
|
|
*
|
2023-11-05 16:03:23 +05:00
|
|
|
* @param {import("../base/Client")} client
|
2022-08-04 19:26:17 +05:00
|
|
|
*/
|
|
|
|
constructor(client) {
|
|
|
|
super({
|
|
|
|
command: new SlashCommandBuilder()
|
|
|
|
.setName("afk")
|
|
|
|
.setDescription(client.translate("general/afk:DESCRIPTION"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.setDescriptionLocalizations({
|
2023-07-05 00:58:06 +05:00
|
|
|
uk: client.translate("general/afk:DESCRIPTION", null, "uk-UA"),
|
|
|
|
ru: client.translate("general/afk:DESCRIPTION", null, "ru-RU"),
|
2023-06-15 19:46:27 +05:00
|
|
|
})
|
2024-09-19 23:58:06 +05:00
|
|
|
.setIntegrationTypes([ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall])
|
2024-09-14 19:52:56 +05:00
|
|
|
.setContexts([InteractionContextType.BotDM, InteractionContextType.PrivateChannel, InteractionContextType.Guild])
|
2023-07-05 00:58:06 +05:00
|
|
|
.addStringOption(option =>
|
|
|
|
option
|
|
|
|
.setName("message")
|
|
|
|
.setDescription(client.translate("common:MESSAGE"))
|
|
|
|
.setDescriptionLocalizations({
|
|
|
|
uk: client.translate("common:MESSAGE", null, "uk-UA"),
|
|
|
|
ru: client.translate("common:MESSAGE", null, "ru-RU"),
|
|
|
|
})
|
|
|
|
.setRequired(true),
|
2024-09-19 23:58:06 +05:00
|
|
|
)
|
|
|
|
.addBooleanOption(option =>
|
|
|
|
option
|
|
|
|
.setName("ephemeral")
|
|
|
|
.setDescription(client.translate("misc:EPHEMERAL_RESPONSE"))
|
|
|
|
.setDescriptionLocalizations({
|
|
|
|
uk: client.translate("misc:EPHEMERAL_RESPONSE", null, "uk-UA"),
|
|
|
|
ru: client.translate("misc:EPHEMERAL_RESPONSE", null, "ru-RU"),
|
|
|
|
}),
|
2023-07-05 00:58:06 +05:00
|
|
|
),
|
2022-08-04 19:26:17 +05:00
|
|
|
dirname: __dirname,
|
2022-12-15 21:02:38 +05:00
|
|
|
ownerOnly: false,
|
2022-08-04 19:26:17 +05:00
|
|
|
});
|
|
|
|
}
|
2024-02-06 21:45:53 +05:00
|
|
|
|
2022-08-04 19:26:17 +05:00
|
|
|
/**
|
|
|
|
*
|
2023-11-05 16:03:23 +05:00
|
|
|
* @param {import("../../base/Client")} client
|
2022-08-04 19:26:17 +05:00
|
|
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
|
|
|
*/
|
2024-02-09 23:26:57 +05:00
|
|
|
async execute(client, interaction) {
|
2024-09-19 23:58:06 +05:00
|
|
|
await interaction.deferReply({ ephemeral: interaction.options.getBoolean("ephemeral") || false });
|
2023-06-15 19:46:27 +05:00
|
|
|
|
2024-02-09 23:26:57 +05:00
|
|
|
const userData = interaction.data.user,
|
2024-09-19 23:58:06 +05:00
|
|
|
message = interaction.options.getString("message");
|
|
|
|
|
|
|
|
if (message.length > 150) return interaction.error("misc:MAX_150_CHARS", null, { edit: true });
|
2022-08-04 19:26:17 +05:00
|
|
|
|
2024-09-19 23:58:06 +05:00
|
|
|
userData.afk = escapeEscape(escapeCodeBlock(escapeInlineCode(message))).replace("@", "@\u200b");
|
2023-09-25 21:42:43 +05:00
|
|
|
|
2024-02-09 23:26:57 +05:00
|
|
|
await userData.save();
|
2022-08-04 19:26:17 +05:00
|
|
|
|
|
|
|
interaction.success("general/afk:SUCCESS", {
|
2024-09-19 23:58:06 +05:00
|
|
|
message,
|
2023-06-15 19:46:27 +05:00
|
|
|
}, { edit: true });
|
2022-08-04 19:26:17 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-05 00:58:06 +05:00
|
|
|
module.exports = Afk;
|