Stop was advancing the queue, history overwrote the day file, and slash commands often never replied; soundboard clips now mix on top of the current track. Co-authored-by: Cursor <cursoragent@cursor.com>
39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
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.path)}`);
|
|
}
|
|
else {
|
|
await interaction.editReply(`Loop turned off`);
|
|
}
|
|
} catch (error) {
|
|
console.error(error);
|
|
if (interaction.deferred || interaction.replied) {
|
|
await interaction.editReply('Coś poszło nie tak :/');
|
|
} else {
|
|
await interaction.reply('Coś poszło nie tak :/');
|
|
}
|
|
}
|
|
}
|
|
|
|
export default {
|
|
name,
|
|
register,
|
|
execute
|
|
}
|