mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-23 07:38:00 -05:00
idk just use for loop and not forEach
i see its faster so i use it
This commit is contained in:
parent
a5d34e6411
commit
508b6a64c7
10 changed files with 19 additions and 19 deletions
|
@ -17,7 +17,7 @@ module.exports = {
|
|||
let primary = true
|
||||
const message = []
|
||||
|
||||
listed.forEach((value) => {
|
||||
for (const value of listed) {
|
||||
message.push({
|
||||
text: value + ' ',
|
||||
color: (!((primary = !primary)) ? 'gold' : 'yellow'),
|
||||
|
@ -26,7 +26,7 @@ module.exports = {
|
|||
value: `${prefix}cowsay ${value} `
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
bot.tellraw(selector, message)
|
||||
} else {
|
||||
|
|
|
@ -22,11 +22,11 @@ module.exports = {
|
|||
usage.push({ text: `${prefix}${command.name} `, color: 'gold' })
|
||||
usage.push({ text: command.usage, color: 'aqua' })
|
||||
} else {
|
||||
command.usage.forEach((value) => {
|
||||
for (const value of command.usage) {
|
||||
usage.push({ text: `${prefix}${command.name} `, color: 'gold' })
|
||||
usage.push({ text: value, color: 'aqua' })
|
||||
usage.push('\n')
|
||||
})
|
||||
}
|
||||
usage.pop()
|
||||
}
|
||||
|
||||
|
|
|
@ -249,7 +249,7 @@ module.exports = {
|
|||
break
|
||||
case 'queue':
|
||||
const queueWithName = []
|
||||
bot.music.queue.forEach((song) => queueWithName.push(song.name))
|
||||
for (const song of bot.music.queue) queueWithName.push(song.name)
|
||||
bot.tellraw(selector, [
|
||||
{
|
||||
text: 'Queue: ',
|
||||
|
@ -338,7 +338,7 @@ module.exports = {
|
|||
break
|
||||
case 'queue':
|
||||
const queueWithName = []
|
||||
bot.music.queue.forEach((song) => queueWithName.push(song.name))
|
||||
for (const song of bot.music.queue) queueWithName.push(song.name)
|
||||
Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Queue')
|
||||
|
|
|
@ -39,8 +39,8 @@ module.exports = {
|
|||
]
|
||||
|
||||
const bots = bot.getBots()
|
||||
bots.forEach((bot) => {
|
||||
for (const bot of bots) {
|
||||
bot.tellraw(selector, component)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
4
index.js
4
index.js
|
@ -11,14 +11,14 @@ const dcclient = new Client({ intents: [Guilds, GuildMessages, MessageContent] }
|
|||
let bots = []
|
||||
|
||||
dcclient.on('ready', () => {
|
||||
config.servers.forEach(async (server) => {
|
||||
for (const server of config.servers) {
|
||||
const getBots = () => bots
|
||||
const setNewBot = (server, bot) => {
|
||||
bots = bots.filter((eachBot) => eachBot.server.host !== server)
|
||||
bots.push(bot)
|
||||
}
|
||||
createBot(server, config, getBots, setNewBot, dcclient, rl)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
dcclient.login(config.discord.token)
|
||||
|
|
|
@ -16,14 +16,14 @@ function inject (bot, dcclient, config) {
|
|||
return
|
||||
};
|
||||
// totallynotskidded™️ from mineflayer/lib/plugins/chat.js
|
||||
bot.chatQueue[0].split('\n').forEach((subMessage) => {
|
||||
for (const subMessage of bot.chatQueue[0].split('\n')) {
|
||||
if (!subMessage) return
|
||||
let smallMsg
|
||||
for (let i = 0; i < subMessage.length; i += config.chat.messageLength) {
|
||||
smallMsg = subMessage.substring(i, i + config.chat.messageLength)
|
||||
bot._chatQueue.push(smallMsg)
|
||||
}
|
||||
})
|
||||
}
|
||||
bot.chatQueue.shift()
|
||||
}
|
||||
}, 0)
|
||||
|
|
|
@ -46,7 +46,7 @@ function inject (bot, _dcclient, config, rl) {
|
|||
|
||||
if (line.startsWith('.csvr ')) {
|
||||
const host = line.substring(6)
|
||||
bot.getBots().forEach((eachBot) => { eachBot.console.host = host })
|
||||
for (const eachBot of bot.getBots()) eachBot.console.host = host
|
||||
bot.console.info(`Host set to: ${host}`)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ async function inject (bot, dcclient, config) {
|
|||
try {
|
||||
const attachmentsComponent = []
|
||||
if (message.attachments) {
|
||||
message.attachments.forEach((value) => {
|
||||
for (const value of message.attachments) {
|
||||
attachmentsComponent.push({
|
||||
text: message.content === '' ? '[Attachment]' : ' [Attachment]', // may not be the best fix
|
||||
color: 'green',
|
||||
|
@ -48,7 +48,7 @@ async function inject (bot, dcclient, config) {
|
|||
value: value.proxyURL
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
const component = [
|
||||
{ text: '[', color: 'dark_gray' },
|
||||
|
|
|
@ -9,9 +9,9 @@ async function list (filepath = '.') {
|
|||
const files = await fs.readdir(filepath)
|
||||
|
||||
const component = []
|
||||
files.forEach((filename, index) => {
|
||||
for (const filename of files) {
|
||||
component.push(filename)
|
||||
})
|
||||
}
|
||||
return component
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ const path = require('path')
|
|||
async function loadPlugins (bot, dcclient, config, rl, target, client, proxy, clientPacketBlacklist, targetPacketBlacklist) {
|
||||
const dir = path.join(__dirname, '..', 'plugins', proxy ? 'proxy' : '')
|
||||
const plugins = await fs.readdir(dir)
|
||||
plugins.forEach((plugin) => {
|
||||
for (const plugin of plugins) {
|
||||
if (!plugin.endsWith('.js')) return
|
||||
try {
|
||||
const plug = require(path.join(dir, plugin))
|
||||
|
@ -27,7 +27,7 @@ async function loadPlugins (bot, dcclient, config, rl, target, client, proxy, cl
|
|||
console.log(`Plugin ${plugin} is having exception loading the plugin:`)
|
||||
console.log(util.inspect(e))
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = { loadPlugins }
|
||||
|
|
Loading…
Reference in a new issue