From 6e39c8d09ed8f7460f54fb766efddd507f368523 Mon Sep 17 00:00:00 2001 From: Tiago Grosso Date: Fri, 23 Aug 2024 21:18:08 +0100 Subject: feat: add optional pageSize to /queue command --- src/commands/queue.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/commands') diff --git a/src/commands/queue.ts b/src/commands/queue.ts index 5196ca9..dcc674a 100644 --- a/src/commands/queue.ts +++ b/src/commands/queue.ts @@ -14,6 +14,10 @@ export default class implements Command { .addIntegerOption(option => option .setName('page') .setDescription('page of queue to show [default: 1]') + .setRequired(false)) + .addIntegerOption(option => option + .setName('pageSize') + .setDescription('how many items to display per page [default: 10]') .setRequired(false)); private readonly playerManager: PlayerManager; @@ -25,7 +29,11 @@ export default class implements Command { public async execute(interaction: ChatInputCommandInteraction) { const player = this.playerManager.get(interaction.guild!.id); - const embed = buildQueueEmbed(player, interaction.options.getInteger('page') ?? 1); + const embed = buildQueueEmbed( + player, + interaction.options.getInteger('page') ?? 1, + interaction.options.getInteger('pageSize') ?? 10, + ); await interaction.reply({embeds: [embed]}); } -- cgit v1.2.3 From c46153f62086a06fe6aedf240bfec9f264295565 Mon Sep 17 00:00:00 2001 From: Tiago Grosso Date: Fri, 23 Aug 2024 21:38:50 +0100 Subject: fix: fix page-size option name --- src/commands/queue.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/commands') diff --git a/src/commands/queue.ts b/src/commands/queue.ts index dcc674a..d627c7f 100644 --- a/src/commands/queue.ts +++ b/src/commands/queue.ts @@ -16,7 +16,7 @@ export default class implements Command { .setDescription('page of queue to show [default: 1]') .setRequired(false)) .addIntegerOption(option => option - .setName('pageSize') + .setName('page-size') .setDescription('how many items to display per page [default: 10]') .setRequired(false)); @@ -32,7 +32,7 @@ export default class implements Command { const embed = buildQueueEmbed( player, interaction.options.getInteger('page') ?? 1, - interaction.options.getInteger('pageSize') ?? 10, + interaction.options.getInteger('page-size') ?? 10, ); await interaction.reply({embeds: [embed]}); -- cgit v1.2.3 From 0912d957918cb93b0d0607d305fd9d92c1f1cce5 Mon Sep 17 00:00:00 2001 From: Tiago Grosso Date: Sat, 24 Aug 2024 23:08:05 +0100 Subject: feat: add setting for default queue page size --- src/commands/config.ts | 27 +++++++++++++++++++++++++++ src/commands/queue.ts | 13 ++++++++++--- 2 files changed, 37 insertions(+), 3 deletions(-) (limited to 'src/commands') diff --git a/src/commands/config.ts b/src/commands/config.ts index f866e82..c9aa0e3 100644 --- a/src/commands/config.ts +++ b/src/commands/config.ts @@ -56,6 +56,15 @@ export default class implements Command { .setMinValue(0) .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(50) + .setRequired(true))) .addSubcommand(subcommand => subcommand .setName('get') .setDescription('show all settings')); @@ -171,6 +180,23 @@ 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 'get': { const embed = new EmbedBuilder().setTitle('Config'); @@ -185,6 +211,7 @@ 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, }; let description = ''; diff --git a/src/commands/queue.ts b/src/commands/queue.ts index d627c7f..60472b0 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 { @@ -17,7 +18,9 @@ export default class implements Command { .setRequired(false)) .addIntegerOption(option => option .setName('page-size') - .setDescription('how many items to display per page [default: 10]') + .setDescription('how many items to display per page [default: 10, max: 50]') + .setMinValue(1) + .setMaxValue(50) .setRequired(false)); private readonly playerManager: PlayerManager; @@ -27,12 +30,16 @@ 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, - interaction.options.getInteger('page-size') ?? 10, + pageSize, ); await interaction.reply({embeds: [embed]}); -- cgit v1.2.3 From 8e7e12c8dfa39d4ce779b8fdcbdfd0cfe7425269 Mon Sep 17 00:00:00 2001 From: Tiago Grosso Date: Tue, 27 Aug 2024 11:11:43 +0100 Subject: fix: limit queue size to 30 --- src/commands/config.ts | 2 +- src/commands/queue.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/commands') diff --git a/src/commands/config.ts b/src/commands/config.ts index c9aa0e3..91b2578 100644 --- a/src/commands/config.ts +++ b/src/commands/config.ts @@ -63,7 +63,7 @@ export default class implements Command { .setName('page-size') .setDescription('page size of the /queue command') .setMinValue(1) - .setMaxValue(50) + .setMaxValue(30) .setRequired(true))) .addSubcommand(subcommand => subcommand .setName('get') diff --git a/src/commands/queue.ts b/src/commands/queue.ts index 60472b0..fd3674a 100644 --- a/src/commands/queue.ts +++ b/src/commands/queue.ts @@ -20,7 +20,7 @@ export default class implements Command { .setName('page-size') .setDescription('how many items to display per page [default: 10, max: 50]') .setMinValue(1) - .setMaxValue(50) + .setMaxValue(30) .setRequired(false)); private readonly playerManager: PlayerManager; -- cgit v1.2.3 From a87078c2ada84adabc8d9bb5b527feec6490e513 Mon Sep 17 00:00:00 2001 From: Harry Jenkins Date: Wed, 28 Aug 2024 16:41:12 +1000 Subject: update page-size option description to reflect maximum value of 30 --- src/commands/queue.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/commands') diff --git a/src/commands/queue.ts b/src/commands/queue.ts index fd3674a..fd36e43 100644 --- a/src/commands/queue.ts +++ b/src/commands/queue.ts @@ -18,7 +18,7 @@ export default class implements Command { .setRequired(false)) .addIntegerOption(option => option .setName('page-size') - .setDescription('how many items to display per page [default: 10, max: 50]') + .setDescription('how many items to display per page [default: 10, max: 30]') .setMinValue(1) .setMaxValue(30) .setRequired(false)); -- cgit v1.2.3 From af639159d1647ffb7b4c5c5f7ad035fe8766b6dc Mon Sep 17 00:00:00 2001 From: sofushn Date: Sat, 7 Sep 2024 13:09:45 +0200 Subject: feat: allow running without spotify --- src/commands/play.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/commands') diff --git a/src/commands/play.ts b/src/commands/play.ts index 25aef1c..7851eb7 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 {inject, injectable, optional} from 'inversify'; import Spotify from 'spotify-web-api-node'; import Command from './index.js'; import {TYPES} from '../types.js'; @@ -36,12 +36,12 @@ export default class implements Command { 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; } -- cgit v1.2.3 From 66e022489ff8caaf1d9dcdbd34c93fe702dfa024 Mon Sep 17 00:00:00 2001 From: sofushn Date: Mon, 28 Oct 2024 14:57:08 +0100 Subject: fix: Spotify URL is part of query description even when disabled --- src/commands/play.ts | 48 +++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 21 deletions(-) (limited to 'src/commands') diff --git a/src/commands/play.ts b/src/commands/play.ts index 7851eb7..c87ccd5 100644 --- a/src/commands/play.ts +++ b/src/commands/play.ts @@ -1,6 +1,6 @@ import {AutocompleteInteraction, ChatInputCommandInteraction} from 'discord.js'; import {URL} from 'url'; -import {SlashCommandBuilder} from '@discordjs/builders'; +import {SlashCommandBuilder, SlashCommandSubcommandsOnlyBuilder} from '@discordjs/builders'; import {inject, injectable, optional} from 'inversify'; import Spotify from 'spotify-web-api-node'; import Command from './index.js'; @@ -13,26 +13,7 @@ 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 & Pick; public requiresVC = true; @@ -44,6 +25,31 @@ export default class implements Command { 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 { -- cgit v1.2.3 From b42f27eba9db787c1986e9d2146f742157905e91 Mon Sep 17 00:00:00 2001 From: Hazzajenko Date: Fri, 1 Nov 2024 17:36:01 +1100 Subject: Added commands to set whether to reduce the volume when people speak and to set the target volume. --- src/commands/config.ts | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'src/commands') diff --git a/src/commands/config.ts b/src/commands/config.ts index 91b2578..01d9fe9 100644 --- a/src/commands/config.ts +++ b/src/commands/config.ts @@ -40,6 +40,22 @@ export default class implements Command { .setName('value') .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') @@ -197,6 +213,40 @@ export default class implements Command { 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'); @@ -212,6 +262,7 @@ export default class implements Command { '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 = ''; -- cgit v1.2.3