mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-27 01:25:33 -05:00
change hashing check in cmd handler a bit
idk a rewrite already exist but idk idk
This commit is contained in:
parent
bade4a4b89
commit
e6773a9f62
2 changed files with 40 additions and 13 deletions
|
@ -1,16 +1,14 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'validate',
|
name: 'validate',
|
||||||
description: 'Validates hash',
|
description: 'Validates a hash',
|
||||||
alias: [],
|
alias: ['checkhash'],
|
||||||
usage: '<hash>',
|
usage: '<hash|ownerHash>',
|
||||||
trusted: 1,
|
trusted: 1,
|
||||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
if (args[0] === hash) {
|
if (args[0] === hash) {
|
||||||
bot.tellraw(selector, { text: 'Valid hash', color: 'green' })
|
bot.tellraw(selector, { text: 'Valid hash', color: 'green' })
|
||||||
} else if (args[0] === ownerhash) {
|
} else if (args[0] === ownerhash) {
|
||||||
bot.tellraw(selector, { text: 'Valid OwnerHash', color: 'green' })
|
bot.tellraw(selector, { text: 'Valid OwnerHash', color: 'green' })
|
||||||
} else {
|
|
||||||
bot.tellraw(selector, { text: 'Invalid hash', color: 'red' })
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,20 +25,49 @@ function inject (bot, dcclient, config) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const alias = bot.command_handler.commands.find((command) => command.alias.includes(commandName.toLowerCase()))
|
const alias = bot.command_handler.commands.find((command) => command.alias.includes(commandName.toLowerCase()))
|
||||||
if (alias) command = bot.command_handler.commands.find((command) => command.alias.includes(commandName.toLowerCase()))
|
if (alias) command = alias
|
||||||
|
|
||||||
if (prefix === '*' && message.endsWith('*') && message !== '*') return
|
if (prefix === '*' && message.endsWith('*') && message !== '*') return
|
||||||
if (!command) throw new Error(`Unknown command: "${commandName}"`)
|
if (!command) throw new Error(`Unknown command: "${commandName}"`)
|
||||||
|
|
||||||
if (command.name !== 'validate' && command.trusted === 1) {
|
if (command.trusted > 0) {
|
||||||
if (discord && !message.member?.roles?.cache?.some((role) => role.name === 'Trusted')) throw new Error('You\'re not in the trusted role!')
|
const discordRoles = message.member?.roles?.cache // do i need the "?"s ?
|
||||||
else if (!discord && args[0] !== hash) throw new Error('Invalid hash')
|
|
||||||
} else if (command.name !== 'validate' && command.trusted === 2) {
|
// TODO: Don't hardcode the roles
|
||||||
if (discord && !message.member?.roles?.cache?.some((role) => role.name === 'ChomeNS')) throw new Error('You\'re not in the owner of this bot!')
|
|
||||||
else if (!discord && args[0] !== ownerhash) throw new Error('Invalid OwnerHash')
|
// trusted and host
|
||||||
|
// discord
|
||||||
|
if (
|
||||||
|
discord &&
|
||||||
|
command.trusted === 1 &&
|
||||||
|
!discordRoles.some((role) => role.name === 'Trusted' || role.name === 'Host')
|
||||||
|
) throw new Error('You\'re not in the trusted role!')
|
||||||
|
// in game
|
||||||
|
if (
|
||||||
|
!discord &&
|
||||||
|
command.trusted === 1 &&
|
||||||
|
args[0] !== hash &&
|
||||||
|
args[0] !== ownerhash
|
||||||
|
|
||||||
|
) throw new Error('Invalid hash')
|
||||||
|
|
||||||
|
// host only (yup i changed, owner doesn't exist anymore (kinda, we still call it ownerHash™))
|
||||||
|
// discord
|
||||||
|
if (
|
||||||
|
discord &&
|
||||||
|
command.trusted === 2 &&
|
||||||
|
!discordRoles.some((role) => role.name === 'Host')
|
||||||
|
) throw new Error('You\'re not in the host role!')
|
||||||
|
// in game
|
||||||
|
if (
|
||||||
|
!discord &&
|
||||||
|
command.trusted === 2 &&
|
||||||
|
args[0] !== ownerhash
|
||||||
|
) throw new Error('Invalid OwnerHash')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prefix === config.discord.prefix) {
|
if (prefix === config.discord.prefix) {
|
||||||
if (!command.discordExecute) throw new Error('This command is not yet supported on discord!')
|
if (!command.discordExecute) throw new Error('This command is not yet supported on Discord!')
|
||||||
command.discordExecute(bot, username, sender, prefix, args, channeldc, message, config)
|
command.discordExecute(bot, username, sender, prefix, args, channeldc, message, config)
|
||||||
} else {
|
} else {
|
||||||
command.execute(bot, username, sender, prefix, args, config, hash, ownerhash, selector)
|
command.execute(bot, username, sender, prefix, args, config, hash, ownerhash, selector)
|
||||||
|
|
Loading…
Reference in a new issue