From fcc8d8881aa338c5011f1173ad2d16efa13591c3 Mon Sep 17 00:00:00 2001 From: MarcoCoreDuo <90222533+MarcoCoreDuo@users.noreply.github.com> Date: Thu, 18 Jul 2024 06:32:16 +0200 Subject: Switch to Distube's ytdl-core fork (resolves playback issue) (#1042) --- src/services/player.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/services/player.ts b/src/services/player.ts index 0da80a4..5e284a6 100644 --- a/src/services/player.ts +++ b/src/services/player.ts @@ -1,7 +1,7 @@ import {VoiceChannel, Snowflake} from 'discord.js'; import {Readable} from 'stream'; import hasha from 'hasha'; -import ytdl, {videoFormat} from 'ytdl-core'; +import ytdl, {videoFormat} from '@distube/ytdl-core'; import {WriteStream} from 'fs-capacitor'; import ffmpeg from 'fluent-ffmpeg'; import shuffle from 'array-shuffle'; @@ -280,8 +280,8 @@ export default class { if (this.getCurrent() && this.status !== STATUS.PAUSED) { await this.play(); } else { - this.audioPlayer?.stop(true); this.status = STATUS.IDLE; + this.audioPlayer?.stop(true); const settings = await getGuildSettings(this.guildId); -- cgit v1.2.3 From 62b1abcba04c776f2a7f8c53478bf4be47011516 Mon Sep 17 00:00:00 2001 From: Son Roy Almerol Date: Thu, 18 Jul 2024 00:43:26 -0400 Subject: Switch from node-ytsr to Distube's fork (#1024) Co-authored-by: Max Isom --- src/services/youtube-api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/services/youtube-api.ts b/src/services/youtube-api.ts index b7d68b9..143033a 100644 --- a/src/services/youtube-api.ts +++ b/src/services/youtube-api.ts @@ -1,7 +1,7 @@ import {inject, injectable} from 'inversify'; import {toSeconds, parse} from 'iso8601-duration'; import got, {Got} from 'got'; -import ytsr, {Video} from 'ytsr'; +import ytsr, {Video} from '@distube/ytsr'; import PQueue from 'p-queue'; import {SongMetadata, QueuedPlaylist, MediaSource} from './player.js'; import {TYPES} from '../types.js'; -- cgit v1.2.3 From d7261260a3eb6bbe8f5af50dda215ef7b501a8ab Mon Sep 17 00:00:00 2001 From: MintyFreshers Date: Thu, 18 Jul 2024 05:47:01 +0100 Subject: Added skip currently playing track option into the /play options. (#1046) Co-authored-by: Max Isom --- src/commands/favorites.ts | 6 +++++- src/commands/play.ts | 6 +++++- src/services/add-query-to-queue.ts | 14 ++++++++++++-- 3 files changed, 22 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/commands/favorites.ts b/src/commands/favorites.ts index f00c96f..d635826 100644 --- a/src/commands/favorites.ts +++ b/src/commands/favorites.ts @@ -28,7 +28,10 @@ export default class implements Command { .setDescription('shuffle the input if you\'re adding multiple tracks')) .addBooleanOption(option => option .setName('split') - .setDescription('if a track has chapters, split it'))) + .setDescription('if a track has chapters, split it')) + .addBooleanOption(option => option + .setName('skip') + .setDescription('skip the currently playing track'))) .addSubcommand(subcommand => subcommand .setName('list') .setDescription('list all favorites')) @@ -124,6 +127,7 @@ export default class implements Command { shuffleAdditions: interaction.options.getBoolean('shuffle') ?? false, addToFrontOfQueue: interaction.options.getBoolean('immediate') ?? false, shouldSplitChapters: interaction.options.getBoolean('split') ?? false, + skipCurrentTrack: interaction.options.getBoolean('skip') ?? false, }); } diff --git a/src/commands/play.ts b/src/commands/play.ts index 65f28d4..25aef1c 100644 --- a/src/commands/play.ts +++ b/src/commands/play.ts @@ -29,7 +29,10 @@ export default class implements Command { .setDescription('shuffle the input if you\'re adding multiple tracks')) .addBooleanOption(option => option .setName('split') - .setDescription('if a track has chapters, split it')); + .setDescription('if a track has chapters, split it')) + .addBooleanOption(option => option + .setName('skip') + .setDescription('skip the currently playing track')); public requiresVC = true; @@ -52,6 +55,7 @@ export default class implements Command { addToFrontOfQueue: interaction.options.getBoolean('immediate') ?? false, shuffleAdditions: interaction.options.getBoolean('shuffle') ?? false, shouldSplitChapters: interaction.options.getBoolean('split') ?? false, + skipCurrentTrack: interaction.options.getBoolean('skip') ?? false, }); } diff --git a/src/services/add-query-to-queue.ts b/src/services/add-query-to-queue.ts index 2b84b63..401ad90 100644 --- a/src/services/add-query-to-queue.ts +++ b/src/services/add-query-to-queue.ts @@ -38,12 +38,14 @@ export default class AddQueryToQueue { addToFrontOfQueue, shuffleAdditions, shouldSplitChapters, + skipCurrentTrack, interaction, }: { query: string; addToFrontOfQueue: boolean; shuffleAdditions: boolean; shouldSplitChapters: boolean; + skipCurrentTrack: boolean; interaction: ChatInputCommandInteraction; }): Promise { const guildId = interaction.guild!.id; @@ -169,6 +171,14 @@ export default class AddQueryToQueue { await player.play(); } + if (skipCurrentTrack) { + try { + await player.forward(1); + } catch (_: unknown) { + throw new Error('no song to skip to'); + } + } + // Build response message if (statusMsg !== '') { if (extraMsg === '') { @@ -183,9 +193,9 @@ export default class AddQueryToQueue { } if (newSongs.length === 1) { - await interaction.editReply(`u betcha, **${firstSong.title}** added to the${addToFrontOfQueue ? ' front of the' : ''} queue${extraMsg}`); + await interaction.editReply(`u betcha, **${firstSong.title}** added to the${addToFrontOfQueue ? ' front of the' : ''} queue${skipCurrentTrack ? 'and current track skipped' : ''}${extraMsg}`); } else { - await interaction.editReply(`u betcha, **${firstSong.title}** and ${newSongs.length - 1} other songs were added to the queue${extraMsg}`); + await interaction.editReply(`u betcha, **${firstSong.title}** and ${newSongs.length - 1} other songs were added to the queue${skipCurrentTrack ? 'and current track skipped' : ''}${extraMsg}`); } } -- cgit v1.2.3 From e494287d1d4e220c98856ac1c5c3a34231debe7f Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sat, 17 Aug 2024 20:22:57 -0700 Subject: Update Docker builds to publish to ghcr.io & update README (#1067) --- src/events/guild-create.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/events/guild-create.ts b/src/events/guild-create.ts index 1d60910..c903009 100644 --- a/src/events/guild-create.ts +++ b/src/events/guild-create.ts @@ -40,5 +40,5 @@ export default async (guild: Guild): Promise => { } const owner = await guild.fetchOwner(); - await owner.send('👋 Hi! Someone (probably you) just invited me to a server you own. By default, I\'m usable by all guild member in all guild channels. To change this, check out the wiki page on permissions: https://github.com/codetheweb/muse/wiki/Configuring-Bot-Permissions.'); + await owner.send('👋 Hi! Someone (probably you) just invited me to a server you own. By default, I\'m usable by all guild member in all guild channels. To change this, check out the wiki page on permissions: https://github.com/museofficial/muse/wiki/Configuring-Bot-Permissions.'); }; -- cgit v1.2.3 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 +++++++++- src/utils/build-embed.ts | 10 ++++------ 2 files changed, 13 insertions(+), 7 deletions(-) (limited to 'src') 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]}); } diff --git a/src/utils/build-embed.ts b/src/utils/build-embed.ts index b8e725c..23db0b9 100644 --- a/src/utils/build-embed.ts +++ b/src/utils/build-embed.ts @@ -5,8 +5,6 @@ import getProgressBar from './get-progress-bar.js'; import {prettyTime} from './time.js'; import {truncate} from './string.js'; -const PAGE_SIZE = 10; - const getMaxSongTitleLength = (title: string) => { // eslint-disable-next-line no-control-regex const nonASCII = /[^\x00-\x7F]+/; @@ -77,7 +75,7 @@ export const buildPlayingMessageEmbed = (player: Player): EmbedBuilder => { return message; }; -export const buildQueueEmbed = (player: Player, page: number): EmbedBuilder => { +export const buildQueueEmbed = (player: Player, page: number, pageSize: number): EmbedBuilder => { const currentlyPlaying = player.getCurrent(); if (!currentlyPlaying) { @@ -85,14 +83,14 @@ export const buildQueueEmbed = (player: Player, page: number): EmbedBuilder => { } const queueSize = player.queueSize(); - const maxQueuePage = Math.ceil((queueSize + 1) / PAGE_SIZE); + const maxQueuePage = Math.ceil((queueSize + 1) / pageSize); if (page > maxQueuePage) { throw new Error('the queue isn\'t that big'); } - const queuePageBegin = (page - 1) * PAGE_SIZE; - const queuePageEnd = queuePageBegin + PAGE_SIZE; + const queuePageBegin = (page - 1) * pageSize; + const queuePageEnd = queuePageBegin + pageSize; const queuedSongs = player .getQueue() .slice(queuePageBegin, queuePageEnd) -- 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') 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') 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') 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') 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