aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZagrthos <[email protected]>2022-03-19 15:55:23 +0100
committerGitHub <[email protected]>2022-03-19 09:55:23 -0500
commit60376d4f5798004bc0215698bc1cc0786fcd5dbc (patch)
tree270ae2fc9a11b4a9d5ef50023a89799d4e69a928
parent346a6c6eee4a790cc71e5b6d78854be61b28873f (diff)
downloadmuse-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]>
-rw-r--r--CHANGELOG.md2
-rw-r--r--README.md4
-rw-r--r--src/commands/now-playing.ts32
-rw-r--r--src/inversify.config.ts2
-rw-r--r--src/utils/build-embed.ts4
5 files changed, 41 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ab20474..8709464 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
+### Added
+- Added a `/now-playing` command to show the current track without the full queue embed
## [1.6.2] - 2022-03-17
### Fixed
diff --git a/README.md b/README.md
index d2b43fc..a913b2f 100644
--- a/README.md
+++ b/README.md
@@ -77,7 +77,9 @@ services:
### Node.js
-**Prerequisites**: Node.js, ffmpeg
+**Prerequisites**:
+* Node.js (16.x is recommended because it's the current LTS version)
+* ffmpeg
1. `git clone https://github.com/codetheweb/muse.git && cd muse`
2. Copy `.env.example` to `.env` and populate with values
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)],
+ });
+ }
+}
diff --git a/src/inversify.config.ts b/src/inversify.config.ts
index b6a6f51..78267f8 100644
--- a/src/inversify.config.ts
+++ b/src/inversify.config.ts
@@ -21,6 +21,7 @@ import Config from './commands/config.js';
import Disconnect from './commands/disconnect.js';
import Favorites from './commands/favorites.js';
import ForwardSeek from './commands/fseek.js';
+import NowPlaying from './commands/now-playing.js';
import Pause from './commands/pause.js';
import Play from './commands/play.js';
import QueueCommand from './commands/queue.js';
@@ -65,6 +66,7 @@ container.bind<SpotifyAPI>(TYPES.Services.SpotifyAPI).to(SpotifyAPI).inSingleton
Disconnect,
Favorites,
ForwardSeek,
+ NowPlaying,
Pause,
Play,
QueueCommand,
diff --git a/src/utils/build-embed.ts b/src/utils/build-embed.ts
index 0925da1..c6e9551 100644
--- a/src/utils/build-embed.ts
+++ b/src/utils/build-embed.ts
@@ -61,8 +61,8 @@ export const buildPlayingMessageEmbed = (player: Player): MessageEmbed => {
const message = new MessageEmbed();
message
- .setColor('DARK_GREEN')
- .setTitle('Now Playing')
+ .setColor(player.status === STATUS.PLAYING ? 'DARK_GREEN' : 'DARK_RED')
+ .setTitle(player.status === STATUS.PLAYING ? 'Now Playing' : 'Paused')
.setDescription(`
**${getSongTitle(currentlyPlaying)}**
Requested by: <@${requestedBy}>\n