botv12/commands/filter.js

107 lines
2.7 KiB
JavaScript
Raw Permalink Normal View History

2025-02-06 00:34:04 -05:00
import { getMessage } from '../util/lang.js'
2025-02-14 01:06:21 -05:00
const execute = c => {
2025-02-12 15:49:05 -05:00
let subcmd
if (c.args.length >= 1) subcmd = c.args.splice(0, 1)[0].toLowerCase()
console.log(subcmd)
console.log(c.args)
switch (subcmd) {
case 'add': {
const command = c.args.join(' ')
2025-02-12 16:04:02 -05:00
let playerName
let uuid
2025-02-12 15:49:05 -05:00
console.log(command)
if (!/[a-f\d]{8}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{12}/.test(command)) {
playerName = command
uuid = c.bot.findUUID(playerName)
2025-04-06 03:14:09 -04:00
if (uuid === '00000000-0000-0000-0000-000000000000') {
2025-02-12 15:49:05 -05:00
c.reply({
text: getMessage(c.lang, 'command.filter.error.notFound')
})
return
}
} else {
playerName = c.bot.findRealNameFromUUID(command)
uuid = command
}
2025-02-12 16:04:02 -05:00
if (!c.bot.isFiltered(command)) {
2025-02-12 15:49:05 -05:00
playerName = c.bot.findRealNameFromUUID(command)
c.bot.addFilter(uuid, playerName)
} else {
c.reply({
text: getMessage(c.lang, 'command.filter.error.filtered')
})
return
}
c.reply({
translate: getMessage(c.lang, 'command.filter.success.add'),
color: c.colors.secondary,
with: [
{
text: command,
color: c.colors.primary
},
{
text: playerName,
color: c.colors.primary
}
]
})
break
}
case 'remove': {
c.bot.removeFilter(c.args[0])
c.reply({
translate: getMessage(c.lang, 'command.filter.success.remove'),
color: c.colors.secondary,
with: [
{
text: c.args[0],
color: c.colors.primary
}
]
})
break
}
case 'list':
c.bot.filteredPlayers.forEach(item => {
c.reply({
translate: getMessage(c.lang, 'command.filter.list'),
color: c.colors.secondary,
with: [
{
text: item.username,
color: c.colors.primary
},
{
text: item.uuid,
color: c.colors.primary
}
]
})
})
break
case 'clear':
2025-02-12 16:04:02 -05:00
// c.bot.clearCloops()
2025-02-12 15:49:05 -05:00
c.reply({
text: getMessage(c.lang, 'Not implemented')
})
break
default:
c.reply({
2025-04-06 03:14:09 -04:00
translate: getMessage(c.lang, 'command.error.subcommand'),
2025-02-12 15:49:05 -05:00
color: c.colors.secondary,
with: [
{
text: `${c.prefix}help filter`,
color: c.colors.primary
}
]
})
}
2025-02-06 00:34:04 -05:00
}
2025-02-12 15:49:05 -05:00
2025-04-11 23:41:53 -04:00
const level = 1
2025-02-12 16:04:02 -05:00
const aliases = ['blacklist']
2025-02-12 15:49:05 -05:00
const consoleIndex = true
2025-04-06 03:14:09 -04:00
export { execute, level, consoleIndex, aliases }