Pass message type to commands
This commit is contained in:
parent
9fe7bfd3f7
commit
5f0c8a99e1
4 changed files with 13 additions and 5 deletions
|
@ -157,7 +157,13 @@ module.exports = {
|
|||
uuid = b.findUUID(username)
|
||||
message = split.join(': ')
|
||||
}
|
||||
b.emit('chat', { json, type: 'legacy', uuid: data.uuid ? data.uuid : uuid, message, username })
|
||||
b.emit('chat', {
|
||||
json,
|
||||
type: 'legacy',
|
||||
uuid: data.uuid ? data.uuid : uuid,
|
||||
message,
|
||||
username
|
||||
})
|
||||
})
|
||||
|
||||
b.on('chat', (data) => {
|
||||
|
@ -173,7 +179,7 @@ module.exports = {
|
|||
for (const i in b.prefix) {
|
||||
if (fullCommand.startsWith(b.prefix[i])) {
|
||||
const command = fullCommand.slice(b.prefix[i].length)
|
||||
b.runCommand(data.username, data.nickname, data.uuid, command, b.prefix[i])
|
||||
b.runCommand(data.username, data.nickname, data.uuid, command, data.type, b.prefix[i])
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -18,7 +18,7 @@ module.exports = {
|
|||
load: (b) => {
|
||||
b.prefix = settings.prefix
|
||||
b.lastCmd = 0
|
||||
b.runCommand = (name, nickname, uuid, text, prefix) => {
|
||||
b.runCommand = (name, nickname, uuid, text, msgType, prefix) => {
|
||||
if (uuid === '00000000-0000-0000-0000-000000000000') return
|
||||
if (Date.now() - b.lastCmd <= 1000) return
|
||||
const userSettings = loadSettings(uuid)
|
||||
|
@ -45,7 +45,7 @@ module.exports = {
|
|||
return
|
||||
}
|
||||
try {
|
||||
cmds[cmd[0].toLowerCase()].execute(new Command(uuid, name, nickname, text, prefix, b, verify, userSettings))
|
||||
cmds[cmd[0].toLowerCase()].execute(new Command(uuid, name, nickname, text, msgType, prefix, b, verify, userSettings))
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
b.tellraw(uuid, {
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
const settings = require('../settings.json')
|
||||
class Command {
|
||||
constructor (uuid, user, nick, cmd, prefix, bot, verify, prefs) {
|
||||
constructor (uuid, user, nick, cmd, msgType, prefix, bot, verify, prefs) {
|
||||
this.send = (text, uuid) => { bot.tellraw(uuid || '@a', text) }
|
||||
this.reply = text => bot.tellraw(uuid, text)
|
||||
this.uuid = uuid
|
||||
this.username = user
|
||||
this.nickname = nick
|
||||
this.command = cmd
|
||||
this.msgType = msgType;
|
||||
this.prefix = prefix
|
||||
this.bot = bot
|
||||
this.type = 'minecraft'
|
||||
|
|
|
@ -10,6 +10,7 @@ class ConsoleCommand {
|
|||
this.username = 'Owner'
|
||||
this.nickname = 'Console'
|
||||
this.command = cmd
|
||||
this.msgType = "_bot_console";
|
||||
this.prefix = '' // prefix does not exist at console
|
||||
this.bot = index2 >= 0
|
||||
? index.bot[index2]
|
||||
|
|
Loading…
Reference in a new issue