mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-02 06:28:54 +00:00
fix: remove unnecessary async/await
This commit is contained in:
1 parent
dd0804770c
commit
7dc7b4ff7e
5 files changed
+15
-18
No files matched your search
@@ -26,7 +26,7 @@ class LeaveCommand extends BaseSlashCommandInteraction {
|
||||
]);
|
||||
|
||||
logger.debug('Deleting queue.');
|
||||
await this.deleteQueue(queue);
|
||||
this.deleteQueue(queue);
|
||||
|
||||
logger.debug('Responding with success embed.');
|
||||
return await interaction.editReply({
|
||||
@@ -43,7 +43,7 @@ class LeaveCommand extends BaseSlashCommandInteraction {
|
||||
});
|
||||
}
|
||||
|
||||
private async deleteQueue(queue: GuildQueue): Promise<void> {
|
||||
private deleteQueue(queue: GuildQueue): void {
|
||||
if (!queue.deleted) {
|
||||
queue.delete();
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
||||
|
||||
const player = useMainPlayer()!;
|
||||
const searchQuery = interaction.options.getString('query')!;
|
||||
const transformedQuery = await transformQuery({ query: searchQuery, executionId });
|
||||
const transformedQuery = transformQuery({ query: searchQuery, executionId });
|
||||
|
||||
const searchResult = await this.searchTrack(player, transformedQuery, interaction, logger);
|
||||
if (!searchResult || searchResult.tracks.length === 0) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { GuildQueue, useQueue } from 'discord-player';
|
||||
import { ChatInputCommandInteraction, EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||
import { ChatInputCommandInteraction, EmbedBuilder, Message, SlashCommandBuilder } from 'discord.js';
|
||||
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||
@@ -57,11 +57,11 @@ class SeekCommand extends BaseSlashCommandInteraction {
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
formattedDurationString: string
|
||||
) {
|
||||
): Promise<Message> {
|
||||
logger.debug('Invalid duration format input.');
|
||||
|
||||
logger.debug('Responding with warning embed.');
|
||||
await interaction.editReply({
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
@@ -76,7 +76,6 @@ class SeekCommand extends BaseSlashCommandInteraction {
|
||||
.setColor(this.embedOptions.colors.warning)
|
||||
]
|
||||
});
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
private async seekToDurationInCurrentTrack(
|
||||
@@ -85,12 +84,12 @@ class SeekCommand extends BaseSlashCommandInteraction {
|
||||
queue: GuildQueue,
|
||||
durationInMilliseconds: number,
|
||||
formattedDurationString: string
|
||||
) {
|
||||
): Promise<Message> {
|
||||
queue.node.seek(durationInMilliseconds);
|
||||
logger.debug(`Seeked to '${formattedDurationString}' in current track.`);
|
||||
|
||||
logger.debug('Responding with success embed.');
|
||||
await interaction.editReply({
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setAuthor(await this.getEmbedUserAuthor(interaction))
|
||||
@@ -102,7 +101,6 @@ class SeekCommand extends BaseSlashCommandInteraction {
|
||||
.setColor(this.embedOptions.colors.success)
|
||||
]
|
||||
});
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
private async handleDurationLongerThanTrack(
|
||||
@@ -110,11 +108,11 @@ class SeekCommand extends BaseSlashCommandInteraction {
|
||||
interaction: ChatInputCommandInteraction,
|
||||
formattedDurationString: string,
|
||||
queue: GuildQueue
|
||||
) {
|
||||
): Promise<Message> {
|
||||
logger.debug('Duration specified is longer than the track duration.');
|
||||
|
||||
logger.debug('Responding with warning embed.');
|
||||
await interaction.editReply({
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
@@ -127,7 +125,6 @@ class SeekCommand extends BaseSlashCommandInteraction {
|
||||
.setColor(this.embedOptions.colors.warning)
|
||||
]
|
||||
});
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
private parseDurationArray(durationInputSplit: string[]): string {
|
||||
|
||||
@@ -6,7 +6,7 @@ describe('searchQueryValidator', () => {
|
||||
async (countryCode) => {
|
||||
const trackId = '5T8EDUDqKcs6OSOwEsfqG7';
|
||||
const query: string = `https://open.spotify.com/${countryCode}/track/${trackId}`;
|
||||
const transformedQuery: string = await transformQuery({ query, executionId: 'test' });
|
||||
const transformedQuery: string = transformQuery({ query, executionId: 'test' });
|
||||
|
||||
expect(transformedQuery).toBe(`https://open.spotify.com/track/${trackId}`);
|
||||
}
|
||||
@@ -17,7 +17,7 @@ describe('searchQueryValidator', () => {
|
||||
async (path) => {
|
||||
const trackId = '5T8EDUDqKcs6OSOwEsfqG7';
|
||||
const query: string = `https://open.spotify.com/${path}/track/${trackId}`;
|
||||
const transformedQuery: string = await transformQuery({ query, executionId: 'test' });
|
||||
const transformedQuery: string = transformQuery({ query, executionId: 'test' });
|
||||
|
||||
expect(transformedQuery).toBe(`https://open.spotify.com/${path}/track/${trackId}`);
|
||||
}
|
||||
@@ -28,7 +28,7 @@ describe('searchQueryValidator', () => {
|
||||
async (path) => {
|
||||
const trackId = '5T8EDUDqKcs6OSOwEsfqG7';
|
||||
const query: string = `https://open.spotify.com/${path}/track/${trackId}`;
|
||||
const transformedQuery: string = await transformQuery({ query, executionId: 'test' });
|
||||
const transformedQuery: string = transformQuery({ query, executionId: 'test' });
|
||||
|
||||
expect(transformedQuery).toBe(`https://open.spotify.com/${path}/track/${trackId}`);
|
||||
}
|
||||
@@ -46,7 +46,7 @@ describe('searchQueryValidator', () => {
|
||||
]
|
||||
])('should return the same url if it is not a valid Spotify url', async (inputUrl, expectedUrl) => {
|
||||
const executionId: string = 'test';
|
||||
const transformedQuery: string = await transformQuery({ query: inputUrl, executionId });
|
||||
const transformedQuery: string = transformQuery({ query: inputUrl, executionId });
|
||||
|
||||
expect(transformedQuery).toBe(expectedUrl);
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Logger } from 'pino';
|
||||
import loggerModule from '../../services/logger';
|
||||
import { TransformQueryParams } from '../../types/utilTypes';
|
||||
|
||||
export const transformQuery = async ({ query, executionId }: TransformQueryParams) => {
|
||||
export const transformQuery = ({ query, executionId }: TransformQueryParams) => {
|
||||
const logger: Logger = loggerModule.child({
|
||||
module: 'utilValidation',
|
||||
name: 'transformQuery',
|
||||
|
||||
Reference in new issue
Block a user