botv12/commands/filter.js

92 lines
2.1 KiB
JavaScript
Raw Permalink Normal View History

2025-07-19 19:21:50 -04:00
async function 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()
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
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({
2025-04-25 04:50:38 -04:00
text: 'command.filter.error.notFound',
parseLang: true,
color: '$error'
2025-02-12 15:49:05 -05:00
})
return
}
} else {
playerName = c.bot.findRealNameFromUUID(command)
uuid = command
}
2025-04-25 04:50:38 -04:00
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({
2025-04-25 04:50:38 -04:00
text: 'command.filter.error.filtered',
parseLang: true,
color: '$error'
2025-02-12 15:49:05 -05:00
})
return
}
2025-04-25 05:15:49 -04:00
2025-02-12 15:49:05 -05:00
c.reply({
2025-04-25 04:50:38 -04:00
text: 'command.filter.success.add',
parseLang: true,
2025-02-12 15:49:05 -05:00
with: [
2025-04-25 04:50:38 -04:00
command,
playerName
2025-02-12 15:49:05 -05:00
]
})
break
}
case 'remove': {
c.bot.removeFilter(c.args[0])
c.reply({
2025-04-25 04:50:38 -04:00
text: 'command.filter.success.remove',
parseLang: true,
2025-02-12 15:49:05 -05:00
with: [
2025-04-25 04:50:38 -04:00
c.args[0]
2025-02-12 15:49:05 -05:00
]
})
break
}
case 'list':
c.bot.filteredPlayers.forEach(item => {
c.reply({
2025-04-25 04:50:38 -04:00
text: 'command.filter.list',
parseLang: true,
2025-02-12 15:49:05 -05:00
with: [
2025-04-25 04:50:38 -04:00
item.username,
item.uuid
2025-02-12 15:49:05 -05:00
]
})
})
break
case 'clear':
2025-07-15 14:55:23 -04:00
c.bot.filteredPlayers = [] // Unlike cloop, filters don't use setInterval several times
2025-02-12 15:49:05 -05:00
c.reply({
2025-07-15 14:55:23 -04:00
text: 'command.filter.success.clear',
2025-04-25 05:15:49 -04:00
parseLang: true
2025-02-12 15:49:05 -05:00
})
break
default:
c.reply({
2025-04-25 04:50:38 -04:00
text: 'command.error.subcommand',
parseLang: true,
2025-02-12 15:49:05 -05:00
with: [
2025-04-25 04:50:38 -04:00
`${c.prefix}help filter`
2025-02-12 15:49:05 -05:00
]
})
}
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 }