mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-02 14:38:49 +00:00
16 files changed
+314
-46
No files matched your search
@@ -31,37 +31,11 @@ module.exports = {
|
||||
.setDescription(
|
||||
`${embedOptions.icons.rule} **List of commands**\n` +
|
||||
`${commandListString}\n\n` +
|
||||
`${embedOptions.icons.support} **Support server**\nJoin the support server for help or suggestions: \n**${botOptions.serverInviteUrl}**\n\n` +
|
||||
`${embedOptions.icons.support} **Support server**\nJoin the support server for help or to suggest improvements: \n**${botOptions.serverInviteUrl}**\n\n` +
|
||||
`${embedOptions.icons.bot} **Enjoying ${botOptions.name}?**\nAdd me to another server: \n**[Click me!](${botOptions.botInviteUrl})**`
|
||||
)
|
||||
.setColor(embedOptions.colors.info)
|
||||
]
|
||||
});
|
||||
|
||||
/*
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`${embedOptions.icons.rule} **List of commands**\n` +
|
||||
'- **`/play` `query`** - Add a track or playlist to the queue by url or search.\n' +
|
||||
'- **`/pause`** - Pause or resume the current track.\n' +
|
||||
'- **`/queue` `[page]`** - Show the list of tracks added to the queue.\n' +
|
||||
'- **`/nowplaying`** - Show information about the track currently playing.\n' +
|
||||
'- **`/seek` `duration`** - Seek to a specified duration in the current track.\n' +
|
||||
`- **\`/loop\` \`mode\`** - ${embedOptions.icons.beta} Toggle looping a track, the whole queue or autoplay.\n` +
|
||||
`- **\`/filters\`** - ${embedOptions.icons.beta} Toggle various audio filters during playback.\n` +
|
||||
'- **`/volume` `[percentage]`** - Show or set the playback volume for tracks.\n' +
|
||||
'- **`/skip` `[tracknumber]`** - Skip to next or specified track.\n' +
|
||||
'- **`/remove` `tracknumber`** - Remove specified track from the queue.\n' +
|
||||
`- **\`/stop\`** - ${embedOptions.icons.new} Stop playing audio and clear the track queue.\n` +
|
||||
'- **`/leave`** - Clear the queue and remove the bot from voice channel.\n\n' +
|
||||
`${embedOptions.icons.support} **Support server**\nJoin the support server for help or suggestions: \n**${botOptions.serverInviteUrl}**\n\n` +
|
||||
`${embedOptions.icons.bot} **Enjoying ${botOptions.name}?**\nAdd me to another server: \n**[Click me!](${botOptions.botInviteUrl})**`
|
||||
)
|
||||
.setColor(embedOptions.colors.info)
|
||||
]
|
||||
});
|
||||
*/
|
||||
}
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
const logger = require('../../services/logger');
|
||||
const { embedOptions, ffmpegFilterOptions } = require('../../config');
|
||||
const { notInVoiceChannel } = require('../../utils/validation/voiceChannelValidator');
|
||||
const { notInVoiceChannel, notInSameVoiceChannel } = require('../../utils/validation/voiceChannelValidator');
|
||||
const { queueDoesNotExist, queueNoCurrentTrack } = require('../../utils/validation/queueValidator');
|
||||
const {
|
||||
SlashCommandBuilder,
|
||||
@@ -31,6 +31,10 @@ module.exports = {
|
||||
return;
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel(interaction, queue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (await queueNoCurrentTrack(interaction, queue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const logger = require('../../services/logger');
|
||||
const { embedOptions } = require('../../config');
|
||||
const { notInVoiceChannel } = require('../../utils/validation/voiceChannelValidator');
|
||||
const { notInVoiceChannel, notInSameVoiceChannel } = require('../../utils/validation/voiceChannelValidator');
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
||||
const { useQueue } = require('discord-player');
|
||||
|
||||
@@ -34,6 +34,10 @@ module.exports = {
|
||||
});
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel(interaction, queue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!queue.deleted) {
|
||||
queue.delete();
|
||||
logger.debug(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const logger = require('../../services/logger');
|
||||
const { embedOptions, botOptions } = require('../../config');
|
||||
const { notInVoiceChannel } = require('../../utils/validation/voiceChannelValidator');
|
||||
const { notInVoiceChannel, notInSameVoiceChannel } = require('../../utils/validation/voiceChannelValidator');
|
||||
const { queueDoesNotExist } = require('../../utils/validation/queueValidator');
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
||||
const { useQueue } = require('discord-player');
|
||||
@@ -36,6 +36,10 @@ module.exports = {
|
||||
return;
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel(interaction, queue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const loopModesFormatted = new Map([
|
||||
[0, 'disabled'],
|
||||
[1, 'track'],
|
||||
|
||||
@@ -0,0 +1,212 @@
|
||||
const logger = require('../../services/logger');
|
||||
const { embedOptions } = require('../../config');
|
||||
const { notInVoiceChannel, notInSameVoiceChannel } = require('../../utils/validation/voiceChannelValidator');
|
||||
const { queueDoesNotExist, queueNoCurrentTrack } = require('../../utils/validation/queueValidator');
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
||||
const { useMainPlayer, useQueue, QueryType } = require('discord-player');
|
||||
const { lyricsExtractor } = require('@discord-player/extractor');
|
||||
|
||||
module.exports = {
|
||||
isNew: true,
|
||||
isBeta: false,
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('lyrics')
|
||||
.setDescription('Get lyrics from Genius for current or specified track.')
|
||||
.setDMPermission(false)
|
||||
.setNSFW(false)
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
.setName('query')
|
||||
.setDescription('Search query or URL.')
|
||||
.setRequired(false)
|
||||
.setMinLength(2)
|
||||
.setMaxLength(500)
|
||||
.setAutocomplete(true)
|
||||
),
|
||||
autocomplete: async ({ interaction }) => {
|
||||
const query = interaction.options.getString('query', true);
|
||||
if (query.length < 2) {
|
||||
return;
|
||||
}
|
||||
const genius = lyricsExtractor();
|
||||
const lyricsResult = await genius.search(query).catch(() => null);
|
||||
|
||||
let response = [];
|
||||
|
||||
if (!lyricsResult) {
|
||||
const player = useMainPlayer();
|
||||
const searchResults = await player.search(query);
|
||||
response = searchResults.tracks.slice(0, 1).map((track) => ({
|
||||
name:
|
||||
`${track.title} [Artist: ${track.author}]`.length > 100
|
||||
? `${track.title}`.slice(0, 100)
|
||||
: `${track.title} [Author: ${track.author}]`,
|
||||
value: track.title
|
||||
}));
|
||||
} else {
|
||||
response = [
|
||||
{
|
||||
name: `${lyricsResult.title} [Artist: ${lyricsResult.artist.name}]`,
|
||||
value: lyricsResult.title
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
if (!response || response.length === 0) {
|
||||
return interaction.respond([]);
|
||||
}
|
||||
|
||||
logger.debug(`[Shard ${interaction.guild.shardId}] Autocomplete search responded for query: ${query}`);
|
||||
return interaction.respond(response);
|
||||
},
|
||||
execute: async ({ interaction }) => {
|
||||
const query = interaction.options.getString('query');
|
||||
const queue = useQueue(interaction.guild.id);
|
||||
let geniusSearchQuery = '';
|
||||
|
||||
if (!query) {
|
||||
if (await notInVoiceChannel(interaction)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (await queueDoesNotExist(interaction, queue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel(interaction, queue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (await queueNoCurrentTrack(interaction, queue)) {
|
||||
return;
|
||||
}
|
||||
geniusSearchQuery = queue.currentTrack.title.slice(0, 50);
|
||||
}
|
||||
|
||||
let searchResult;
|
||||
if (query) {
|
||||
const player = useMainPlayer();
|
||||
const searchResults = await player.search(query, {
|
||||
searchEngine: QueryType.SPOTIFY_SEARCH
|
||||
});
|
||||
|
||||
if (searchResults.tracks.length === 0) {
|
||||
logger.debug(
|
||||
`[Shard ${interaction.guild.shardId}] User used command ${interaction.commandName} but there was no search results found.`
|
||||
);
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${embedOptions.icons.warning} No search results found**\nThere was no search results found for query **${query}**.`
|
||||
)
|
||||
.setColor(embedOptions.colors.warning)
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
searchResult = searchResults.tracks[0];
|
||||
geniusSearchQuery = searchResults.tracks[0].title;
|
||||
logger.debug(`Using query for genius: ${geniusSearchQuery}`);
|
||||
}
|
||||
|
||||
// get lyrics
|
||||
const genius = lyricsExtractor();
|
||||
let lyricsResult = await genius.search(geniusSearchQuery).catch(() => null);
|
||||
|
||||
// try again with shorter query (some titles just have added info in the end)
|
||||
if (!lyricsResult && geniusSearchQuery.length > 20) {
|
||||
lyricsResult = await genius.search(geniusSearchQuery.slice(0, 20)).catch(() => null);
|
||||
}
|
||||
if (!lyricsResult && geniusSearchQuery.length > 10) {
|
||||
lyricsResult = await genius.search(geniusSearchQuery.slice(0, 10)).catch(() => null);
|
||||
}
|
||||
|
||||
// Check if authors in track from searchResult includes the artist name from genius
|
||||
if (searchResult && lyricsResult) {
|
||||
const searchResultAuthorIncludesArtist = searchResult.author
|
||||
.toLowerCase()
|
||||
.includes(lyricsResult.artist.name.toLowerCase());
|
||||
const lyricsResultArtistIncludesAuthor = lyricsResult.artist.name
|
||||
.toLowerCase()
|
||||
.includes(searchResult.author.toLowerCase());
|
||||
const searchResultAuthorSplitIncludesArtist = lyricsResult.artist.name
|
||||
.toLowerCase()
|
||||
.includes(searchResult.author.split(', ')[0].toLowerCase());
|
||||
|
||||
if (
|
||||
!searchResultAuthorIncludesArtist &&
|
||||
!lyricsResultArtistIncludesAuthor &&
|
||||
!searchResultAuthorSplitIncludesArtist
|
||||
) {
|
||||
lyricsResult = null;
|
||||
logger.debug('Found lyrics but artist name did not match from player result.');
|
||||
}
|
||||
}
|
||||
|
||||
if (!lyricsResult || !lyricsResult.lyrics) {
|
||||
logger.debug(
|
||||
`[Shard ${interaction.guild.shardId}] User used command ${interaction.commandName} but there was no lyrics found.`
|
||||
);
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${embedOptions.icons.warning} No lyrics found**\nThere was no Genius lyrics found for track **${geniusSearchQuery}**.`
|
||||
)
|
||||
.setColor(embedOptions.colors.warning)
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
// If message length is too long, split into multiple messages
|
||||
if (lyricsResult.lyrics.length > 3800) {
|
||||
const messageCount = Math.ceil(lyricsResult.lyrics.length / 3800);
|
||||
for (let i = 0; i < messageCount; i++) {
|
||||
const message = lyricsResult.lyrics.slice(i * 3800, (i + 1) * 3800);
|
||||
if (i === 0) {
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${embedOptions.icons.queue} Showing lyrics**\n` +
|
||||
`**Track: [${lyricsResult.title}](${lyricsResult.url})**\n` +
|
||||
`**Artist: [${lyricsResult.artist.name}](${lyricsResult.artist.url})**` +
|
||||
`\n\n\`\`\`fix\n${message}\`\`\``
|
||||
)
|
||||
.setColor(embedOptions.colors.info)
|
||||
]
|
||||
});
|
||||
continue;
|
||||
} else {
|
||||
await interaction.channel.send({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(`\`\`\`fix\n${message}\`\`\``)
|
||||
.setColor(embedOptions.colors.info)
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
logger.debug(
|
||||
`[Shard ${interaction.guild.shardId}] User used command ${interaction.commandName} and retrieved lyrics.`
|
||||
);
|
||||
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${embedOptions.icons.queue} Showing lyrics**\n` +
|
||||
`**Track: [${lyricsResult.title}](${lyricsResult.url})**\n` +
|
||||
`**Artist: [${lyricsResult.artist.name}](${lyricsResult.artist.url})**` +
|
||||
`\n\n\`\`\`fix\n${lyricsResult.lyrics.slice(0, 3096)}\`\`\``
|
||||
)
|
||||
.setColor(embedOptions.colors.info)
|
||||
]
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
const logger = require('../../services/logger');
|
||||
const { embedOptions, playerOptions } = require('../../config');
|
||||
const { notInVoiceChannel } = require('../../utils/validation/voiceChannelValidator');
|
||||
const { notInVoiceChannel, notInSameVoiceChannel } = require('../../utils/validation/voiceChannelValidator');
|
||||
const { queueDoesNotExist, queueNoCurrentTrack } = require('../../utils/validation/queueValidator');
|
||||
const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, ButtonBuilder } = require('discord.js');
|
||||
const { useQueue } = require('discord-player');
|
||||
@@ -24,6 +24,10 @@ module.exports = {
|
||||
return;
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel(interaction, queue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (await queueNoCurrentTrack(interaction, queue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const logger = require('../../services/logger');
|
||||
const { embedOptions } = require('../../config');
|
||||
const { notInVoiceChannel } = require('../../utils/validation/voiceChannelValidator');
|
||||
const { notInVoiceChannel, notInSameVoiceChannel } = require('../../utils/validation/voiceChannelValidator');
|
||||
const { queueDoesNotExist, queueNoCurrentTrack } = require('../../utils/validation/queueValidator');
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
||||
const { useQueue } = require('discord-player');
|
||||
@@ -24,6 +24,10 @@ module.exports = {
|
||||
return;
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel(interaction, queue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (await queueNoCurrentTrack(interaction, queue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const logger = require('../../services/logger');
|
||||
const { embedOptions, playerOptions, botOptions } = require('../../config');
|
||||
const { notInVoiceChannel } = require('../../utils/validation/voiceChannelValidator');
|
||||
const { notInVoiceChannel, notInSameVoiceChannel } = require('../../utils/validation/voiceChannelValidator');
|
||||
const { cannotJoinVoiceOrTalk } = require('../../utils/validation/permissionValidator');
|
||||
const { transformQuery } = require('../../utils/validation/searchQueryValidator');
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
||||
@@ -30,10 +30,11 @@ module.exports = {
|
||||
return;
|
||||
}
|
||||
const searchResults = await player.search(query);
|
||||
let response = [];
|
||||
|
||||
logger.debug(`[Shard ${interaction.guild.shardId}] Autocomplete search responded for query: ${query}`);
|
||||
|
||||
let response = searchResults.tracks.slice(0, 5).map((track) => ({
|
||||
response = searchResults.tracks.slice(0, 5).map((track) => ({
|
||||
name:
|
||||
`${track.title} [Author: ${track.author}]`.length > 100
|
||||
? `${track.title}`.slice(0, 100)
|
||||
@@ -41,10 +42,14 @@ module.exports = {
|
||||
value: track.url
|
||||
}));
|
||||
|
||||
if (!response || response.length === 0) {
|
||||
return interaction.respond([]);
|
||||
}
|
||||
|
||||
return interaction.respond(response);
|
||||
},
|
||||
execute: async ({ interaction }) => {
|
||||
if (await notInVoiceChannel(interaction)) {
|
||||
execute: async ({ interaction, client }) => {
|
||||
if (await notInVoiceChannel(interaction, client)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -52,6 +57,11 @@ module.exports = {
|
||||
return;
|
||||
}
|
||||
|
||||
let queue = useQueue(interaction.guild.id);
|
||||
if (queue && (await notInSameVoiceChannel(interaction, queue))) {
|
||||
return;
|
||||
}
|
||||
|
||||
const player = useMainPlayer();
|
||||
const query = interaction.options.getString('query');
|
||||
|
||||
@@ -102,7 +112,7 @@ module.exports = {
|
||||
});
|
||||
}
|
||||
|
||||
let queue = useQueue(interaction.guild.id);
|
||||
queue = useQueue(interaction.guild.id);
|
||||
let queueSize = queue?.size ?? 0;
|
||||
|
||||
if ((searchResult.playlist && searchResult.tracks.length) > playerOptions.maxQueueSize - queueSize) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const logger = require('../../services/logger');
|
||||
const { embedOptions, playerOptions } = require('../../config');
|
||||
const { notInVoiceChannel } = require('../../utils/validation/voiceChannelValidator');
|
||||
const { notInVoiceChannel, notInSameVoiceChannel } = require('../../utils/validation/voiceChannelValidator');
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
||||
const { useQueue } = require('discord-player');
|
||||
|
||||
@@ -19,6 +19,11 @@ module.exports = {
|
||||
}
|
||||
|
||||
const queue = useQueue(interaction.guild.id);
|
||||
|
||||
if (await notInSameVoiceChannel(interaction, queue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const pageIndex = (interaction.options.getNumber('page') || 1) - 1;
|
||||
let queueString = '';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const logger = require('../../services/logger');
|
||||
const { embedOptions } = require('../../config');
|
||||
const { notInVoiceChannel } = require('../../utils/validation/voiceChannelValidator');
|
||||
const { notInVoiceChannel, notInSameVoiceChannel } = require('../../utils/validation/voiceChannelValidator');
|
||||
const { queueDoesNotExist } = require('../../utils/validation/queueValidator');
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
||||
const { useQueue } = require('discord-player');
|
||||
@@ -31,6 +31,10 @@ module.exports = {
|
||||
return;
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel(interaction, queue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const removeTrackNumber = interaction.options.getNumber('tracknumber');
|
||||
|
||||
if (removeTrackNumber > queue.tracks.data.length) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const logger = require('../../services/logger');
|
||||
const { embedOptions } = require('../../config');
|
||||
const { notInVoiceChannel } = require('../../utils/validation/voiceChannelValidator');
|
||||
const { notInVoiceChannel, notInSameVoiceChannel } = require('../../utils/validation/voiceChannelValidator');
|
||||
const { queueDoesNotExist, queueNoCurrentTrack } = require('../../utils/validation/queueValidator');
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
||||
const { useQueue } = require('discord-player');
|
||||
@@ -30,6 +30,10 @@ module.exports = {
|
||||
return;
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel(interaction, queue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (await queueNoCurrentTrack(interaction, queue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const logger = require('../../services/logger');
|
||||
const { embedOptions } = require('../../config');
|
||||
const { notInVoiceChannel } = require('../../utils/validation/voiceChannelValidator');
|
||||
const { notInVoiceChannel, notInSameVoiceChannel } = require('../../utils/validation/voiceChannelValidator');
|
||||
const { queueDoesNotExist, queueIsEmpty } = require('../../utils/validation/queueValidator');
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
||||
const { useQueue } = require('discord-player');
|
||||
@@ -24,6 +24,10 @@ module.exports = {
|
||||
return;
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel(interaction, queue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (await queueIsEmpty(interaction, queue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const logger = require('../../services/logger');
|
||||
const { embedOptions } = require('../../config');
|
||||
const { notInVoiceChannel } = require('../../utils/validation/voiceChannelValidator');
|
||||
const { notInVoiceChannel, notInSameVoiceChannel } = require('../../utils/validation/voiceChannelValidator');
|
||||
const { queueDoesNotExist, queueNoCurrentTrack } = require('../../utils/validation/queueValidator');
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
||||
const { useQueue } = require('discord-player');
|
||||
@@ -27,6 +27,10 @@ module.exports = {
|
||||
return;
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel(interaction, queue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (await queueNoCurrentTrack(interaction, queue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
const logger = require('../../services/logger');
|
||||
const { embedOptions } = require('../../config');
|
||||
const { notInVoiceChannel } = require('../../utils/validation/voiceChannelValidator');
|
||||
const { notInVoiceChannel, notInSameVoiceChannel } = require('../../utils/validation/voiceChannelValidator');
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
||||
const { useQueue } = require('discord-player');
|
||||
|
||||
module.exports = {
|
||||
isNew: true,
|
||||
isNew: false,
|
||||
isBeta: false,
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('stop')
|
||||
@@ -34,6 +34,10 @@ module.exports = {
|
||||
});
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel(interaction, queue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!queue.deleted) {
|
||||
queue.setRepeatMode(0);
|
||||
queue.clear();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const logger = require('../../services/logger');
|
||||
const { embedOptions } = require('../../config');
|
||||
const { notInVoiceChannel } = require('../../utils/validation/voiceChannelValidator');
|
||||
const { notInVoiceChannel, notInSameVoiceChannel } = require('../../utils/validation/voiceChannelValidator');
|
||||
const { queueDoesNotExist } = require('../../utils/validation/queueValidator');
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
||||
const { useQueue } = require('discord-player');
|
||||
@@ -31,6 +31,10 @@ module.exports = {
|
||||
return;
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel(interaction, queue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const volume = interaction.options.getNumber('percentage');
|
||||
|
||||
if (!volume && volume !== 0) {
|
||||
|
||||
@@ -8,7 +8,7 @@ exports.notInVoiceChannel = async (interaction) => {
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${embedOptions.icons.warning} Oops!**\nYou need to be in a voice channel to use this command.`
|
||||
`**${embedOptions.icons.warning} Not in a voice channel**\nYou need to be in a voice channel to use this command.`
|
||||
)
|
||||
.setColor(embedOptions.colors.warning)
|
||||
]
|
||||
@@ -20,3 +20,26 @@ exports.notInVoiceChannel = async (interaction) => {
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
exports.notInSameVoiceChannel = async (interaction, queue) => {
|
||||
if (!queue.dispatcher) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (interaction.member.voice.channel.id !== queue.dispatcher.channel.id) {
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${embedOptions.icons.warning} Not in same voice channel**\nYou need to be in the same voice channel as me to use this command.\n\n**Voice channel:** ${queue.dispatcher.channel.name}`
|
||||
)
|
||||
.setColor(embedOptions.colors.warning)
|
||||
]
|
||||
});
|
||||
|
||||
logger.debug(`User tried to use command ${interaction.commandName} but was not in the same voice channel.`);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
Reference in new issue
Block a user