JaBa/commands/Music/volume.js

77 lines
2.3 KiB
JavaScript
Raw Permalink Normal View History

2024-09-19 23:58:06 +05:00
const { SlashCommandBuilder, InteractionContextType, ApplicationIntegrationType } = 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"),
})
.setIntegrationTypes([ApplicationIntegrationType.GuildInstall])
.setContexts([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;