added loop
This commit is contained in:
@@ -7,6 +7,7 @@ import queue from "./queue"
|
||||
import resume from "./resume"
|
||||
import skip from "./skip"
|
||||
import stop from "./stop"
|
||||
import loop from "./loop"
|
||||
|
||||
export const commands: { [key: string]: Command } = {
|
||||
ping,
|
||||
@@ -18,5 +19,6 @@ export const commands: { [key: string]: Command } = {
|
||||
stop,
|
||||
pause,
|
||||
skip,
|
||||
loop,
|
||||
}
|
||||
|
||||
|
||||
34
src/commands/loop.ts
Normal file
34
src/commands/loop.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { CacheType, ChatInputCommandInteraction, SlashCommandBuilder } from 'discord.js';
|
||||
import { toggleLoop } from '../playback';
|
||||
import { formatFilePath } from '../util/downloader'
|
||||
|
||||
|
||||
const name = "loop"
|
||||
|
||||
function register() {
|
||||
return new SlashCommandBuilder()
|
||||
.setName(name)
|
||||
.setDescription('loop current song')
|
||||
}
|
||||
|
||||
async function execute(interaction: ChatInputCommandInteraction<CacheType>) {
|
||||
try {
|
||||
await interaction.deferReply()
|
||||
const audio = toggleLoop()
|
||||
if (audio) {
|
||||
await interaction.editReply(`looped ${formatFilePath(audio.url)}`);
|
||||
}
|
||||
else {
|
||||
await interaction.editReply(`Loop turned off`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
await interaction.reply('Coś poszło nie tak :/');
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
name,
|
||||
register,
|
||||
execute
|
||||
}
|
||||
Reference in New Issue
Block a user