Skip to content

Commit

Permalink
resolve #124
Browse files Browse the repository at this point in the history
  • Loading branch information
NachoToast committed May 7, 2023
1 parent fc57736 commit 712297f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/commands/music/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { leaveCommand } from './leave';
import { nowPlayingCommand } from './nowPlaying';
import { pauseCommand } from './pause';
import { playCommand } from './play';
import { previousCommand } from './previous';
import { queueCommand } from './queue';
import { removeCommand } from './remove';
import { resumeCommand } from './resume';
Expand All @@ -22,6 +23,7 @@ export const musicCommands = [
clearCommand,
removeCommand,
shuffleCommand,
previousCommand,
];

if (JukebotGlobals.devmode) musicCommands.push(searchCommand);
20 changes: 20 additions & 0 deletions src/commands/music/previous.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { EntityManager } from '../../classes';
import { errorMessages } from '../../messages';
import { Command } from '../../types';

export const previousCommand: Command = {
name: 'previous',
description: 'Lists the recently played songs',
execute: async function ({ interaction, channel, member }): Promise<void> {
const jukebox = EntityManager.getGuildInstance(member.guild.id);

if (jukebox === undefined) {
await interaction.reply({ content: errorMessages.emptyPreviousQueue });
return;
}

const response = jukebox.historyQueue.makeQueueEmbed(interaction, channel, member);

await interaction.reply(response);
},
};
2 changes: 2 additions & 0 deletions src/messages/errorMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export const errorMessages = {
/** Send when an interaction that requires a queue of length > 0 is called while the queue is empty. */
emptyQueue: 'Nothing is currently queued',

emptyPreviousQueue: 'Nothing has been played yet',

notInSameVoiceChannel: (targetVoiceChannelId: string, action: string) =>
`You must be in the same voice channel as me (${channelMention(targetVoiceChannelId)}) to ${action}`,
};

0 comments on commit 712297f

Please sign in to comment.