diff --git a/commands/cowsay.js b/commands/cowsay.js index b49bf3f..3465f8b 100644 --- a/commands/cowsay.js +++ b/commands/cowsay.js @@ -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 { diff --git a/commands/help.js b/commands/help.js index ac7ea63..891a93c 100644 --- a/commands/help.js +++ b/commands/help.js @@ -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() } diff --git a/commands/music.js b/commands/music.js index 8c07600..f9fe210 100644 --- a/commands/music.js +++ b/commands/music.js @@ -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') diff --git a/commands/netmsg.js b/commands/netmsg.js index e105022..37e5476 100644 --- a/commands/netmsg.js +++ b/commands/netmsg.js @@ -39,8 +39,8 @@ module.exports = { ] const bots = bot.getBots() - bots.forEach((bot) => { + for (const bot of bots) { bot.tellraw(selector, component) - }) + } } } diff --git a/index.js b/index.js index 303d887..d6a94c5 100644 --- a/index.js +++ b/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) diff --git a/plugins/chat.js b/plugins/chat.js index dbd5691..04f16be 100644 --- a/plugins/chat.js +++ b/plugins/chat.js @@ -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) diff --git a/plugins/console.js b/plugins/console.js index 1ef13cf..5e84488 100644 --- a/plugins/console.js +++ b/plugins/console.js @@ -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 } diff --git a/plugins/discord.js b/plugins/discord.js index 438495d..cfd0d2a 100644 --- a/plugins/discord.js +++ b/plugins/discord.js @@ -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' }, diff --git a/util/file-list.js b/util/file-list.js index f663251..6bba885 100644 --- a/util/file-list.js +++ b/util/file-list.js @@ -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 } diff --git a/util/loadPlugins.js b/util/loadPlugins.js index 71896f2..4357cc6 100644 --- a/util/loadPlugins.js +++ b/util/loadPlugins.js @@ -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 }