2024-09-11 02:02:29 -04:00
|
|
|
const cmds = require('../util/commands.js')
|
|
|
|
const { getMessage } = require('../util/lang.js')
|
|
|
|
const hashcheck = require('../util/hashcheck.js')
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
load: (b) => {
|
2024-09-12 00:26:36 -04:00
|
|
|
b.on('command', c => {
|
2024-09-11 02:02:29 -04:00
|
|
|
const cmd = c.command.split(' ')
|
|
|
|
const command = cmds[c.cmdName.toLowerCase()]
|
|
|
|
const verify = hashcheck(cmd, c.uuid)
|
|
|
|
const permsN = getMessage(c.lang, 'command.help.permsNormal')
|
|
|
|
const permsT = getMessage(c.lang, 'command.help.permsTrusted')
|
|
|
|
const permsO = getMessage(c.lang, 'command.help.permsOwner')
|
2024-09-11 23:38:55 -04:00
|
|
|
if (command && command.level !== undefined && command.level > verify) {
|
2024-09-11 02:02:29 -04:00
|
|
|
b.tellraw(c.uuid, {
|
|
|
|
text: getMessage(c.lang, 'command.disallowed.perms')
|
|
|
|
})
|
|
|
|
b.tellraw(c.uuid, {
|
|
|
|
text: getMessage(c.lang, 'command.disallowed.perms.yourLevel', [[permsN, permsT, permsO][verify]])
|
|
|
|
})
|
|
|
|
b.tellraw(c.uuid, {
|
|
|
|
text: getMessage(c.lang, 'command.disallowed.perms.cmdLevel', [[permsN, permsT, permsO][command.level]])
|
|
|
|
})
|
|
|
|
c.cancel = true
|
|
|
|
} else if (verify > 0) {
|
|
|
|
c.rewriteCommand(cmd.slice(0, cmd.length - 1).join(' '))
|
2024-09-12 00:26:36 -04:00
|
|
|
c.verify = verify
|
2024-09-11 02:02:29 -04:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|