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