mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-04 22:15:29 +00:00
fix: remove Promise.resolve() return and fix queue type
This commit is contained in:
1 parent
d5cc5b8741
commit
67e45729a3
23 files changed
+102
-117
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.');
|
||||||
|
|||||||
@@ -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,
|
||||||
@@ -40,21 +40,21 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const filterOptions: StringSelectMenuOptionBuilder[] = [];
|
const filterOptions: StringSelectMenuOptionBuilder[] = [];
|
||||||
|
|||||||
@@ -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,10 +28,10 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
if (!queue) {
|
if (!queue) {
|
||||||
logger.debug('There is already no queue.');
|
logger.debug('There is already no queue.');
|
||||||
@@ -49,7 +49,7 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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';
|
||||||
@@ -42,17 +42,17 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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,24 +43,24 @@ 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 })) {
|
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
geniusSearchQuery = queue.currentTrack!.title.slice(0, 50);
|
geniusSearchQuery = queue.currentTrack!.title.slice(0, 50);
|
||||||
|
|
||||||
@@ -188,7 +188,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,
|
||||||
@@ -38,21 +38,21 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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';
|
||||||
@@ -29,21 +29,21 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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,18 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
guildId: interaction.guild?.id
|
guildId: interaction.guild?.id
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await cannotJoinVoiceOrTalk({ interaction, executionId })) {
|
if (await cannotJoinVoiceOrTalk({ interaction, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let queue = useQueue(interaction.guild!.id);
|
let queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
if (queue && (await notInSameVoiceChannel({ interaction, queue, executionId }))) {
|
if (queue && (await notInSameVoiceChannel({ interaction, queue, executionId }))) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const player = useMainPlayer()!;
|
const player = useMainPlayer()!;
|
||||||
@@ -86,7 +87,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 +212,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,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, SlashCommandBuilder } from 'discord.js';
|
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||||
|
|
||||||
import loggerModule from '../../../services/logger';
|
import loggerModule from '../../../services/logger';
|
||||||
@@ -30,13 +30,13 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const pageIndex = (interaction.options.getNumber('page') || 1) - 1;
|
const pageIndex = (interaction.options.getNumber('page') || 1) - 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,21 +35,21 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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';
|
||||||
@@ -29,21 +29,21 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await queueIsEmpty({ interaction, queue, executionId })) {
|
if (await queueIsEmpty({ interaction, queue, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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';
|
||||||
@@ -32,21 +32,21 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const skipToTrack = interaction.options.getNumber('tracknumber');
|
const skipToTrack = 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';
|
||||||
@@ -28,10 +28,10 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
if (!queue) {
|
if (!queue) {
|
||||||
logger.debug('There is no queue.');
|
logger.debug('There is no queue.');
|
||||||
@@ -49,7 +49,7 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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';
|
||||||
@@ -36,17 +36,17 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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.');
|
||||||
|
|||||||
@@ -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 } from 'discord.js';
|
import { EmbedBuilder, GuildMember } from 'discord.js';
|
||||||
|
|
||||||
import loggerModule from '../../services/logger';
|
import loggerModule from '../../services/logger';
|
||||||
@@ -20,7 +20,7 @@ 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)!;
|
||||||
|
|
||||||
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.');
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -65,7 +65,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 +74,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) {
|
||||||
|
|||||||
Reference in new issue
Block a user