From ad2913ed54d21d420ddb46d19020d376e67d2aee Mon Sep 17 00:00:00 2001 From: ringoXD Date: Fri, 31 May 2024 23:56:38 +0900 Subject: [PATCH 1/3] =?UTF-8?q?loop=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- language/default.json | 9 +++++++ packages/player/commands/loop.ts | 44 ++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 packages/player/commands/loop.ts diff --git a/language/default.json b/language/default.json index d9128d8..5230101 100644 --- a/language/default.json +++ b/language/default.json @@ -434,6 +434,15 @@ }, "defaultTitle": "${0}'s graph" }, + "loop": { + "name": "loop", + "description": "音楽をループ再生します。", + "mode": { + "track": "現在の曲をループ再生します!", + "queue": "キュー内の曲をループ再生します!", + "off": "ループ再生をオフにしました!" + } + }, "mcSrvlookup": { "name": "mcsrv_record", "description": "Lookup SRV Record", diff --git a/packages/player/commands/loop.ts b/packages/player/commands/loop.ts new file mode 100644 index 0000000..6489757 --- /dev/null +++ b/packages/player/commands/loop.ts @@ -0,0 +1,44 @@ +import { SlashCommandBuilder } from 'discord.js'; +import { LANG } from 'core'; +import { PlayerCommand } from '../PlayerCommand'; +import { QueueRepeatMode } from 'discord-player'; + +module.exports = new PlayerCommand( + new SlashCommandBuilder() + .setName(LANG.commands.loop.name) + .setDescription(LANG.commands.loop.description), + + async function (interaction, queue) { + try { + if (queue.repeatMode == QueueRepeatMode.OFF) { + queue.setRepeatMode(QueueRepeatMode.TRACK); + await interaction.reply(LANG.commands.loop.mode.track); + return; + } + if (queue.repeatMode == QueueRepeatMode.TRACK) { + queue.setRepeatMode(QueueRepeatMode.QUEUE); + await interaction.reply(LANG.commands.loop.mode.queue); + return; + } + if (queue.repeatMode == QueueRepeatMode.QUEUE) { + queue.setRepeatMode(QueueRepeatMode.OFF); + await interaction.reply(LANG.commands.loop.mode.off); + return; + } + } catch (e) { + await interaction.reply(`Something went wrong: ${e}`); + return; + } + }, +); + +/* + +declare enum QueueRepeatMode { + OFF = 0, + TRACK = 1, + QUEUE = 2, + AUTOPLAY = 3 +} + +*/ From 2f1a37cda0f9633abdc7d63fea09472c849864b3 Mon Sep 17 00:00:00 2001 From: ringoXD Date: Sat, 1 Jun 2024 00:02:52 +0900 Subject: [PATCH 2/3] devlog lol --- packages/player/commands/loop.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/player/commands/loop.ts b/packages/player/commands/loop.ts index 6489757..d592ade 100644 --- a/packages/player/commands/loop.ts +++ b/packages/player/commands/loop.ts @@ -3,6 +3,8 @@ import { LANG } from 'core'; import { PlayerCommand } from '../PlayerCommand'; import { QueueRepeatMode } from 'discord-player'; +console.log('CALLED LOOP'); + module.exports = new PlayerCommand( new SlashCommandBuilder() .setName(LANG.commands.loop.name) From d2262f996f35b2b22bf5475244673411d59026d5 Mon Sep 17 00:00:00 2001 From: ringoXD Date: Sat, 1 Jun 2024 00:06:04 +0900 Subject: [PATCH 3/3] oopsie, I forgot --- packages/player/commands/loop.ts | 2 -- packages/player/index.ts | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/player/commands/loop.ts b/packages/player/commands/loop.ts index d592ade..6489757 100644 --- a/packages/player/commands/loop.ts +++ b/packages/player/commands/loop.ts @@ -3,8 +3,6 @@ import { LANG } from 'core'; import { PlayerCommand } from '../PlayerCommand'; import { QueueRepeatMode } from 'discord-player'; -console.log('CALLED LOOP'); - module.exports = new PlayerCommand( new SlashCommandBuilder() .setName(LANG.commands.loop.name) diff --git a/packages/player/index.ts b/packages/player/index.ts index 052b938..3d0462a 100644 --- a/packages/player/index.ts +++ b/packages/player/index.ts @@ -37,6 +37,7 @@ class PlayerFeature extends Feature { require('./commands/skip'), require('./commands/stop'), require('./commands/volume'), + require('./commands/loop'), ]); player.events.on('playerStart', (queue, track) => {