aboutsummaryrefslogtreecommitdiff
path: root/src/commands
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
parentb605bf220859acd767533e0ab9436ced771bb8e2 (diff)
parent716d6d9f4f2cd1a6872e463e9877203a259478a3 (diff)
downloadmuse-d92fd2a29796c9c5d6ddeb9718bf6fcd6ee5958a.tar.xz
muse-d92fd2a29796c9c5d6ddeb9718bf6fcd6ee5958a.zip
Merge branch 'museofficial:master' into masterHEADmaster
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/config.ts78
-rw-r--r--src/commands/play.ts56
-rw-r--r--src/commands/queue.ts19
3 files changed, 126 insertions, 27 deletions
diff --git a/src/commands/config.ts b/src/commands/config.ts
index f866e82..01d9fe9 100644
--- a/src/commands/config.ts
+++ b/src/commands/config.ts
@@ -41,6 +41,22 @@ export default class implements Command {
.setDescription('whether bot responses to queue additions are only displayed to the requester')
.setRequired(true)))
.addSubcommand(subcommand => subcommand
+ .setName('set-reduce-vol-when-voice')
+ .setDescription('set whether to turn down the volume when people speak')
+ .addBooleanOption(option => option
+ .setName('value')
+ .setDescription('whether to turn down the volume when people speak')
+ .setRequired(true)))
+ .addSubcommand(subcommand => subcommand
+ .setName('set-reduce-vol-when-voice-target')
+ .setDescription('set the target volume when people speak')
+ .addIntegerOption(option => option
+ .setName('volume')
+ .setDescription('volume percentage (0 is muted, 100 is max & default)')
+ .setMinValue(0)
+ .setMaxValue(100)
+ .setRequired(true)))
+ .addSubcommand(subcommand => subcommand
.setName('set-auto-announce-next-song')
.setDescription('set whether to announce the next song in the queue automatically')
.addBooleanOption(option => option
@@ -57,6 +73,15 @@ export default class implements Command {
.setMaxValue(100)
.setRequired(true)))
.addSubcommand(subcommand => subcommand
+ .setName('set-default-queue-page-size')
+ .setDescription('set the default page size of the /queue command')
+ .addIntegerOption(option => option
+ .setName('page-size')
+ .setDescription('page size of the /queue command')
+ .setMinValue(1)
+ .setMaxValue(30)
+ .setRequired(true)))
+ .addSubcommand(subcommand => subcommand
.setName('get')
.setDescription('show all settings'));
@@ -171,6 +196,57 @@ export default class implements Command {
break;
}
+ case 'set-default-queue-page-size': {
+ const value = interaction.options.getInteger('page-size')!;
+
+ await prisma.setting.update({
+ where: {
+ guildId: interaction.guild!.id,
+ },
+ data: {
+ defaultQueuePageSize: value,
+ },
+ });
+
+ await interaction.reply('👍 default queue page size updated');
+
+ break;
+ }
+
+ case 'set-reduce-vol-when-voice': {
+ const value = interaction.options.getBoolean('value')!;
+
+ await prisma.setting.update({
+ where: {
+ guildId: interaction.guild!.id,
+ },
+ data: {
+ turnDownVolumeWhenPeopleSpeak: value,
+ },
+ });
+
+ await interaction.reply('👍 turn down volume setting updated');
+
+ break;
+ }
+
+ case 'set-reduce-vol-when-voice-target': {
+ const value = interaction.options.getInteger('volume')!;
+
+ await prisma.setting.update({
+ where: {
+ guildId: interaction.guild!.id,
+ },
+ data: {
+ turnDownVolumeWhenPeopleSpeakTarget: value,
+ },
+ });
+
+ await interaction.reply('👍 turn down volume target setting updated');
+
+ break;
+ }
+
case 'get': {
const embed = new EmbedBuilder().setTitle('Config');
@@ -185,6 +261,8 @@ export default class implements Command {
'Auto announce next song in queue': config.autoAnnounceNextSong ? 'yes' : 'no',
'Add to queue reponses show for requester only': config.autoAnnounceNextSong ? 'yes' : 'no',
'Default Volume': config.defaultVolume,
+ 'Default queue page size': config.defaultQueuePageSize,
+ 'Reduce volume when people speak': config.turnDownVolumeWhenPeopleSpeak ? 'yes' : 'no',
};
let description = '';
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> {
diff --git a/src/commands/queue.ts b/src/commands/queue.ts
index 5196ca9..fd36e43 100644
--- a/src/commands/queue.ts
+++ b/src/commands/queue.ts
@@ -5,6 +5,7 @@ import {TYPES} from '../types.js';
import PlayerManager from '../managers/player.js';
import Command from './index.js';
import {buildQueueEmbed} from '../utils/build-embed.js';
+import {getGuildSettings} from '../utils/get-guild-settings.js';
@injectable()
export default class implements Command {
@@ -14,6 +15,12 @@ export default class implements Command {
.addIntegerOption(option => option
.setName('page')
.setDescription('page of queue to show [default: 1]')
+ .setRequired(false))
+ .addIntegerOption(option => option
+ .setName('page-size')
+ .setDescription('how many items to display per page [default: 10, max: 30]')
+ .setMinValue(1)
+ .setMaxValue(30)
.setRequired(false));
private readonly playerManager: PlayerManager;
@@ -23,9 +30,17 @@ export default class implements Command {
}
public async execute(interaction: ChatInputCommandInteraction) {
- const player = this.playerManager.get(interaction.guild!.id);
+ const guildId = interaction.guild!.id;
+ const player = this.playerManager.get(guildId);
+
+ const pageSizeFromOptions = interaction.options.getInteger('page-size');
+ const pageSize = pageSizeFromOptions ?? (await getGuildSettings(guildId)).defaultQueuePageSize;
- const embed = buildQueueEmbed(player, interaction.options.getInteger('page') ?? 1);
+ const embed = buildQueueEmbed(
+ player,
+ interaction.options.getInteger('page') ?? 1,
+ pageSize,
+ );
await interaction.reply({embeds: [embed]});
}