From ec2fde1a0bf4d17af5ab9974770b6e91251fcd96 Mon Sep 17 00:00:00 2001 From: ChomeNS Date: Wed, 14 Dec 2022 20:51:30 +0700 Subject: [PATCH] fix sender not working, remove sender from chat parser, remove raw username --- commands/ayunsudo.js | 4 ++-- commands/botuser.js | 4 ++-- commands/botvisibility.js | 4 ++-- commands/bruhify.js | 4 ++-- commands/cb.js | 4 ++-- commands/changelog.js | 4 ++-- commands/clearchat.js | 4 ++-- commands/cloop.js | 4 ++-- commands/cowsay.js | 4 ++-- commands/crashserver.js | 4 ++-- commands/creator.js | 4 ++-- commands/discord.js | 2 +- commands/draw.js | 2 +- commands/eaglercrash.js | 2 +- commands/echo.js | 4 ++-- commands/end.js | 4 ++-- commands/entity.js | 2 +- commands/eval.js | 4 ++-- commands/executebypass.js | 2 +- commands/gamemodeall.js | 2 +- commands/help.js | 4 ++-- commands/list.js | 4 ++-- commands/music.js | 4 ++-- commands/netmsg.js | 2 +- commands/refillcore.js | 2 +- commands/rtp.js | 2 +- commands/servereval.js | 4 ++-- commands/test.js | 8 ++------ commands/time.js | 4 ++-- commands/tpall.js | 2 +- commands/translate.js | 4 ++-- commands/uptime.js | 4 ++-- commands/urban.js | 2 +- commands/uuid.js | 4 ++-- commands/validate.js | 2 +- commands/wikipedia.js | 4 ++-- plugins/commands.js | 21 +++++++++------------ util/chat.js | 10 +++++----- 38 files changed, 74 insertions(+), 81 deletions(-) diff --git a/commands/ayunsudo.js b/commands/ayunsudo.js index 1db0f57..3be690c 100644 --- a/commands/ayunsudo.js +++ b/commands/ayunsudo.js @@ -4,10 +4,10 @@ module.exports = { description: 'Sudos everyone on Ayunboom!', trusted: 1, usage: ' ', - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { bot.core.run(`essentials:sudo * ${args.slice(1).join(' ')}`) }, - discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message) { + discordExecute (bot, username, sender, prefix, args, channeldc, message) { bot.core.run(`essentials:sudo * ${args.join(' ')}`) } } diff --git a/commands/botuser.js b/commands/botuser.js index a0ce4b9..c6c513b 100644 --- a/commands/botuser.js +++ b/commands/botuser.js @@ -5,10 +5,10 @@ module.exports = { description: 'Shows the bot\'s username and UUID', usage: '', trusted: 0, - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { bot.tellraw(selector, [{ text: 'The bot\'s username is: ', color: 'white' }, { text: `${bot.username}`, color: 'gold', clickEvent: { action: 'copy_to_clipboard', value: `${bot.username}` }, hoverEvent: { action: 'show_text', contents: [{ text: 'Click here to copy the username to your clipboard', color: 'green' }] } }, { text: ' and the UUID is: ' }, { text: `${bot.uuid}`, color: 'aqua', clickEvent: { action: 'copy_to_clipboard', value: `${bot.uuid}` }, hoverEvent: { action: 'show_text', contents: [{ text: 'Click here to copy the UUID to your clipboard', color: 'green' }] } }]) }, - discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) { + discordExecute (bot, username, sender, prefix, args, channeldc, message, config) { const Embed = new MessageEmbed() .setColor(config.discord.embedsColors.normal) .setTitle('Bot\'s User') diff --git a/commands/botvisibility.js b/commands/botvisibility.js index 1a8700a..e272295 100644 --- a/commands/botvisibility.js +++ b/commands/botvisibility.js @@ -9,7 +9,7 @@ module.exports = { '' ], trusted: 1, - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { if (args[1] === 'true' || args[1] === 'on') { bot.visibility = true bot.chat('/essentials:vanish disable') @@ -29,7 +29,7 @@ module.exports = { throw new SyntaxError('Invalid argument') } }, - discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) { + discordExecute (bot, username, sender, prefix, args, channeldc, message, config) { if (args[0] === 'true' || args[0] === 'on') { bot.visibility = true bot.chat('/essentials:vanish disable') diff --git a/commands/bruhify.js b/commands/bruhify.js index 6c8dd51..4d54350 100644 --- a/commands/bruhify.js +++ b/commands/bruhify.js @@ -5,10 +5,10 @@ module.exports = { description: 'RecycleBot bruhify but actionbar', usage: '', trusted: 0, - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { bot.bruhifyText = args.join(' ') }, - discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) { + discordExecute (bot, username, sender, prefix, args, channeldc, message, config) { bot.bruhifyText = args.join(' ') const Embed = new MessageEmbed() .setColor(config.discord.embedsColors.normal) diff --git a/commands/cb.js b/commands/cb.js index 069dacf..42db4a0 100644 --- a/commands/cb.js +++ b/commands/cb.js @@ -4,10 +4,10 @@ module.exports = { description: 'Executes a command in the command core', usage: '', trusted: 0, - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { bot.core.run(args.join(' ')) }, - discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc) { + discordExecute (bot, username, sender, prefix, args, channeldc) { bot.core.run(args.join(' ')) } } diff --git a/commands/changelog.js b/commands/changelog.js index 798a7e1..cbfcb9d 100644 --- a/commands/changelog.js +++ b/commands/changelog.js @@ -6,7 +6,7 @@ module.exports = { description: 'Shows the bot\'s changelog', usage: '', trusted: 0, - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { const component = [] component.push({ text: 'Changelogs ', color: 'green' }) @@ -26,7 +26,7 @@ module.exports = { bot.tellraw(selector, component) }, - discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) { + discordExecute (bot, username, sender, prefix, args, channeldc, message, config) { let changelogs = '' changelog.forEach((message, number) => { number += 1 diff --git a/commands/clearchat.js b/commands/clearchat.js index b0ad714..1d9c7a5 100644 --- a/commands/clearchat.js +++ b/commands/clearchat.js @@ -5,14 +5,14 @@ module.exports = { description: 'Clears the chat', usage: '[specific] ', trusted: 0, - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { if (args[0] === 'specific') { bot.tellraw(args[1], [{ text: `${'\n'.repeat(100)}`, color: 'white' }, { text: `Your chat has been cleared by ${username}.`, color: 'dark_green' }]) } else { bot.tellraw('@a', [{ text: `${'\n'.repeat(100)}`, color: 'white' }, { text: 'The chat has been cleared.', color: 'dark_green' }]) } }, - discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message) { + discordExecute (bot, username, sender, prefix, args, channeldc, message) { if (args[0] === 'specific') { bot.tellraw(args[1], [{ text: `${'\n'.repeat(100)}`, color: 'white' }, { text: `Your chat has been cleared by ${username} (on Discord).`, color: 'dark_green' }]) } else { diff --git a/commands/cloop.js b/commands/cloop.js index 910be96..dca1e51 100644 --- a/commands/cloop.js +++ b/commands/cloop.js @@ -53,7 +53,7 @@ module.exports = { ' list' ], trusted: 1, - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { if (args[1] === 'add' && args[3]) { if (!Number(args[2]) && Number(args[2]) !== 0) throw new SyntaxError('Invalid interval') bot.cloop.add(args.slice(3).join(' '), args[2]) @@ -70,7 +70,7 @@ module.exports = { throw new SyntaxError('Invalid argument') } }, - discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) { + discordExecute (bot, username, sender, prefix, args, channeldc, message, config) { if (args[0] === 'add' && args[2]) { if (!Number(args[1]) && Number(args[1]) !== 0) throw new SyntaxError('Invalid interval') bot.cloop.add(args.slice(2).join(' '), args[1]) diff --git a/commands/cowsay.js b/commands/cowsay.js index 1296e5c..0394cd7 100644 --- a/commands/cowsay.js +++ b/commands/cowsay.js @@ -10,7 +10,7 @@ module.exports = { 'list (not support on Discord)' ], trusted: 0, - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { if (args[0] === 'list') { const listed = Object.keys(cows) @@ -33,7 +33,7 @@ module.exports = { bot.tellraw(selector, { text: cowsay.say(args.slice(1).join(' '), { cow: cows[args[0]] }) }) } }, - discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) { + discordExecute (bot, username, sender, prefix, args, channeldc, message, config) { const Embed = new MessageEmbed() .setColor(config.discord.embedsColors.normal) .setTitle('Cowsay') diff --git a/commands/crashserver.js b/commands/crashserver.js index 55d57cd..d9d2826 100644 --- a/commands/crashserver.js +++ b/commands/crashserver.js @@ -18,10 +18,10 @@ module.exports = { description: 'Crashes the server', usage: '', trusted: 1, - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { crash(bot) }, - discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message) { + discordExecute (bot, username, sender, prefix, args, channeldc, message) { crash(bot) } } diff --git a/commands/creator.js b/commands/creator.js index f2229de..64f5e48 100644 --- a/commands/creator.js +++ b/commands/creator.js @@ -5,10 +5,10 @@ module.exports = { description: 'Shows the bot\'s creator', usage: '', trusted: 0, - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { bot.tellraw(selector, [{ text: 'ChomeNS Bot ', color: 'yellow' }, { text: 'was created by ', color: 'white' }, { text: 'chayapak', color: 'gold' }]) }, - discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) { + discordExecute (bot, username, sender, prefix, args, channeldc, message, config) { const Embed = new MessageEmbed() .setColor(config.discord.embedsColors.normal) .setTitle('Creator') diff --git a/commands/discord.js b/commands/discord.js index ef151aa..b5df787 100644 --- a/commands/discord.js +++ b/commands/discord.js @@ -4,7 +4,7 @@ module.exports = { description: 'Shows the discord invite', usage: '', trusted: 0, - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { bot.tellraw(selector, [ { text: 'The Discord invite is ', diff --git a/commands/draw.js b/commands/draw.js index e1c3565..6252460 100644 --- a/commands/draw.js +++ b/commands/draw.js @@ -8,7 +8,7 @@ module.exports = { alias: [], trusted: 0, usage: '', - execute: async function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute: async function (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { try { const url = args.join(' ') diff --git a/commands/eaglercrash.js b/commands/eaglercrash.js index 423d56d..eb5ea9a 100644 --- a/commands/eaglercrash.js +++ b/commands/eaglercrash.js @@ -4,7 +4,7 @@ module.exports = { description: 'Lags Eaglercraft and crash it', usage: ' ', trusted: 1, - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { switch (args[1]) { case 'on': bot.eaglercrash.on() diff --git a/commands/echo.js b/commands/echo.js index 2d939ee..67dbbb8 100644 --- a/commands/echo.js +++ b/commands/echo.js @@ -4,10 +4,10 @@ module.exports = { description: 'Says a message', usage: '', trusted: 0, - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { bot.chat(args.join(' ')) }, - discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc) { + discordExecute (bot, username, sender, prefix, args, channeldc) { bot.chat(args.join(' ')) } } diff --git a/commands/end.js b/commands/end.js index 86ae40a..506f02f 100644 --- a/commands/end.js +++ b/commands/end.js @@ -4,10 +4,10 @@ module.exports = { description: 'Ends the bot\'s client', usage: '', trusted: 1, - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { bot.end('end command') }, - discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message) { + discordExecute (bot, username, sender, prefix, args, channeldc, message) { bot.end('end command') } } diff --git a/commands/entity.js b/commands/entity.js index 5eecd7a..966f1ba 100644 --- a/commands/entity.js +++ b/commands/entity.js @@ -4,7 +4,7 @@ module.exports = { description: 'Summon any entity!', usage: '[specific] ', trusted: 0, - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { // eslint-disable-next-line no-unused-vars const mcData = require('minecraft-data')(bot.version) diff --git a/commands/eval.js b/commands/eval.js index 9fb1ee7..4bfeb46 100644 --- a/commands/eval.js +++ b/commands/eval.js @@ -14,7 +14,7 @@ module.exports = { 'reset', 'server (eval server) ' ], - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { if (args[0] === 'run') { try { bot.tellraw(selector, { text: `${util.inspect(bot.vm.run(args.slice(1).join(' ')), { stylize })}`.substring(0, 32000) }) @@ -39,7 +39,7 @@ module.exports = { }) } }, - discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) { + discordExecute (bot, username, sender, prefix, args, channeldc, message, config) { if (args[0] === 'run') { const Embed = new MessageEmbed() .setColor(config.discord.embedsColors.normal) diff --git a/commands/executebypass.js b/commands/executebypass.js index 01e8b1d..a55caa4 100644 --- a/commands/executebypass.js +++ b/commands/executebypass.js @@ -4,7 +4,7 @@ module.exports = { description: 'Execute command bypassed', usage: ' ', trusted: 1, - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { bot.core.run('minecraft:execute unless entity @s[name= run ] run ' + args.slice(1).join(' ')) } } diff --git a/commands/gamemodeall.js b/commands/gamemodeall.js index 75cbe6a..138ec66 100644 --- a/commands/gamemodeall.js +++ b/commands/gamemodeall.js @@ -4,7 +4,7 @@ module.exports = { description: 'Gamemode everyone', usage: ' ', trusted: 1, - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { bot.core.run(`minecraft:execute unless entity @s[name= run ] run gamemode ${args[1]} @a[name=!${bot.username}]`) } } diff --git a/commands/help.js b/commands/help.js index 5d89b4a..3b31cfc 100644 --- a/commands/help.js +++ b/commands/help.js @@ -7,7 +7,7 @@ module.exports = { description: 'Shows the help', usage: '[command]', trusted: 0, - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { if (args[0]) { for (const command of bot.command_handler.commands) { function run () { @@ -96,7 +96,7 @@ module.exports = { bot.tellraw(selector, [pre, generalCommands, trustedCommands, ownerCommands]) } }, - discordExecute: async function (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) { + discordExecute: async function (bot, username, sender, prefix, args, channeldc, message, config) { if (args[0]) { for (const command of bot.command_handler.commands) { function run () { diff --git a/commands/list.js b/commands/list.js index cbcecbe..02b2a86 100644 --- a/commands/list.js +++ b/commands/list.js @@ -5,7 +5,7 @@ module.exports = { description: 'List players', usage: '', trusted: 0, - execute: async function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute: async function (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { try { const component = [] component.push({ text: 'Players ', color: 'green' }) @@ -57,7 +57,7 @@ module.exports = { } }, - discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) { + discordExecute (bot, username, sender, prefix, args, channeldc, message, config) { try { let players = '' for (const property of bot.players.list) { diff --git a/commands/music.js b/commands/music.js index a233608..51c02be 100644 --- a/commands/music.js +++ b/commands/music.js @@ -160,7 +160,7 @@ module.exports = { 'nowplaying', 'queue' ], - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { switch (args[0]) { case 'play': play(bot, args.slice(1), false, null, selector, config) @@ -252,7 +252,7 @@ module.exports = { throw new SyntaxError('Invalid argument') } }, - discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) { + discordExecute (bot, username, sender, prefix, args, channeldc, message, config) { let Embed switch (args[0]) { case 'play': diff --git a/commands/netmsg.js b/commands/netmsg.js index c238624..da980a0 100644 --- a/commands/netmsg.js +++ b/commands/netmsg.js @@ -4,7 +4,7 @@ module.exports = { description: 'Broadcasts a message to all of the servers that the bot is connected', usage: '', trusted: 0, - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { const component = [ { text: '[', diff --git a/commands/refillcore.js b/commands/refillcore.js index 91833d5..2a8b9ba 100644 --- a/commands/refillcore.js +++ b/commands/refillcore.js @@ -4,7 +4,7 @@ module.exports = { description: 'Resets the bot\'s command core', usage: '', trusted: 0, - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { bot.core.fillCore() }, discordExecute (bot) { diff --git a/commands/rtp.js b/commands/rtp.js index 6e01331..70a9a82 100644 --- a/commands/rtp.js +++ b/commands/rtp.js @@ -5,7 +5,7 @@ module.exports = { description: 'Randomly teleports the player', usage: '', trusted: 0, - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { const rtppos = `${between(20000000, 500000)} 100 ${between(20000000, 500000)}` bot.tellraw(selector, [{ text: 'Teleporting ', color: 'white' }, { text: username, color: 'aqua' }, { text: ' to ', color: 'white' }, { text: rtppos, color: 'green' }, { text: '...', color: 'white' }]) bot.core.run(`essentials:teleport ${sender} ${rtppos}`) diff --git a/commands/servereval.js b/commands/servereval.js index 77157bc..f66665f 100644 --- a/commands/servereval.js +++ b/commands/servereval.js @@ -8,14 +8,14 @@ module.exports = { description: 'Basically eval command but without vm2', trusted: 2, usage: ' ', - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { try { bot.tellraw(selector, { text: util.inspect(eval(args.slice(1).join(' ')), { stylize }).substring(0, 32700) }) } catch (err) { bot.tellraw(selector, { text: util.inspect(err).replaceAll('runner', 'chayapak1'), color: 'red' }) } }, - discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) { + discordExecute (bot, username, sender, prefix, args, channeldc, message, config) { try { const Embed = new MessageEmbed() .setColor(config.discord.embedsColors.normal) diff --git a/commands/test.js b/commands/test.js index 618ae66..97eec13 100644 --- a/commands/test.js +++ b/commands/test.js @@ -5,16 +5,12 @@ module.exports = { description: 'Tests if the bot is working', usage: '', trusted: 0, - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { bot.tellraw(selector, [ { text: `Username: ${username},`, color: 'green' }, - { - text: ` Raw username: ${usernameraw},`, - color: 'green' - }, { text: ` Sender UUID: ${sender},`, color: 'green' @@ -29,7 +25,7 @@ module.exports = { } ]) }, - discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) { + discordExecute (bot, username, sender, prefix, args, channeldc, message, config) { const Embed = new MessageEmbed() .setColor(config.discord.embedsColors.normal) .setTitle('Hello!') diff --git a/commands/time.js b/commands/time.js index a6ccd52..42968f4 100644 --- a/commands/time.js +++ b/commands/time.js @@ -6,7 +6,7 @@ module.exports = { description: 'Shows the time', usage: '', trusted: 0, - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { const timezone = args.join(' ') const momented = moment().tz(timezone).format('dddd, MMMM Do, YYYY, hh:mm:ss A') const component = [{ text: 'The current date and time for the timezone ', color: 'white' }, { text: timezone, color: 'aqua' }, { text: ' is: ', color: 'white' }, { text: `${momented}`, color: 'green' }] @@ -18,7 +18,7 @@ module.exports = { bot.tellraw(selector, component) } }, - discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) { + discordExecute (bot, username, sender, prefix, args, channeldc, message, config) { const timezone = args.join(' ') const momented = moment().tz(timezone).format('dddd, MMMM Do, YYYY, hh:mm:ss A') const description = `The current date and time for the timezone ${timezone} is: ${momented}` diff --git a/commands/tpall.js b/commands/tpall.js index bbcd580..362cc0d 100644 --- a/commands/tpall.js +++ b/commands/tpall.js @@ -4,7 +4,7 @@ module.exports = { description: 'Teleport everyone', usage: ' ', trusted: 1, - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { bot.core.run(`minecraft:execute unless entity @s[name= run ] run tp @a ${args.slice(1).join(' ')}`) } } diff --git a/commands/translate.js b/commands/translate.js index c086645..2ad299f 100644 --- a/commands/translate.js +++ b/commands/translate.js @@ -6,7 +6,7 @@ module.exports = { description: 'Translate a message from any language to any language using Google Translate', usage: ' ', trusted: 0, - execute: async function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute: async function (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { try { const res = await translate(args.slice(2).join(' '), { from: args[0], to: args[1] }) bot.tellraw(selector, [{ text: 'Result: ', color: 'gold' }, { text: res.text, color: 'green' }]) @@ -14,7 +14,7 @@ module.exports = { bot.tellraw(selector, { text: String(e), color: 'red' }) } }, - discordExecute: async function (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) { + discordExecute: async function (bot, username, sender, prefix, args, channeldc, message, config) { try { const res = await translate(args.slice(2).join(' '), { from: args[0], to: args[1] }) const Embed = new MessageEmbed() diff --git a/commands/uptime.js b/commands/uptime.js index 0be17de..20865ef 100644 --- a/commands/uptime.js +++ b/commands/uptime.js @@ -6,11 +6,11 @@ module.exports = { description: 'Shows the bot\'s uptime', usage: '', trusted: 0, - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { const time = moment.utc(Math.floor(performance.now())).format('H [hours], m [minutes], s [seconds]') bot.tellraw(selector, [{ text: 'The bot\'s uptime is ', color: 'white' }, { text: time, color: 'green' }]) }, - discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) { + discordExecute (bot, username, sender, prefix, args, channeldc, message, config) { const time = moment.utc(Math.floor(performance.now())).format('H [hours], m [minutes], s [seconds]') const Embed = new MessageEmbed() .setColor(config.discord.embedsColors.normal) diff --git a/commands/urban.js b/commands/urban.js index 7af18ea..290355c 100644 --- a/commands/urban.js +++ b/commands/urban.js @@ -5,7 +5,7 @@ module.exports = { description: 'Working Urban Dictionary', usage: '', trusted: 0, - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { urban.autocompleteExtra(args[0], (error, results) => { if (error) { bot.tellraw(selector, [{ text: '[', color: 'dark_red' }, { text: 'Urban', color: 'red' }, { text: '] ', color: 'dark_red' }, { text: error.message, color: 'red' }]) diff --git a/commands/uuid.js b/commands/uuid.js index b99a269..9f2155a 100644 --- a/commands/uuid.js +++ b/commands/uuid.js @@ -5,7 +5,7 @@ module.exports = { description: 'Gets the UUID of a player. If no player specified it will show your UUID instead', usage: '', trusted: 0, - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { if (args[0]) { const playername = args.join(' ') const player = bot.playersAddedPlayers[playername] @@ -61,7 +61,7 @@ module.exports = { ]) } }, - discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message) { + discordExecute (bot, username, sender, prefix, args, channeldc, message) { if (args[0]) { const playername = args.join(' ') const player = bot.playersAddedPlayers[playername] diff --git a/commands/validate.js b/commands/validate.js index 068fb25..2ba1ea3 100644 --- a/commands/validate.js +++ b/commands/validate.js @@ -4,7 +4,7 @@ module.exports = { alias: [], usage: '', trusted: 1, - execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { if (args[0] === hash) { bot.tellraw(selector, { text: 'Valid hash', color: 'green' }) } else if (args[0] === ownerhash) { diff --git a/commands/wikipedia.js b/commands/wikipedia.js index e4e45b4..736001e 100644 --- a/commands/wikipedia.js +++ b/commands/wikipedia.js @@ -7,7 +7,7 @@ module.exports = { description: 'Working Wikipedia!', usage: '', trusted: 0, - execute: async function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + execute: async function (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { try { const page = await wiki.page(args.join(' ')) const summary = await page.summary() @@ -16,7 +16,7 @@ module.exports = { bot.tellraw(selector, { text: e.toString(), color: 'red' }) } }, - discordExecute: async function (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) { + discordExecute: async function (bot, username, sender, prefix, args, channeldc, message, config) { try { const page = await wiki.page(args.join(' ')) const summary = await page.summary() diff --git a/plugins/commands.js b/plugins/commands.js index e8b896f..071645e 100644 --- a/plugins/commands.js +++ b/plugins/commands.js @@ -10,7 +10,7 @@ function inject (bot, dcclient, config) { bot.command_handler.commands = await loadFiles(path.join(__dirname, config.commandsDir)) } bot.command_handler.reload() - bot.command_handler.main = function (prefix, username, usernameraw, message, sender, channeldc, hash, ownerhash, selector, proxy) { + bot.command_handler.main = function (prefix, username, message, sender, channeldc, hash, ownerhash, selector, proxy) { bot.command_handler.reload() let raw let command @@ -39,9 +39,9 @@ function inject (bot, dcclient, config) { if (prefix === config.discord.prefix) { if (!command.discordExecute) throw new Error('This command is not yet supported on discord!') - command.discordExecute(bot, username, usernameraw, sender, prefix, args, channeldc, message, config) + command.discordExecute(bot, username, sender, prefix, args, channeldc, message, config) } else { - command.execute(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector, proxy) + command.execute(bot, username, sender, prefix, args, config, hash, ownerhash, selector, proxy) } } catch (e) { if (prefix === config.discord.prefix) { @@ -55,15 +55,15 @@ function inject (bot, dcclient, config) { } } } - bot.command_handler.run = function (username, usernameraw, message, sender, channeldc, hash, ownerhash, selector = '@a', proxy) { + bot.command_handler.run = function (username, message, sender, channeldc, hash, ownerhash, selector = '@a', proxy) { for (const prefix of config.prefixes) { if (!message.startsWith(prefix)) continue - bot.command_handler.main(prefix, username, usernameraw, message, sender, channeldc, hash, ownerhash, selector, proxy) + bot.command_handler.main(prefix, username, message, sender, channeldc, hash, ownerhash, selector, proxy) } } let previousMessage = { username: '', message: '' } let ratelimit = 0 - bot.on('chat', async (_username, _message, _sender) => { + bot.on('chat', async (_username, _message) => { // try catch cuz TypeError: Cannot read properties of undefined (reading 'replace') try { if ( @@ -77,13 +77,10 @@ function inject (bot, dcclient, config) { previousMessage = { username: _username, _message } - const usernameraw = _username.replace(/§.?/g, '') - const sender = _sender !== '00000000-0000-0000-0000-000000000000' ? _sender : bot.playersAddedPlayers[usernameraw] - let username - if (!bot.getplayerusername[sender]) username = usernameraw - else username = bot.getplayerusername[sender] + const username = _username.replace(/§.?/g, '') + const sender = bot.players.list.find((val) => val.name === username)?.UUID const message = _message.replace(/* /§r/g */ /§.?/g, '')/* .replace(/§/g, '') */ - bot.command_handler.run(username, usernameraw, message, sender, channeldc, bot.hash, bot.ownerHash) + bot.command_handler.run(username, message, sender, channeldc, bot.hash, bot.ownerHash) } catch (e) { bot.console.error(e) } diff --git a/util/chat.js b/util/chat.js index f8762b8..6acbf99 100644 --- a/util/chat.js +++ b/util/chat.js @@ -42,24 +42,24 @@ function parsePlayerMessages (message, packet, bot) { if (raw.match(/.* .*: .*/g)) { const username = raw.replace(/.*?\[.*?\] /g, '').replace(/:.*/g, '').replace(/§#....../gm, '') const message = raw.split(': ').slice(1).join(' ').replace(/§#....../gm, '') - bot.emit('chat', username, message, packet.sender) + bot.emit('chat', username, message) } else if (raw.match(/.* .*\u203a .*/g)) { const username = raw.replace(/.*?\[.*?\] /g, '').replace(/\u203a.*/g, '').replace(/§#....../gm, '').split(' ')[0] const message = raw.split('\u203a ').slice(1).join(' ').substring(2) - bot.emit('chat', username, message, packet.sender) + bot.emit('chat', username, message) } else if (raw.match(/.* .*\u00BB .*/g)) { const username = raw.replace(/.*?\[.*?\] /g, '').replace(/\u00BB.*/g, '').replace(/§#....../gm, '').split(' ')[0] const message = raw.split('\u00BB ').slice(1).join(' ').substring(2) - bot.emit('chat', username, message, packet.sender) + bot.emit('chat', username, message) } else if (raw.match(/.* .*> .*/g)) { const username = raw.replace(/.*?\[.*?\] /g, '').replace(/>.*/g, '').replace(/§#....../gm, '').split(' ')[0] const message = raw.split('> ').slice(1).join(' ').substring(2) - bot.emit('chat', username, message, packet.sender) + bot.emit('chat', username, message) } else if (raw.match(/<.*> .*/g)) { const username = raw.substring(1).split('>')[0] const message = raw.split('> ').slice(1).join(' ') - bot.emit('chat', username, message, packet.sender) + bot.emit('chat', username, message) } else if (raw.match(/§.*§b: §b\/.*/g)) { const username = raw.split('§b: §b')[0] const command = raw.split('§b: §b')[1]