49 lines
1.4 KiB
JavaScript
49 lines
1.4 KiB
JavaScript
const name = 'cloop'
|
|
const description = 'Loops commands'
|
|
const usages = [
|
|
'add <command...>',
|
|
'remove <index>',
|
|
'list'
|
|
]
|
|
const aliases = ['cloop']
|
|
const enabled = true
|
|
|
|
const permLevel = 1
|
|
|
|
function execute (bot, cmd, player, args, handler) {
|
|
const subCommand = args.shift()
|
|
|
|
let interval, command, i, msg
|
|
switch (subCommand) {
|
|
case 'add':
|
|
interval = parseFloat(args.shift())
|
|
command = args.join(' ').replace(/u00a7.?/g, '')
|
|
bot.cloops.push({ command, interval })
|
|
|
|
bot.core.run(`/tellraw @a ${JSON.stringify([
|
|
{ text: 'Added command ', color: bot.colors.primary },
|
|
{ text: command, color: bot.colors.secondary },
|
|
' to cloops.'
|
|
])}`)
|
|
break
|
|
case 'remove':
|
|
i = parseFloat(args.shift())
|
|
bot.cloops.splice(i, 1)
|
|
|
|
bot.core.run(`/tellraw @a ${JSON.stringify([
|
|
{ text: 'Removed cloop ', color: bot.colors.primary },
|
|
{ text: i, color: bot.colors.secondary },
|
|
'.'
|
|
])}`)
|
|
break
|
|
case 'list':
|
|
msg = [{ text: 'Cloops: \n', color: bot.colors.primary }]
|
|
for (const i in bot.cloops) {
|
|
msg.push({ text: `${i}: ` })
|
|
msg.push({ text: `${bot.cloops[i].command}\n`, color: bot.colors.secondary })
|
|
}
|
|
bot.core.run(`/tellraw @a ${JSON.stringify(msg)}`)
|
|
}
|
|
}
|
|
|
|
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }
|