aboutsummaryrefslogtreecommitdiff
path: root/src/commands/play.ts
diff options
context:
space:
mode:
authorBobby <[email protected]>2024-11-06 09:42:25 -0500
committerGitHub <[email protected]>2024-11-06 09:42:25 -0500
commitd92fd2a29796c9c5d6ddeb9718bf6fcd6ee5958a (patch)
tree81961cc995661448794669617f1ed439cbe84a3d /src/commands/play.ts
parentb605bf220859acd767533e0ab9436ced771bb8e2 (diff)
parent716d6d9f4f2cd1a6872e463e9877203a259478a3 (diff)
downloadmuse-master.tar.xz
muse-master.zip
Merge branch 'museofficial:master' into masterHEADmaster
Diffstat (limited to 'src/commands/play.ts')
-rw-r--r--src/commands/play.ts56
1 files changed, 31 insertions, 25 deletions
diff --git a/src/commands/play.ts b/src/commands/play.ts
index 25aef1c..c87ccd5 100644
--- a/src/commands/play.ts
+++ b/src/commands/play.ts
@@ -1,7 +1,7 @@
import {AutocompleteInteraction, ChatInputCommandInteraction} from 'discord.js';
import {URL} from 'url';
-import {SlashCommandBuilder} from '@discordjs/builders';
-import {inject, injectable} from 'inversify';
+import {SlashCommandBuilder, SlashCommandSubcommandsOnlyBuilder} from '@discordjs/builders';
+import {inject, injectable, optional} from 'inversify';
import Spotify from 'spotify-web-api-node';
import Command from './index.js';
import {TYPES} from '../types.js';
@@ -13,37 +13,43 @@ import AddQueryToQueue from '../services/add-query-to-queue.js';
@injectable()
export default class implements Command {
- public readonly slashCommand = new SlashCommandBuilder()
- .setName('play')
- .setDescription('play a song')
- .addStringOption(option => option
- .setName('query')
- .setDescription('YouTube URL, Spotify URL, or search query')
- .setAutocomplete(true)
- .setRequired(true))
- .addBooleanOption(option => option
- .setName('immediate')
- .setDescription('add track to the front of the queue'))
- .addBooleanOption(option => option
- .setName('shuffle')
- .setDescription('shuffle the input if you\'re adding multiple tracks'))
- .addBooleanOption(option => option
- .setName('split')
- .setDescription('if a track has chapters, split it'))
- .addBooleanOption(option => option
- .setName('skip')
- .setDescription('skip the currently playing track'));
+ public readonly slashCommand: Partial<SlashCommandBuilder | SlashCommandSubcommandsOnlyBuilder> & Pick<SlashCommandBuilder, 'toJSON'>;
public requiresVC = true;
- private readonly spotify: Spotify;
+ private readonly spotify?: Spotify;
private readonly cache: KeyValueCacheProvider;
private readonly addQueryToQueue: AddQueryToQueue;
- constructor(@inject(TYPES.ThirdParty) thirdParty: ThirdParty, @inject(TYPES.KeyValueCache) cache: KeyValueCacheProvider, @inject(TYPES.Services.AddQueryToQueue) addQueryToQueue: AddQueryToQueue) {
- this.spotify = thirdParty.spotify;
+ constructor(@inject(TYPES.ThirdParty) @optional() thirdParty: ThirdParty, @inject(TYPES.KeyValueCache) cache: KeyValueCacheProvider, @inject(TYPES.Services.AddQueryToQueue) addQueryToQueue: AddQueryToQueue) {
+ this.spotify = thirdParty?.spotify;
this.cache = cache;
this.addQueryToQueue = addQueryToQueue;
+
+ const queryDescription = thirdParty === undefined
+ ? 'YouTube URL or search query'
+ : 'YouTube URL, Spotify URL, or search query';
+
+ this.slashCommand = new SlashCommandBuilder()
+ .setName('play')
+ .setDescription('play a song')
+ .addStringOption(option => option
+ .setName('query')
+ .setDescription(queryDescription)
+ .setAutocomplete(true)
+ .setRequired(true))
+ .addBooleanOption(option => option
+ .setName('immediate')
+ .setDescription('add track to the front of the queue'))
+ .addBooleanOption(option => option
+ .setName('shuffle')
+ .setDescription('shuffle the input if you\'re adding multiple tracks'))
+ .addBooleanOption(option => option
+ .setName('split')
+ .setDescription('if a track has chapters, split it'))
+ .addBooleanOption(option => option
+ .setName('skip')
+ .setDescription('skip the currently playing track'));
}
public async execute(interaction: ChatInputCommandInteraction): Promise<void> {