Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Commit

Permalink
loop実装
Browse files Browse the repository at this point in the history
  • Loading branch information
ringo360 committed May 31, 2024
1 parent 5e45ffa commit ad2913e
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
9 changes: 9 additions & 0 deletions language/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,15 @@
},
"defaultTitle": "${0}'s graph"
},
"loop": {
"name": "loop",
"description": "音楽をループ再生します。",
"mode": {
"track": "現在の曲をループ再生します!",
"queue": "キュー内の曲をループ再生します!",
"off": "ループ再生をオフにしました!"
}
},
"mcSrvlookup": {
"name": "mcsrv_record",
"description": "Lookup SRV Record",
Expand Down
44 changes: 44 additions & 0 deletions packages/player/commands/loop.ts
Original file line number Diff line number Diff line change
@@ -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
}
*/

0 comments on commit ad2913e

Please sign in to comment.