mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-04 14:38:49 +00:00
Merge pull request #192 from mariusbegby/small-improvements
Small improvements
This commit is contained in:
32 files changed
+318
-331
No files matched your search
@@ -24,7 +24,7 @@ export const handleCommand = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (await cannotSendMessageInChannel({ interaction, executionId })) {
|
if (await cannotSendMessageInChannel({ interaction, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug('Executing command interaction.');
|
logger.debug('Executing command interaction.');
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { MessageComponentInteraction } from 'discord.js';
|
import { MessageComponentInteraction } from 'discord.js';
|
||||||
import loggerModule from '../services/logger';
|
import loggerModule from '../services/logger';
|
||||||
|
import { cannotSendMessageInChannel } from '../utils/validation/permissionValidator';
|
||||||
|
|
||||||
const logger = loggerModule.child({
|
const logger = loggerModule.child({
|
||||||
source: 'interactionComponentHandler.js',
|
source: 'interactionComponentHandler.js',
|
||||||
@@ -16,6 +17,10 @@ export const handleComponent = async (interaction: MessageComponentInteraction,
|
|||||||
|
|
||||||
logger.debug(`Parsed componentId: ${componentId}`);
|
logger.debug(`Parsed componentId: ${componentId}`);
|
||||||
|
|
||||||
|
if (await cannotSendMessageInChannel({ interaction, executionId })) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const componentModule = await import(`../interactions/components/${componentId}.js`);
|
const componentModule = await import(`../interactions/components/${componentId}.js`);
|
||||||
const { default: component } = componentModule;
|
const { default: component } = componentModule;
|
||||||
|
|
||||||
|
|||||||
@@ -39,37 +39,28 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
let totalTracks: number = 0;
|
let totalTracks: number = 0;
|
||||||
let totalListeners: number = 0;
|
let totalListeners: number = 0;
|
||||||
|
|
||||||
await client!.shard!
|
await client!
|
||||||
.broadcastEval(() => {
|
.shard!.broadcastEval(() => {
|
||||||
/* eslint-disable no-undef */
|
/* eslint-disable no-undef */
|
||||||
return player.generateStatistics();
|
return player.generateStatistics();
|
||||||
})
|
})
|
||||||
.then((results) => {
|
.then((results) => {
|
||||||
const queueCountList: number[] = [];
|
|
||||||
const trackCountList: number[] = [];
|
|
||||||
const listenerCountList: number[] = [];
|
|
||||||
results.map((result) => {
|
results.map((result) => {
|
||||||
queueCountList.push(result.queues.length);
|
activeVoiceConnections += result.queues.length;
|
||||||
if (result.queues.length > 0) {
|
result.queues.map((queue) => {
|
||||||
result.queues.map((queue) => {
|
totalTracks += queue.status.playing ? queue.tracksCount + 1 : queue.tracksCount;
|
||||||
trackCountList.push(queue.status.playing ? queue.tracksCount + 1 : queue.tracksCount);
|
totalListeners += queue.listeners;
|
||||||
listenerCountList.push(queue.listeners);
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
activeVoiceConnections = queueCountList.reduce((acc, queueAmount) => acc + queueAmount, 0);
|
|
||||||
totalTracks = trackCountList.reduce((acc, trackAmount) => acc + trackAmount, 0);
|
|
||||||
totalListeners = listenerCountList.reduce((acc, listenerAmount) => acc + listenerAmount, 0);
|
|
||||||
|
|
||||||
logger.debug('Successfully fetched player statistics from shards.');
|
logger.debug('Successfully fetched player statistics from shards.');
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
logger.error(error, 'Failed to fetch player statistics from shards.');
|
logger.error(error, 'Failed to fetch player statistics from shards.');
|
||||||
});
|
});
|
||||||
|
|
||||||
await client!.shard!
|
await client!
|
||||||
.fetchClientValues('guilds.cache')
|
.shard!.fetchClientValues('guilds.cache')
|
||||||
.then((results) => {
|
.then((results) => {
|
||||||
const guildCaches = results as Guild[][];
|
const guildCaches = results as Guild[][];
|
||||||
guildCaches.map((guildCache: Guild[]) => {
|
guildCaches.map((guildCache: Guild[]) => {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { NodeResolvable, QueueFilters, useQueue } from 'discord-player';
|
import { GuildQueue, QueueFilters, useQueue } from 'discord-player';
|
||||||
import {
|
import {
|
||||||
APIActionRowComponent,
|
APIActionRowComponent,
|
||||||
APIMessageActionRowComponent,
|
APIMessageActionRowComponent,
|
||||||
@@ -39,22 +39,19 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
guildId: interaction.guild?.id
|
guildId: interaction.guild?.id
|
||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const validators = [
|
||||||
|
() => notInVoiceChannel({ interaction, executionId }),
|
||||||
|
() => notInSameVoiceChannel({ interaction, queue, executionId }),
|
||||||
|
() => queueDoesNotExist({ interaction, queue, executionId }),
|
||||||
|
() => queueNoCurrentTrack({ interaction, queue, executionId })
|
||||||
|
];
|
||||||
|
|
||||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
for (const validator of validators) {
|
||||||
return Promise.resolve();
|
if (await validator()) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const filterOptions: StringSelectMenuOptionBuilder[] = [];
|
const filterOptions: StringSelectMenuOptionBuilder[] = [];
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { NodeResolvable, useQueue } from 'discord-player';
|
import { GuildQueue, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
||||||
|
|
||||||
import loggerModule from '../../../services/logger';
|
import loggerModule from '../../../services/logger';
|
||||||
import { CustomSlashCommandInteraction } from '../../../types/interactionTypes';
|
import { CustomSlashCommandInteraction } from '../../../types/interactionTypes';
|
||||||
import { EmbedOptions } from '../../../types/configTypes';
|
import { EmbedOptions } from '../../../types/configTypes';
|
||||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||||
|
import { queueDoesNotExist } from '../../../utils/validation/queueValidator';
|
||||||
|
|
||||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||||
|
|
||||||
@@ -27,29 +28,18 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
guildId: interaction.guild?.id
|
guildId: interaction.guild?.id
|
||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const validators = [
|
||||||
|
() => notInVoiceChannel({ interaction, executionId }),
|
||||||
|
() => notInSameVoiceChannel({ interaction, queue, executionId }),
|
||||||
|
() => queueDoesNotExist({ interaction, queue, executionId })
|
||||||
|
];
|
||||||
|
|
||||||
if (!queue) {
|
for (const validator of validators) {
|
||||||
logger.debug('There is already no queue.');
|
if (await validator()) {
|
||||||
|
return;
|
||||||
logger.debug('Responding with warning embed.');
|
}
|
||||||
return await interaction.editReply({
|
|
||||||
embeds: [
|
|
||||||
new EmbedBuilder()
|
|
||||||
.setDescription(
|
|
||||||
`**${embedOptions.icons.warning} Oops!**\n_Hmm.._ It seems I am not in a voice channel!`
|
|
||||||
)
|
|
||||||
.setColor(embedOptions.colors.warning)
|
|
||||||
]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!queue.deleted) {
|
if (!queue.deleted) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { NodeResolvable, useQueue } from 'discord-player';
|
import { GuildQueue, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder, SlashCommandStringOption } from 'discord.js';
|
import { EmbedBuilder, GuildMember, SlashCommandBuilder, SlashCommandStringOption } from 'discord.js';
|
||||||
|
|
||||||
import loggerModule from '../../../services/logger';
|
import loggerModule from '../../../services/logger';
|
||||||
@@ -41,18 +41,18 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
guildId: interaction.guild?.id
|
guildId: interaction.guild?.id
|
||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const validators = [
|
||||||
|
() => notInVoiceChannel({ interaction, executionId }),
|
||||||
|
() => notInSameVoiceChannel({ interaction, queue, executionId }),
|
||||||
|
() => queueDoesNotExist({ interaction, queue, executionId })
|
||||||
|
];
|
||||||
|
|
||||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
for (const validator of validators) {
|
||||||
return Promise.resolve();
|
if (await validator()) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const loopModesFormatted = new Map([
|
const loopModesFormatted = new Map([
|
||||||
@@ -132,6 +132,7 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
if (queue.repeatMode === 0) {
|
if (queue.repeatMode === 0) {
|
||||||
logger.debug('Disabled loop mode.');
|
logger.debug('Disabled loop mode.');
|
||||||
|
|
||||||
|
// TODO: Different text when disabling autoplay.
|
||||||
logger.debug('Responding with success embed.');
|
logger.debug('Responding with success embed.');
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { NodeResolvable, QueryType, useMainPlayer, useQueue } from 'discord-player';
|
import { GuildQueue, QueryType, useMainPlayer, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||||
|
|
||||||
import { lyricsExtractor } from '@discord-player/extractor';
|
import { lyricsExtractor } from '@discord-player/extractor';
|
||||||
@@ -43,25 +43,23 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const query = interaction.options.getString('query');
|
const query = interaction.options.getString('query');
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
let geniusSearchQuery = '';
|
let geniusSearchQuery = '';
|
||||||
|
|
||||||
if (!query) {
|
if (!query) {
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
const validators = [
|
||||||
return Promise.resolve();
|
() => notInVoiceChannel({ interaction, executionId }),
|
||||||
|
() => notInSameVoiceChannel({ interaction, queue, executionId }),
|
||||||
|
() => queueDoesNotExist({ interaction, queue, executionId }),
|
||||||
|
() => queueNoCurrentTrack({ interaction, queue, executionId })
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const validator of validators) {
|
||||||
|
if (await validator()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
geniusSearchQuery = queue.currentTrack!.title.slice(0, 50);
|
geniusSearchQuery = queue.currentTrack!.title.slice(0, 50);
|
||||||
|
|
||||||
logger.debug(
|
logger.debug(
|
||||||
@@ -188,7 +186,7 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug('Responding with info embed.');
|
logger.debug('Responding with info embed.');
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { NodeResolvable, Track, useQueue } from 'discord-player';
|
import { GuildQueue, Track, useQueue } from 'discord-player';
|
||||||
import {
|
import {
|
||||||
APIActionRowComponent,
|
APIActionRowComponent,
|
||||||
APIMessageActionRowComponent,
|
APIMessageActionRowComponent,
|
||||||
@@ -37,22 +37,19 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
guildId: interaction.guild?.id
|
guildId: interaction.guild?.id
|
||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const validators = [
|
||||||
|
() => notInVoiceChannel({ interaction, executionId }),
|
||||||
|
() => notInSameVoiceChannel({ interaction, queue, executionId }),
|
||||||
|
() => queueDoesNotExist({ interaction, queue, executionId }),
|
||||||
|
() => queueNoCurrentTrack({ interaction, queue, executionId })
|
||||||
|
];
|
||||||
|
|
||||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
for (const validator of validators) {
|
||||||
return Promise.resolve();
|
if (await validator()) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const sourceStringsFormatted = new Map([
|
const sourceStringsFormatted = new Map([
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { NodeResolvable, useQueue } from 'discord-player';
|
import { GuildQueue, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
||||||
|
|
||||||
import loggerModule from '../../../services/logger';
|
import loggerModule from '../../../services/logger';
|
||||||
@@ -28,22 +28,19 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
guildId: interaction.guild?.id
|
guildId: interaction.guild?.id
|
||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const validators = [
|
||||||
|
() => notInVoiceChannel({ interaction, executionId }),
|
||||||
|
() => notInSameVoiceChannel({ interaction, queue, executionId }),
|
||||||
|
() => queueDoesNotExist({ interaction, queue, executionId }),
|
||||||
|
() => queueNoCurrentTrack({ interaction, queue, executionId })
|
||||||
|
];
|
||||||
|
|
||||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
for (const validator of validators) {
|
||||||
return Promise.resolve();
|
if (await validator()) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentTrack = queue.currentTrack!;
|
const currentTrack = queue.currentTrack!;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { useMainPlayer, useQueue } from 'discord-player';
|
import { GuildQueue, useMainPlayer, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
||||||
|
|
||||||
import loggerModule from '../../../services/logger';
|
import loggerModule from '../../../services/logger';
|
||||||
@@ -43,17 +43,20 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
guildId: interaction.guild?.id
|
guildId: interaction.guild?.id
|
||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
let queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (await cannotJoinVoiceOrTalk({ interaction, executionId })) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
let queue = useQueue(interaction.guild!.id);
|
|
||||||
if (queue && (await notInSameVoiceChannel({ interaction, queue, executionId }))) {
|
if (queue && (await notInSameVoiceChannel({ interaction, queue, executionId }))) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const validators = [
|
||||||
|
() => notInVoiceChannel({ interaction, executionId }),
|
||||||
|
() => cannotJoinVoiceOrTalk({ interaction, executionId })
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const validator of validators) {
|
||||||
|
if (await validator()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const player = useMainPlayer()!;
|
const player = useMainPlayer()!;
|
||||||
@@ -86,7 +89,7 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
queue = useQueue(interaction.guild!.id);
|
queue = useQueue(interaction.guild!.id)!;
|
||||||
const queueSize = queue?.size ?? 0;
|
const queueSize = queue?.size ?? 0;
|
||||||
|
|
||||||
if ((searchResult.playlist! && searchResult.tracks.length) > playerOptions.maxQueueSize - queueSize) {
|
if ((searchResult.playlist! && searchResult.tracks.length) > playerOptions.maxQueueSize - queueSize) {
|
||||||
@@ -211,7 +214,7 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
|
|
||||||
logger.debug(`Successfully added track with player.play(). Query: '${query}'.`);
|
logger.debug(`Successfully added track with player.play(). Query: '${query}'.`);
|
||||||
|
|
||||||
queue = useQueue(interaction.guild!.id);
|
queue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
if (!queue || !track) {
|
if (!queue || !track) {
|
||||||
logger.warn(`After player.play(), queue is undefined. Query: '${query}'.`);
|
logger.warn(`After player.play(), queue is undefined. Query: '${query}'.`);
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { NodeResolvable, useQueue } from 'discord-player';
|
import { GuildQueue, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||||
|
|
||||||
import loggerModule from '../../../services/logger';
|
import loggerModule from '../../../services/logger';
|
||||||
import { CustomSlashCommandInteraction } from '../../../types/interactionTypes';
|
import { CustomSlashCommandInteraction } from '../../../types/interactionTypes';
|
||||||
import { EmbedOptions, PlayerOptions } from '../../../types/configTypes';
|
import { EmbedOptions, PlayerOptions } from '../../../types/configTypes';
|
||||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||||
|
import { queueDoesNotExist } from '../../../utils/validation/queueValidator';
|
||||||
|
|
||||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||||
const playerOptions: PlayerOptions = config.get('playerOptions');
|
const playerOptions: PlayerOptions = config.get('playerOptions');
|
||||||
@@ -29,57 +30,23 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
guildId: interaction.guild?.id
|
guildId: interaction.guild?.id
|
||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const validators = [
|
||||||
|
() => notInVoiceChannel({ interaction, executionId }),
|
||||||
|
() => notInSameVoiceChannel({ interaction, queue, executionId }),
|
||||||
|
() => queueDoesNotExist({ interaction, queue, executionId })
|
||||||
|
];
|
||||||
|
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
for (const validator of validators) {
|
||||||
return Promise.resolve();
|
if (await validator()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const pageIndex = (interaction.options.getNumber('page') || 1) - 1;
|
const pageIndex = (interaction.options.getNumber('page') || 1) - 1;
|
||||||
let queueString = '';
|
let queueString = '';
|
||||||
|
|
||||||
if (!queue) {
|
|
||||||
if (pageIndex >= 1) {
|
|
||||||
logger.debug(`There is no queue and user tried to access page ${pageIndex + 1}.`);
|
|
||||||
|
|
||||||
logger.debug('Responding with warning embed.');
|
|
||||||
return await interaction.editReply({
|
|
||||||
embeds: [
|
|
||||||
new EmbedBuilder()
|
|
||||||
.setDescription(
|
|
||||||
`**${embedOptions.icons.warning} Oops!**\nPage **\`${
|
|
||||||
pageIndex + 1
|
|
||||||
}\`** is not a valid page number.\n\nThe queue is currently empty, first add some tracks with **\`/play\`**!`
|
|
||||||
)
|
|
||||||
.setColor(embedOptions.colors.warning)
|
|
||||||
]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug('There is no queue, displaying empty queue.');
|
|
||||||
queueString = 'The queue is empty, add some tracks with **`/play`**!';
|
|
||||||
|
|
||||||
logger.debug('Responding with info embed.');
|
|
||||||
return await interaction.editReply({
|
|
||||||
embeds: [
|
|
||||||
new EmbedBuilder()
|
|
||||||
.setAuthor({
|
|
||||||
name: interaction.guild!.name,
|
|
||||||
iconURL: interaction.guild!.iconURL() || ''
|
|
||||||
})
|
|
||||||
.setDescription(`**${embedOptions.icons.queue} Tracks in queue**\n${queueString}`)
|
|
||||||
.setColor(embedOptions.colors.info)
|
|
||||||
.setFooter({
|
|
||||||
text: 'Page 1 of 1 (0 tracks)'
|
|
||||||
})
|
|
||||||
]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const queueLength = queue.tracks.data.length;
|
const queueLength = queue.tracks.data.length;
|
||||||
const totalPages = Math.ceil(queueLength / 10) || 1;
|
const totalPages = Math.ceil(queueLength / 10) || 1;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { NodeResolvable, useQueue } from 'discord-player';
|
import { GuildQueue, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
||||||
|
|
||||||
import loggerModule from '../../../services/logger';
|
import loggerModule from '../../../services/logger';
|
||||||
@@ -35,18 +35,18 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
guildId: interaction.guild?.id
|
guildId: interaction.guild?.id
|
||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const validators = [
|
||||||
|
() => notInVoiceChannel({ interaction, executionId }),
|
||||||
|
() => queueDoesNotExist({ interaction, queue, executionId }),
|
||||||
|
() => notInSameVoiceChannel({ interaction, queue, executionId })
|
||||||
|
];
|
||||||
|
|
||||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
for (const validator of validators) {
|
||||||
return Promise.resolve();
|
if (await validator()) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const removeTrackNumber = interaction.options.getNumber('tracknumber')!;
|
const removeTrackNumber = interaction.options.getNumber('tracknumber')!;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { NodeResolvable, useQueue } from 'discord-player';
|
import { GuildQueue, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
||||||
|
|
||||||
import loggerModule from '../../../services/logger';
|
import loggerModule from '../../../services/logger';
|
||||||
@@ -34,22 +34,19 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
guildId: interaction.guild?.id
|
guildId: interaction.guild?.id
|
||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const validators = [
|
||||||
|
() => notInVoiceChannel({ interaction, executionId }),
|
||||||
|
() => notInSameVoiceChannel({ interaction, queue, executionId }),
|
||||||
|
() => queueDoesNotExist({ interaction, queue, executionId }),
|
||||||
|
() => queueNoCurrentTrack({ interaction, queue, executionId })
|
||||||
|
];
|
||||||
|
|
||||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
for (const validator of validators) {
|
||||||
return Promise.resolve();
|
if (await validator()) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const durationInput = interaction.options.getString('duration');
|
const durationInput = interaction.options.getString('duration');
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { NodeResolvable, useQueue } from 'discord-player';
|
import { GuildQueue, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
||||||
|
|
||||||
import loggerModule from '../../../services/logger';
|
import loggerModule from '../../../services/logger';
|
||||||
@@ -28,22 +28,19 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
guildId: interaction.guild?.id
|
guildId: interaction.guild?.id
|
||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const validators = [
|
||||||
|
() => notInVoiceChannel({ interaction, executionId }),
|
||||||
|
() => notInSameVoiceChannel({ interaction, queue, executionId }),
|
||||||
|
() => queueDoesNotExist({ interaction, queue, executionId }),
|
||||||
|
() => queueIsEmpty({ interaction, queue, executionId })
|
||||||
|
];
|
||||||
|
|
||||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
for (const validator of validators) {
|
||||||
return Promise.resolve();
|
if (await validator()) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (await queueIsEmpty({ interaction, queue, executionId })) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
queue.tracks.shuffle();
|
queue.tracks.shuffle();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { NodeResolvable, useQueue } from 'discord-player';
|
import { GuildQueue, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
||||||
|
|
||||||
import loggerModule from '../../../services/logger';
|
import loggerModule from '../../../services/logger';
|
||||||
@@ -31,22 +31,19 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
guildId: interaction.guild?.id
|
guildId: interaction.guild?.id
|
||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const validators = [
|
||||||
|
() => notInVoiceChannel({ interaction, executionId }),
|
||||||
|
() => notInSameVoiceChannel({ interaction, queue, executionId }),
|
||||||
|
() => queueDoesNotExist({ interaction, queue, executionId }),
|
||||||
|
() => queueNoCurrentTrack({ interaction, queue, executionId })
|
||||||
|
];
|
||||||
|
|
||||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
for (const validator of validators) {
|
||||||
return Promise.resolve();
|
if (await validator()) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const skipToTrack = interaction.options.getNumber('tracknumber');
|
const skipToTrack = interaction.options.getNumber('tracknumber');
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { NodeResolvable, useQueue } from 'discord-player';
|
import { GuildQueue, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
||||||
|
|
||||||
import loggerModule from '../../../services/logger';
|
import loggerModule from '../../../services/logger';
|
||||||
import { CustomSlashCommandInteraction } from '../../../types/interactionTypes';
|
import { CustomSlashCommandInteraction } from '../../../types/interactionTypes';
|
||||||
import { EmbedOptions } from '../../../types/configTypes';
|
import { EmbedOptions } from '../../../types/configTypes';
|
||||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||||
|
import { queueDoesNotExist } from '../../../utils/validation/queueValidator';
|
||||||
|
|
||||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||||
|
|
||||||
@@ -27,29 +28,18 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
guildId: interaction.guild?.id
|
guildId: interaction.guild?.id
|
||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const validators = [
|
||||||
|
() => notInVoiceChannel({ interaction, executionId }),
|
||||||
|
() => notInSameVoiceChannel({ interaction, queue, executionId }),
|
||||||
|
() => queueDoesNotExist({ interaction, queue, executionId })
|
||||||
|
];
|
||||||
|
|
||||||
if (!queue) {
|
for (const validator of validators) {
|
||||||
logger.debug('There is no queue.');
|
if (await validator()) {
|
||||||
|
return;
|
||||||
logger.debug('Responding with warning embed.');
|
}
|
||||||
return await interaction.editReply({
|
|
||||||
embeds: [
|
|
||||||
new EmbedBuilder()
|
|
||||||
.setDescription(
|
|
||||||
`**${embedOptions.icons.warning} Oops!**\n_Hmm.._ It seems I am not in a voice channel!`
|
|
||||||
)
|
|
||||||
.setColor(embedOptions.colors.warning)
|
|
||||||
]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!queue.deleted) {
|
if (!queue.deleted) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { NodeResolvable, useQueue } from 'discord-player';
|
import { GuildQueue, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
||||||
|
|
||||||
import loggerModule from '../../../services/logger';
|
import loggerModule from '../../../services/logger';
|
||||||
@@ -35,18 +35,18 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
guildId: interaction.guild?.id
|
guildId: interaction.guild?.id
|
||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const validators = [
|
||||||
|
() => notInVoiceChannel({ interaction, executionId }),
|
||||||
|
() => notInSameVoiceChannel({ interaction, queue, executionId }),
|
||||||
|
() => queueDoesNotExist({ interaction, queue, executionId })
|
||||||
|
];
|
||||||
|
|
||||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
for (const validator of validators) {
|
||||||
return Promise.resolve();
|
if (await validator()) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const volume = interaction.options.getNumber('percentage');
|
const volume = interaction.options.getNumber('percentage');
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notValidGuildId({ interaction, executionId })) {
|
if (await notValidGuildId({ interaction, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let shardGuilds: Guild[] = [];
|
let shardGuilds: Guild[] = [];
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notValidGuildId({ interaction, executionId })) {
|
if (await notValidGuildId({ interaction, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notValidGuildId({ interaction, executionId })) {
|
if (await notValidGuildId({ interaction, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let shardInfoList: ShardInfo[] = [];
|
let shardInfoList: ShardInfo[] = [];
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notValidGuildId({ interaction, executionId })) {
|
if (await notValidGuildId({ interaction, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// from normal /status command
|
// from normal /status command
|
||||||
@@ -67,24 +67,18 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
return player.generateStatistics();
|
return player.generateStatistics();
|
||||||
})
|
})
|
||||||
.then((results) => {
|
.then((results) => {
|
||||||
const queueCountList: number[] = [];
|
|
||||||
const trackCountList: number[] = [];
|
|
||||||
const listenerCountList: number[] = [];
|
|
||||||
results.map((result) => {
|
results.map((result) => {
|
||||||
queueCountList.push(result.queues.length);
|
activeVoiceConnections += result.queues.length;
|
||||||
if (result.queues.length > 0) {
|
result.queues.map((queue) => {
|
||||||
result.queues.map((queue) => {
|
totalTracks += queue.status.playing ? queue.tracksCount + 1 : queue.tracksCount;
|
||||||
trackCountList.push(queue.status.playing ? queue.tracksCount + 1 : queue.tracksCount);
|
totalListeners += queue.listeners;
|
||||||
listenerCountList.push(queue.listeners);
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
activeVoiceConnections = queueCountList.reduce((acc, queueAmount) => acc + queueAmount, 0);
|
|
||||||
totalTracks = trackCountList.reduce((acc, trackAmount) => acc + trackAmount, 0);
|
|
||||||
totalListeners = listenerCountList.reduce((acc, listenerAmount) => acc + listenerAmount, 0);
|
|
||||||
|
|
||||||
logger.debug('Successfully fetched player statistics from shards.');
|
logger.debug('Successfully fetched player statistics from shards.');
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
logger.error(error, 'Failed to fetch player statistics from shards.');
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.debug('Fetching client values from all shards.');
|
logger.debug('Fetching client values from all shards.');
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ import config from 'config';
|
|||||||
import loggerModule from '../../services/logger';
|
import loggerModule from '../../services/logger';
|
||||||
import { EmbedOptions } from '../../types/configTypes';
|
import { EmbedOptions } from '../../types/configTypes';
|
||||||
import { CustomComponentInteraction } from '../../types/interactionTypes';
|
import { CustomComponentInteraction } from '../../types/interactionTypes';
|
||||||
import { useQueue } from 'discord-player';
|
import { GuildQueue, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, GuildMember } from 'discord.js';
|
import { EmbedBuilder, GuildMember } from 'discord.js';
|
||||||
|
import { notInSameVoiceChannel, notInVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
||||||
|
import { queueDoesNotExist } from '../../utils/validation/queueValidator';
|
||||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||||
|
|
||||||
const component: CustomComponentInteraction = {
|
const component: CustomComponentInteraction = {
|
||||||
@@ -20,7 +22,19 @@ const component: CustomComponentInteraction = {
|
|||||||
|
|
||||||
logger.debug('Received disable confirmation.');
|
logger.debug('Received disable confirmation.');
|
||||||
|
|
||||||
const queue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
|
const validators = [
|
||||||
|
() => notInVoiceChannel({ interaction, executionId }),
|
||||||
|
() => notInSameVoiceChannel({ interaction, queue, executionId }),
|
||||||
|
() => queueDoesNotExist({ interaction, queue, executionId })
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const validator of validators) {
|
||||||
|
if (await validator()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Reset filters before enabling provided filters
|
// Reset filters before enabling provided filters
|
||||||
if (queue.filters.ffmpeg.filters.length > 0) {
|
if (queue.filters.ffmpeg.filters.length > 0) {
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ import config from 'config';
|
|||||||
import loggerModule from '../../services/logger';
|
import loggerModule from '../../services/logger';
|
||||||
import { EmbedOptions, FFmpegFilterOptions } from '../../types/configTypes';
|
import { EmbedOptions, FFmpegFilterOptions } from '../../types/configTypes';
|
||||||
import { CustomComponentInteraction } from '../../types/interactionTypes';
|
import { CustomComponentInteraction } from '../../types/interactionTypes';
|
||||||
import { QueueFilters, useQueue } from 'discord-player';
|
import { GuildQueue, QueueFilters, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, GuildMember, StringSelectMenuInteraction } from 'discord.js';
|
import { EmbedBuilder, GuildMember, StringSelectMenuInteraction } from 'discord.js';
|
||||||
|
import { notInSameVoiceChannel, notInVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
||||||
|
import { queueDoesNotExist } from '../../utils/validation/queueValidator';
|
||||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||||
const ffmpegFilterOptions: FFmpegFilterOptions = config.get('ffmpegFilterOptions');
|
const ffmpegFilterOptions: FFmpegFilterOptions = config.get('ffmpegFilterOptions');
|
||||||
|
|
||||||
@@ -22,7 +24,19 @@ const component: CustomComponentInteraction = {
|
|||||||
logger.debug('Received select menu confirmation.');
|
logger.debug('Received select menu confirmation.');
|
||||||
|
|
||||||
const selectMenuInteraction = interaction as StringSelectMenuInteraction;
|
const selectMenuInteraction = interaction as StringSelectMenuInteraction;
|
||||||
const queue = useQueue(selectMenuInteraction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
|
const validators = [
|
||||||
|
() => notInVoiceChannel({ interaction, executionId }),
|
||||||
|
() => notInSameVoiceChannel({ interaction, queue, executionId }),
|
||||||
|
() => queueDoesNotExist({ interaction, queue, executionId })
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const validator of validators) {
|
||||||
|
if (await validator()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
queue.filters.ffmpeg.setInputArgs([
|
queue.filters.ffmpeg.setInputArgs([
|
||||||
'-threads',
|
'-threads',
|
||||||
@@ -42,10 +56,10 @@ const component: CustomComponentInteraction = {
|
|||||||
logger.debug('Reset queue filters.');
|
logger.debug('Reset queue filters.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// if bassboost is enabled and not normalizer, also enable normalizer to avoid distrorion
|
// if bassboost is enabled and not normalizer, also enable normalizer to avoid distrorion
|
||||||
if (
|
if (
|
||||||
(selectMenuInteraction.values.includes('bassboost_low') || selectMenuInteraction.values.includes('bassboost')) &&
|
(selectMenuInteraction.values.includes('bassboost_low') ||
|
||||||
|
selectMenuInteraction.values.includes('bassboost')) &&
|
||||||
!selectMenuInteraction.values.includes('normalizer')
|
!selectMenuInteraction.values.includes('normalizer')
|
||||||
) {
|
) {
|
||||||
selectMenuInteraction.values.push('normalizer');
|
selectMenuInteraction.values.push('normalizer');
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { NodeResolvable, useQueue } from 'discord-player';
|
import { GuildQueue, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, GuildMember } from 'discord.js';
|
import { EmbedBuilder, GuildMember } from 'discord.js';
|
||||||
|
|
||||||
import loggerModule from '../../services/logger';
|
import loggerModule from '../../services/logger';
|
||||||
import { EmbedOptions } from '../../types/configTypes';
|
import { EmbedOptions } from '../../types/configTypes';
|
||||||
import { CustomComponentInteraction } from '../../types/interactionTypes';
|
import { CustomComponentInteraction } from '../../types/interactionTypes';
|
||||||
|
import { notInSameVoiceChannel, notInVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
||||||
|
import { queueDoesNotExist, queueNoCurrentTrack } from '../../utils/validation/queueValidator';
|
||||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||||
|
|
||||||
const component: CustomComponentInteraction = {
|
const component: CustomComponentInteraction = {
|
||||||
@@ -20,7 +22,20 @@ const component: CustomComponentInteraction = {
|
|||||||
|
|
||||||
logger.debug(`Received skip confirmation for track id ${referenceId}.`);
|
logger.debug(`Received skip confirmation for track id ${referenceId}.`);
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
|
const validators = [
|
||||||
|
() => notInVoiceChannel({ interaction, executionId }),
|
||||||
|
() => notInSameVoiceChannel({ interaction, queue, executionId }),
|
||||||
|
() => queueDoesNotExist({ interaction, queue, executionId }),
|
||||||
|
() => queueNoCurrentTrack({ interaction, queue, executionId })
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const validator of validators) {
|
||||||
|
if (await validator()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!queue || (queue.tracks.data.length === 0 && !queue.currentTrack)) {
|
if (!queue || (queue.tracks.data.length === 0 && !queue.currentTrack)) {
|
||||||
logger.debug('Tried skipping track but there was no queue.');
|
logger.debug('Tried skipping track but there was no queue.');
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { GuildQueue, Player } from 'discord-player';
|
import { GuildQueue, Player } from 'discord-player';
|
||||||
import { ChatInputCommandInteraction } from 'discord.js';
|
import { ChatInputCommandInteraction, MessageComponentInteraction } from 'discord.js';
|
||||||
|
|
||||||
import { ExtendedClient } from './clientTypes';
|
import { ExtendedClient } from './clientTypes';
|
||||||
|
|
||||||
@@ -24,18 +24,18 @@ export interface CustomEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface NotInVoiceChannelParams {
|
export interface NotInVoiceChannelParams {
|
||||||
interaction: ChatInputCommandInteraction;
|
interaction: ChatInputCommandInteraction | MessageComponentInteraction;
|
||||||
executionId: string;
|
executionId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface NotInSameVoiceChannelParams {
|
export interface NotInSameVoiceChannelParams {
|
||||||
interaction: ChatInputCommandInteraction;
|
interaction: ChatInputCommandInteraction | MessageComponentInteraction;
|
||||||
queue: GuildQueue;
|
queue: GuildQueue;
|
||||||
executionId: string;
|
executionId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface NotValidGuildIdParams {
|
export interface NotValidGuildIdParams {
|
||||||
interaction: ChatInputCommandInteraction;
|
interaction: ChatInputCommandInteraction | MessageComponentInteraction;
|
||||||
executionId: string;
|
executionId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,30 +45,30 @@ export interface TransformQueryParams {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface QueueDoesNotExistParams {
|
export interface QueueDoesNotExistParams {
|
||||||
interaction: ChatInputCommandInteraction;
|
interaction: ChatInputCommandInteraction | MessageComponentInteraction;
|
||||||
queue: GuildQueue;
|
queue: GuildQueue;
|
||||||
executionId: string;
|
executionId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface QueueNoCurrentTrackParams {
|
export interface QueueNoCurrentTrackParams {
|
||||||
interaction: ChatInputCommandInteraction;
|
interaction: ChatInputCommandInteraction | MessageComponentInteraction;
|
||||||
queue: GuildQueue;
|
queue: GuildQueue;
|
||||||
executionId: string;
|
executionId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface QueueIsEmptyParams {
|
export interface QueueIsEmptyParams {
|
||||||
interaction: ChatInputCommandInteraction;
|
interaction: ChatInputCommandInteraction | MessageComponentInteraction;
|
||||||
queue: GuildQueue;
|
queue: GuildQueue;
|
||||||
executionId: string;
|
executionId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CannotJoinVoiceOrTalkParams {
|
export interface CannotJoinVoiceOrTalkParams {
|
||||||
interaction: ChatInputCommandInteraction;
|
interaction: ChatInputCommandInteraction | MessageComponentInteraction;
|
||||||
executionId: string;
|
executionId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CannotSendMessageInChannelParams {
|
export interface CannotSendMessageInChannelParams {
|
||||||
interaction: ChatInputCommandInteraction;
|
interaction: ChatInputCommandInteraction | MessageComponentInteraction;
|
||||||
executionId: string;
|
executionId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,22 +20,11 @@ const logger = loggerModule.child({
|
|||||||
executionId: executionId
|
executionId: executionId
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//TODO: Fix deploying not working with require()
|
||||||
|
|
||||||
const slashCommands: SlashCommandBuilder[] = [];
|
const slashCommands: SlashCommandBuilder[] = [];
|
||||||
const systemCommands: SlashCommandBuilder[] = [];
|
const systemCommands: SlashCommandBuilder[] = [];
|
||||||
const commandFolders = fs.readdirSync(path.resolve('./dist/commands'));
|
const commandFolders = fs.readdirSync(path.resolve('./dist/interactions/commands'));
|
||||||
for (const folder of commandFolders) {
|
|
||||||
const commandFiles = fs
|
|
||||||
.readdirSync(path.resolve(`./dist/commands/${folder}`))
|
|
||||||
.filter((file) => file.endsWith('.js'));
|
|
||||||
|
|
||||||
for (const file of commandFiles) {
|
|
||||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
||||||
const command = require(`../commands/${folder}/${file}`);
|
|
||||||
command.isSystemCommand
|
|
||||||
? systemCommands.push(command.data.toJSON())
|
|
||||||
: slashCommands.push(command.data.toJSON());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!process.env.DISCORD_BOT_TOKEN) {
|
if (!process.env.DISCORD_BOT_TOKEN) {
|
||||||
throw new Error('DISCORD_BOT_TOKEN environment variable is not set.');
|
throw new Error('DISCORD_BOT_TOKEN environment variable is not set.');
|
||||||
@@ -52,6 +41,21 @@ const rest = new REST({ version: '10' }).setToken(process.env.DISCORD_BOT_TOKEN)
|
|||||||
logger.error(
|
logger.error(
|
||||||
'Missing required environment variables for deployment.\nPlease provide valid DISCORD_APPLICATION_ID and DISCORD_BOT_TOKEN in .env file.'
|
'Missing required environment variables for deployment.\nPlease provide valid DISCORD_APPLICATION_ID and DISCORD_BOT_TOKEN in .env file.'
|
||||||
);
|
);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const folder of commandFolders) {
|
||||||
|
const commandFiles = fs
|
||||||
|
.readdirSync(path.resolve(`./dist/interactions/commands/${folder}`))
|
||||||
|
.filter((file) => file.endsWith('.js'));
|
||||||
|
|
||||||
|
for (const file of commandFiles) {
|
||||||
|
const commandModule = await import(`../interactions/commands/${folder}/${file}`);
|
||||||
|
const command = commandModule.default;
|
||||||
|
command.isSystemCommand
|
||||||
|
? systemCommands.push(command.data.toJSON())
|
||||||
|
: slashCommands.push(command.data.toJSON());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export const postBotStats = async ({ client, executionId }: PostBotStatsParams)
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (client.shard?.ids[0] !== 0) {
|
if (client.shard?.ids[0] !== 0) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let guildCount = 0;
|
let guildCount = 0;
|
||||||
@@ -129,7 +129,7 @@ export const postBotStats = async ({ client, executionId }: PostBotStatsParams)
|
|||||||
sites.map((site) => {
|
sites.map((site) => {
|
||||||
if (!site.enabled) {
|
if (!site.enabled) {
|
||||||
// return if site is disabled
|
// return if site is disabled
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export const startLoadTest = async ({ client, executionId }: StartLoadTestParams
|
|||||||
|
|
||||||
if (!loadTestOptions.enabled) {
|
if (!loadTestOptions.enabled) {
|
||||||
logger.debug('Load test is disabled in options, cancelling.');
|
logger.debug('Load test is disabled in options, cancelling.');
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const channelIds = loadTestOptions.channelIdsToJoin;
|
const channelIds = loadTestOptions.channelIdsToJoin;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { EmbedBuilder, GuildMember, TextChannel, VoiceChannel } from 'discord.js';
|
import { EmbedBuilder, GuildMember, InteractionType, TextChannel, VoiceChannel } from 'discord.js';
|
||||||
|
|
||||||
import loggerModule from '../../services/logger';
|
import loggerModule from '../../services/logger';
|
||||||
import { EmbedOptions } from '../../types/configTypes';
|
import { EmbedOptions } from '../../types/configTypes';
|
||||||
@@ -17,6 +17,8 @@ export const cannotJoinVoiceOrTalk = async ({ interaction, executionId }: Cannot
|
|||||||
});
|
});
|
||||||
|
|
||||||
const channel = interaction.member instanceof GuildMember ? interaction.member.voice.channel : null;
|
const channel = interaction.member instanceof GuildMember ? interaction.member.voice.channel : null;
|
||||||
|
const interactionIdentifier =
|
||||||
|
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
||||||
|
|
||||||
if (channel instanceof VoiceChannel && (!channel.joinable || !channel.speakable)) {
|
if (channel instanceof VoiceChannel && (!channel.joinable || !channel.speakable)) {
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
@@ -30,7 +32,7 @@ export const cannotJoinVoiceOrTalk = async ({ interaction, executionId }: Cannot
|
|||||||
});
|
});
|
||||||
|
|
||||||
logger.debug(
|
logger.debug(
|
||||||
`User tried to use command '${interaction.commandName}' but the bot had no permission to join/speak in the voice channel.`
|
`User tried to use command '${interactionIdentifier}' but the bot had no permission to join/speak in the voice channel.`
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -50,10 +52,13 @@ export const cannotSendMessageInChannel = async ({ interaction, executionId }: C
|
|||||||
|
|
||||||
const channel = interaction.channel;
|
const channel = interaction.channel;
|
||||||
|
|
||||||
|
const interactionIdentifier =
|
||||||
|
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
||||||
|
|
||||||
// only checks if channel is viewable, as bot will have permission to send interaction replies if channel is viewable
|
// only checks if channel is viewable, as bot will have permission to send interaction replies if channel is viewable
|
||||||
if (channel instanceof TextChannel && !channel.viewable) {
|
if (channel instanceof TextChannel && !channel.viewable) {
|
||||||
logger.info(
|
logger.info(
|
||||||
`User tried to use command '${interaction.commandName}' but the bot had no permission to send reply in text channel.`
|
`User tried to use interaction '${interactionIdentifier}' but the bot has permission to send reply in text channel.`
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -65,7 +70,7 @@ export const cannotSendMessageInChannel = async ({ interaction, executionId }: C
|
|||||||
logger.debug(
|
logger.debug(
|
||||||
'Sending ephemeral message in channel about insufficient permissions to send message in channel.'
|
'Sending ephemeral message in channel about insufficient permissions to send message in channel.'
|
||||||
);
|
);
|
||||||
return await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.setDescription(
|
||||||
@@ -74,8 +79,6 @@ export const cannotSendMessageInChannel = async ({ interaction, executionId }: C
|
|||||||
.setColor(embedOptions.colors.warning)
|
.setColor(embedOptions.colors.warning)
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof Error) {
|
if (error instanceof Error) {
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { EmbedBuilder } from 'discord.js';
|
import { EmbedBuilder, InteractionType } from 'discord.js';
|
||||||
|
|
||||||
import loggerModule from '../../services/logger';
|
import loggerModule from '../../services/logger';
|
||||||
import { EmbedOptions } from '../../types/configTypes';
|
import { EmbedOptions } from '../../types/configTypes';
|
||||||
import {
|
import { QueueDoesNotExistParams, QueueIsEmptyParams, QueueNoCurrentTrackParams } from '../../types/utilTypes';
|
||||||
QueueDoesNotExistParams, QueueIsEmptyParams, QueueNoCurrentTrackParams
|
|
||||||
} from '../../types/utilTypes';
|
|
||||||
|
|
||||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||||
export const queueDoesNotExist = async ({ interaction, queue, executionId }: QueueDoesNotExistParams) => {
|
export const queueDoesNotExist = async ({ interaction, queue, executionId }: QueueDoesNotExistParams) => {
|
||||||
@@ -18,6 +16,9 @@ export const queueDoesNotExist = async ({ interaction, queue, executionId }: Que
|
|||||||
guildId: interaction.guild?.id
|
guildId: interaction.guild?.id
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const interactionIdentifier =
|
||||||
|
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
||||||
|
|
||||||
if (!queue) {
|
if (!queue) {
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
@@ -29,7 +30,7 @@ export const queueDoesNotExist = async ({ interaction, queue, executionId }: Que
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.debug(`User tried to use command '${interaction.commandName}' but there was no queue.`);
|
logger.debug(`User tried to use command '${interactionIdentifier}' but there was no queue.`);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,6 +47,9 @@ export const queueNoCurrentTrack = async ({ interaction, queue, executionId }: Q
|
|||||||
guildId: interaction.guild?.id
|
guildId: interaction.guild?.id
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const interactionIdentifier =
|
||||||
|
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
||||||
|
|
||||||
if (!queue.currentTrack) {
|
if (!queue.currentTrack) {
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
@@ -57,7 +61,7 @@ export const queueNoCurrentTrack = async ({ interaction, queue, executionId }: Q
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.debug(`User tried to use command '${interaction.commandName}' but there was no current track.`);
|
logger.debug(`User tried to use command '${interactionIdentifier}' but there was no current track.`);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,6 +78,9 @@ export const queueIsEmpty = async ({ interaction, queue, executionId }: QueueIsE
|
|||||||
guildId: interaction.guild?.id
|
guildId: interaction.guild?.id
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const interactionIdentifier =
|
||||||
|
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
||||||
|
|
||||||
if (queue.tracks.data.length === 0) {
|
if (queue.tracks.data.length === 0) {
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
@@ -85,7 +92,7 @@ export const queueIsEmpty = async ({ interaction, queue, executionId }: QueueIsE
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.debug(`User tried to use command '${interaction.commandName}' but there was no tracks in the queue.`);
|
logger.debug(`User tried to use command '${interactionIdentifier}' but there was no tracks in the queue.`);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { EmbedBuilder } from 'discord.js';
|
import { EmbedBuilder, InteractionType } from 'discord.js';
|
||||||
|
|
||||||
import loggerModule from '../../services/logger';
|
import loggerModule from '../../services/logger';
|
||||||
import { EmbedOptions, SystemOptions } from '../../types/configTypes';
|
import { EmbedOptions, SystemOptions } from '../../types/configTypes';
|
||||||
@@ -17,19 +17,22 @@ export const notValidGuildId = async ({ interaction, executionId }: NotValidGuil
|
|||||||
guildId: interaction.guild?.id
|
guildId: interaction.guild?.id
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const interactionIdentifier =
|
||||||
|
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
||||||
|
|
||||||
if (interaction.guildId && !systemOptions.systemGuildIds.includes(interaction.guildId)) {
|
if (interaction.guildId && !systemOptions.systemGuildIds.includes(interaction.guildId)) {
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${embedOptions.icons.warning} Oops!**\nNo permission to execute this command.\n\nThe command **\`/${interaction.commandName}\`** cannot be executed in this server.`
|
`**${embedOptions.icons.warning} Oops!**\nNo permission to execute this command.\n\nThe command **\`/${interactionIdentifier}\`** cannot be executed in this server.`
|
||||||
)
|
)
|
||||||
.setColor(embedOptions.colors.warning)
|
.setColor(embedOptions.colors.warning)
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.debug(
|
logger.debug(
|
||||||
`User tried to use command '${interaction.commandName}' but system command cannot be executed in the specified guild.`
|
`User tried to use command '${interactionIdentifier}' but system command cannot be executed in the specified guild.`
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { EmbedBuilder, GuildMember } from 'discord.js';
|
import { EmbedBuilder, GuildMember, InteractionType } from 'discord.js';
|
||||||
|
|
||||||
import loggerModule from '../../services/logger';
|
import loggerModule from '../../services/logger';
|
||||||
import { EmbedOptions } from '../../types/configTypes';
|
import { EmbedOptions } from '../../types/configTypes';
|
||||||
@@ -16,6 +16,9 @@ export const notInVoiceChannel = async ({ interaction, executionId }: NotInVoice
|
|||||||
guildId: interaction.guild?.id
|
guildId: interaction.guild?.id
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const interactionIdentifier =
|
||||||
|
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
||||||
|
|
||||||
if (interaction.member instanceof GuildMember && !interaction.member.voice.channel) {
|
if (interaction.member instanceof GuildMember && !interaction.member.voice.channel) {
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
@@ -27,7 +30,7 @@ export const notInVoiceChannel = async ({ interaction, executionId }: NotInVoice
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.debug(`User tried to use command '${interaction.commandName}' but was not in a voice channel.`);
|
logger.debug(`User tried to use command '${interactionIdentifier}' but was not in a voice channel.`);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,6 +47,9 @@ export const notInSameVoiceChannel = async ({ interaction, queue, executionId }:
|
|||||||
guildId: interaction.guild?.id
|
guildId: interaction.guild?.id
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const interactionIdentifier =
|
||||||
|
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
||||||
|
|
||||||
if (!queue || !queue.dispatcher) {
|
if (!queue || !queue.dispatcher) {
|
||||||
// If there is no queue or bot is not in voice channel, then there is no need to check if user is in same voice channel.
|
// If there is no queue or bot is not in voice channel, then there is no need to check if user is in same voice channel.
|
||||||
return false;
|
return false;
|
||||||
@@ -63,7 +69,7 @@ export const notInSameVoiceChannel = async ({ interaction, queue, executionId }:
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.debug(`User tried to use command '${interaction.commandName}' but was not in the same voice channel.`);
|
logger.debug(`User tried to use command '${interactionIdentifier}' but was not in the same voice channel.`);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user