JaBa/commands/Music/volume.js

77 lines
2.2 KiB
JavaScript
Raw Permalink Normal View History

const { SlashCommandBuilder } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand");
2024-04-29 15:57:02 +05:00
const numbers = Array.from({ length: 100 }, (_, k) => k + 1);
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"),
})
.setDMPermission(false)
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-29 15:57:02 +05:00
const player = client.lavalink.getPlayer(interaction.guildId);
if (!player) 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-29 15:57:02 +05:00
await player.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-29 15:57:02 +05:00
results = numbers.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;