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 +} + +*/ 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) => {