43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import { SlashCommandBuilder } from 'discord.js'
|
|
import { bot } from '../../index'
|
|
import { i18n } from '../../utils/i18n'
|
|
import { canModifyQueue } from '../../utils/queue'
|
|
import { SlashCommand } from '../../sturctures/command'
|
|
|
|
export const command: SlashCommand = {
|
|
slashData: new SlashCommandBuilder()
|
|
.setName('loop')
|
|
.setDescription(i18n.__('loop.description')),
|
|
run: (itd) => {
|
|
const { interaction }: any = itd
|
|
const queue = bot.queues.get(interaction.guild!.id)
|
|
|
|
const guildMemer = interaction.guild!.members.cache.get(
|
|
interaction.user.id
|
|
)
|
|
|
|
if (!queue)
|
|
return interaction
|
|
.reply({
|
|
content: i18n.__('loop.errorNotQueue'),
|
|
ephemeral: true,
|
|
})
|
|
.catch(console.error)
|
|
|
|
if (!guildMemer || !canModifyQueue(guildMemer))
|
|
return i18n.__('common.errorNotChannel')
|
|
|
|
queue.loop = !queue.loop
|
|
|
|
const content = {
|
|
content: i18n.__mf('loop.result', {
|
|
loop: queue.loop ? i18n.__('common.on') : i18n.__('common.off'),
|
|
}),
|
|
}
|
|
|
|
if (interaction.replied)
|
|
interaction.followUp(content).catch(console.error)
|
|
else interaction.reply(content).catch(console.error)
|
|
},
|
|
}
|