mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-04 06:28:53 +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
@@ -1,5 +1,5 @@
|
||||
import config from 'config';
|
||||
import { NodeResolvable, QueueFilters, useQueue } from 'discord-player';
|
||||
import { GuildQueue, QueueFilters, useQueue } from 'discord-player';
|
||||
import {
|
||||
APIActionRowComponent,
|
||||
APIMessageActionRowComponent,
|
||||
@@ -40,21 +40,21 @@ const command: CustomSlashCommandInteraction = {
|
||||
});
|
||||
|
||||
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 })) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
const filterOptions: StringSelectMenuOptionBuilder[] = [];
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import config from 'config';
|
||||
import { NodeResolvable, useQueue } from 'discord-player';
|
||||
import { GuildQueue, useQueue } from 'discord-player';
|
||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
||||
|
||||
import loggerModule from '../../../services/logger';
|
||||
@@ -28,10 +28,10 @@ const command: CustomSlashCommandInteraction = {
|
||||
});
|
||||
|
||||
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) {
|
||||
logger.debug('There is already no queue.');
|
||||
@@ -49,7 +49,7 @@ const command: CustomSlashCommandInteraction = {
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!queue.deleted) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
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 loggerModule from '../../../services/logger';
|
||||
@@ -42,17 +42,17 @@ const command: CustomSlashCommandInteraction = {
|
||||
});
|
||||
|
||||
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 })) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
const loopModesFormatted = new Map([
|
||||
@@ -132,6 +132,7 @@ const command: CustomSlashCommandInteraction = {
|
||||
if (queue.repeatMode === 0) {
|
||||
logger.debug('Disabled loop mode.');
|
||||
|
||||
// TODO: Different text when disabling autoplay.
|
||||
logger.debug('Responding with success embed.');
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
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 { lyricsExtractor } from '@discord-player/extractor';
|
||||
@@ -43,24 +43,24 @@ const command: CustomSlashCommandInteraction = {
|
||||
});
|
||||
|
||||
const query = interaction.options.getString('query');
|
||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
let geniusSearchQuery = '';
|
||||
|
||||
if (!query) {
|
||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
geniusSearchQuery = queue.currentTrack!.title.slice(0, 50);
|
||||
|
||||
@@ -188,7 +188,7 @@ const command: CustomSlashCommandInteraction = {
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
logger.debug('Responding with info embed.');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import config from 'config';
|
||||
import { NodeResolvable, Track, useQueue } from 'discord-player';
|
||||
import { GuildQueue, Track, useQueue } from 'discord-player';
|
||||
import {
|
||||
APIActionRowComponent,
|
||||
APIMessageActionRowComponent,
|
||||
@@ -38,21 +38,21 @@ const command: CustomSlashCommandInteraction = {
|
||||
});
|
||||
|
||||
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 })) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
const sourceStringsFormatted = new Map([
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import config from 'config';
|
||||
import { NodeResolvable, useQueue } from 'discord-player';
|
||||
import { GuildQueue, useQueue } from 'discord-player';
|
||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
||||
|
||||
import loggerModule from '../../../services/logger';
|
||||
@@ -29,21 +29,21 @@ const command: CustomSlashCommandInteraction = {
|
||||
});
|
||||
|
||||
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 })) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
const currentTrack = queue.currentTrack!;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
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 loggerModule from '../../../services/logger';
|
||||
@@ -43,17 +43,18 @@ const command: CustomSlashCommandInteraction = {
|
||||
guildId: interaction.guild?.id
|
||||
});
|
||||
|
||||
|
||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
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 }))) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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}'.`);
|
||||
|
||||
queue = useQueue(interaction.guild!.id);
|
||||
queue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
if (!queue || !track) {
|
||||
logger.warn(`After player.play(), queue is undefined. Query: '${query}'.`);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import config from 'config';
|
||||
import { NodeResolvable, useQueue } from 'discord-player';
|
||||
import { GuildQueue, useQueue } from 'discord-player';
|
||||
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||
|
||||
import loggerModule from '../../../services/logger';
|
||||
@@ -30,13 +30,13 @@ const command: CustomSlashCommandInteraction = {
|
||||
});
|
||||
|
||||
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 })) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
const pageIndex = (interaction.options.getNumber('page') || 1) - 1;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import config from 'config';
|
||||
import { NodeResolvable, useQueue } from 'discord-player';
|
||||
import { GuildQueue, useQueue } from 'discord-player';
|
||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
||||
|
||||
import loggerModule from '../../../services/logger';
|
||||
@@ -35,21 +35,21 @@ const command: CustomSlashCommandInteraction = {
|
||||
});
|
||||
|
||||
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 })) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
const durationInput = interaction.options.getString('duration');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import config from 'config';
|
||||
import { NodeResolvable, useQueue } from 'discord-player';
|
||||
import { GuildQueue, useQueue } from 'discord-player';
|
||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
||||
|
||||
import loggerModule from '../../../services/logger';
|
||||
@@ -29,21 +29,21 @@ const command: CustomSlashCommandInteraction = {
|
||||
});
|
||||
|
||||
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 })) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
if (await queueIsEmpty({ interaction, queue, executionId })) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
queue.tracks.shuffle();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import config from 'config';
|
||||
import { NodeResolvable, useQueue } from 'discord-player';
|
||||
import { GuildQueue, useQueue } from 'discord-player';
|
||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
||||
|
||||
import loggerModule from '../../../services/logger';
|
||||
@@ -32,21 +32,21 @@ const command: CustomSlashCommandInteraction = {
|
||||
});
|
||||
|
||||
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 })) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
const skipToTrack = interaction.options.getNumber('tracknumber');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import config from 'config';
|
||||
import { NodeResolvable, useQueue } from 'discord-player';
|
||||
import { GuildQueue, useQueue } from 'discord-player';
|
||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
||||
|
||||
import loggerModule from '../../../services/logger';
|
||||
@@ -28,10 +28,10 @@ const command: CustomSlashCommandInteraction = {
|
||||
});
|
||||
|
||||
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) {
|
||||
logger.debug('There is no queue.');
|
||||
@@ -49,7 +49,7 @@ const command: CustomSlashCommandInteraction = {
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!queue.deleted) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import config from 'config';
|
||||
import { NodeResolvable, useQueue } from 'discord-player';
|
||||
import { GuildQueue, useQueue } from 'discord-player';
|
||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
||||
|
||||
import loggerModule from '../../../services/logger';
|
||||
@@ -36,17 +36,17 @@ const command: CustomSlashCommandInteraction = {
|
||||
});
|
||||
|
||||
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 })) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
const volume = interaction.options.getNumber('percentage');
|
||||
|
||||
Reference in new issue
Block a user