JaBa/commands/Music/volume.js

76 lines
2.2 KiB
JavaScript
Raw Normal View History

2024-09-14 19:52:56 +05:00
const { SlashCommandBuilder, InteractionContextType } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand");
class Volume extends BaseCommand {
/**
*
2023-11-05 16:03:23 +05:00
* @param {import("../base/Client")} client
*/
constructor(client) {
super({
command: new SlashCommandBuilder()
.setName("volume")
.setDescription(client.translate("music/volume:DESCRIPTION"))
.setDescriptionLocalizations({
2023-07-05 00:58:06 +05:00
uk: client.translate("music/volume:DESCRIPTION", null, "uk-UA"),
ru: client.translate("music/volume:DESCRIPTION", null, "ru-RU"),
})
2024-09-14 19:52:56 +05:00
.setContexts([InteractionContextType.PrivateChannel, InteractionContextType.Guild])
2023-07-05 00:58:06 +05:00
.addIntegerOption(option =>
option
.setName("int")
.setDescription(client.translate("common:INT"))
.setDescriptionLocalizations({
uk: client.translate("common:INT", null, "uk-UA"),
ru: client.translate("common:INT", null, "ru-RU"),
})
.setRequired(true)
.setAutocomplete(true),
),
dirname: __dirname,
ownerOnly: false,
});
}
/**
*
2023-11-05 16:03:23 +05:00
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/
async execute(client, interaction) {
const voice = interaction.member.voice.channel;
if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL", null, { ephemeral: true });
2024-04-30 12:19:44 +05:00
const queue = client.player.nodes.get(interaction.guildId);
if (!queue) return interaction.error("music/play:NOT_PLAYING", null, { ephemeral: true });
const volume = interaction.options.getInteger("int");
2023-03-27 19:27:48 +05:00
if (volume <= 0 || volume > 100) return interaction.error("misc:INVALID_NUMBER_RANGE", { min: 1, max: 100 });
2024-04-30 12:19:44 +05:00
queue.node.setVolume(volume);
interaction.success("music/volume:SUCCESS", {
volume,
});
}
/**
*
2023-11-05 16:03:23 +05:00
* @param {import("../../base/Client")} client
* @param {import("discord.js").AutocompleteInteraction} interaction
* @returns
*/
async autocompleteRun(client, interaction) {
const int = interaction.options.getInteger("int"),
2024-04-30 12:19:44 +05:00
results = Array.from({ length: 100 }, (_, k) => k + 1).filter(i => i.toString().includes(int));
2024-01-15 23:19:59 +05:00
return await interaction.respond(
results.slice(0, 25).map(i => ({
name: i,
value: i,
2023-07-05 00:58:06 +05:00
})),
);
}
}
2023-07-05 00:58:06 +05:00
module.exports = Volume;