clear chat queue fix

This commit is contained in:
ChomeNS 2022-12-05 16:54:50 +07:00
parent ddb1dbd32c
commit 666cc2491f
2 changed files with 9 additions and 7 deletions

View file

@ -5,13 +5,15 @@ module.exports = {
usage: '', usage: '',
trusted: 0, trusted: 0,
execute (bot) { execute (bot) {
if (bot.queue[0]) { if (bot._chatQueue[0]) {
bot.chatQueue = [] bot.chatQueue = []
bot._chatQueue = []
} }
}, },
discordExecute (bot) { discordExecute (bot) {
if (bot.queue[0]) { if (bot._chatQueue[0]) {
bot.chatQueue = [] bot.chatQueue = []
bot._chatQueue = []
} }
} }
} }

View file

@ -6,7 +6,7 @@ const { chatPacketListener, parsePlayerMessages } = require('../util/chat')
function inject (bot, dcclient, config) { function inject (bot, dcclient, config) {
bot.chatQueue = [] bot.chatQueue = []
const _chatQueue = [] bot._chatQueue = []
const _chatQueueInterval = setInterval(() => { const _chatQueueInterval = setInterval(() => {
if (bot.chatQueue.length !== 0) { if (bot.chatQueue.length !== 0) {
@ -20,7 +20,7 @@ function inject (bot, dcclient, config) {
let smallMsg let smallMsg
for (let i = 0; i < subMessage.length; i += config.chat.messageLength) { for (let i = 0; i < subMessage.length; i += config.chat.messageLength) {
smallMsg = subMessage.substring(i, i + config.chat.messageLength) smallMsg = subMessage.substring(i, i + config.chat.messageLength)
_chatQueue.push(smallMsg) bot._chatQueue.push(smallMsg)
} }
}) })
bot.chatQueue.shift() bot.chatQueue.shift()
@ -28,9 +28,9 @@ function inject (bot, dcclient, config) {
}, 0) }, 0)
const chatQueueInterval = setInterval(function () { const chatQueueInterval = setInterval(function () {
if (_chatQueue.length !== 0) { if (bot._chatQueue.length !== 0) {
bot.write('chat', { message: _chatQueue[0] }) bot.write('chat', { message: bot._chatQueue[0] })
_chatQueue.shift() bot._chatQueue.shift()
} }
}, 450) }, 450)