diff options
| author | Zagrthos <[email protected]> | 2022-03-19 15:55:23 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-03-19 09:55:23 -0500 |
| commit | 60376d4f5798004bc0215698bc1cc0786fcd5dbc (patch) | |
| tree | 270ae2fc9a11b4a9d5ef50023a89799d4e69a928 /src/commands | |
| parent | 346a6c6eee4a790cc71e5b6d78854be61b28873f (diff) | |
| download | muse-60376d4f5798004bc0215698bc1cc0786fcd5dbc.tar.xz muse-60376d4f5798004bc0215698bc1cc0786fcd5dbc.zip | |
Update README and add "Now playing" Command (#589)
Co-authored-by: Max Isom <[email protected]>
Co-authored-by: Max Isom <[email protected]>
Diffstat (limited to 'src/commands')
| -rw-r--r-- | src/commands/now-playing.ts | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/commands/now-playing.ts b/src/commands/now-playing.ts new file mode 100644 index 0000000..999bb69 --- /dev/null +++ b/src/commands/now-playing.ts @@ -0,0 +1,32 @@ +import {CommandInteraction} from 'discord.js'; +import {TYPES} from '../types.js'; +import {inject, injectable} from 'inversify'; +import PlayerManager from '../managers/player.js'; +import Command from '.'; +import {SlashCommandBuilder} from '@discordjs/builders'; +import {buildPlayingMessageEmbed} from '../utils/build-embed.js'; + +@injectable() +export default class implements Command { + public readonly slashCommand = new SlashCommandBuilder() + .setName('now-playing') + .setDescription('shows the currently played song'); + + private readonly playerManager: PlayerManager; + + constructor(@inject(TYPES.Managers.Player) playerManager: PlayerManager) { + this.playerManager = playerManager; + } + + public async execute(interaction: CommandInteraction): Promise<void> { + const player = this.playerManager.get(interaction.guild!.id); + + if (!player.getCurrent()) { + throw new Error('nothing is currently playing'); + } + + await interaction.reply({ + embeds: [buildPlayingMessageEmbed(player)], + }); + } +} |
