diff --git a/commands/ayunsudo.js b/commands/ayunsudo.js index d483154..d79b1f0 100644 --- a/commands/ayunsudo.js +++ b/commands/ayunsudo.js @@ -5,7 +5,7 @@ module.exports = { description: 'Sudo everyone on Ayunboom!', trusted: 1, usage: ' ', - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { + execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { if (args[0] === hash) { bot.core.run(`essentials:sudo * ${args.slice(1).join(' ')}`); } else { diff --git a/commands/botuser.js b/commands/botuser.js index 6413a48..4ad681a 100644 --- a/commands/botuser.js +++ b/commands/botuser.js @@ -6,8 +6,8 @@ module.exports = { description: 'Shows the bot\'s username and UUID', usage: '', trusted: 0, - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { - bot.tellraw('@a', [{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'}]}}]); + execute: function(bot, username, usernameraw, 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: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) { const Embed = new MessageEmbed() diff --git a/commands/botvisibility.js b/commands/botvisibility.js index ecda70e..2366bc4 100644 --- a/commands/botvisibility.js +++ b/commands/botvisibility.js @@ -6,16 +6,16 @@ module.exports = { description: 'Changes the bot\'s visibility', usage: ' ', trusted: 1, - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { + execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { if (args[0] === hash) { if (args[1] === 'true') { bot.visibility = true; bot.chat('/essentials:vanish disable'); - bot.tellraw('@a', [{text: 'The bot\'s visibility is now ', color: 'white'}, {text: 'visible', color: 'green'}]); + bot.tellraw(selector, [{text: 'The bot\'s visibility is now ', color: 'white'}, {text: 'visible', color: 'green'}]); } else if (args[1] === 'false') { bot.visibility = false; bot.chat('/essentials:vanish enable'); - bot.tellraw('@a', [{text: 'The bot\'s visibility is now ', color: 'white'}, {text: 'invisible', color: 'gold'}]); + bot.tellraw(selector, [{text: 'The bot\'s visibility is now ', color: 'white'}, {text: 'invisible', color: 'gold'}]); } else { throw new SyntaxError('Invalid argument'); } diff --git a/commands/bruhify.js b/commands/bruhify.js index d060ca9..cda9d5e 100644 --- a/commands/bruhify.js +++ b/commands/bruhify.js @@ -6,7 +6,7 @@ module.exports = { description: 'RecycleBot bruhify but actionbar', usage: '', trusted: 0, - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { + execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { bot.bruhifyText = args.join(' '); }, discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc) { diff --git a/commands/cb.js b/commands/cb.js index f3c1073..cbeeddd 100644 --- a/commands/cb.js +++ b/commands/cb.js @@ -5,7 +5,7 @@ module.exports = { description: 'Executes a command in the command core', usage: '', trusted: 0, - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { + execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { bot.core.run(args.join(' ')); }, discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc) { diff --git a/commands/changelog.js b/commands/changelog.js index 3998d40..b1b1f0f 100644 --- a/commands/changelog.js +++ b/commands/changelog.js @@ -7,11 +7,11 @@ module.exports = { description: 'Shows the bot\'s changelog', usage: '', trusted: 0, - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { - bot.tellraw('@a', [{text: 'Changelogs:', color: 'green'}]); + execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + bot.tellraw(selector, [{text: 'Changelogs:', color: 'green'}]); changelog.forEach((message, number) => { number += 1; - bot.tellraw('@a', [{text: `${number}`, color: 'gray'}, {text: ' - ', color: 'dark_gray'}, {text: message, color: 'gray'}]); + bot.tellraw(selector, [{text: `${number}`, color: 'gray'}, {text: ' - ', color: 'dark_gray'}, {text: message, color: 'gray'}]); }); }, discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc) { diff --git a/commands/clearchat.js b/commands/clearchat.js index eb12990..177f4b7 100644 --- a/commands/clearchat.js +++ b/commands/clearchat.js @@ -6,12 +6,12 @@ module.exports = { description: 'Clears the chat', usage: '[specific] ', trusted: 0, - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { + execute: function(bot, username, usernameraw, 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'}]); return; } else { - bot.tellraw('@a', [{text: `${'\n'.repeat(100)}`, color: 'white'}, {text: 'The chat has been cleared.', color: 'dark_green'}]); + bot.tellraw(selector, [{text: `${'\n'.repeat(100)}`, color: 'white'}, {text: 'The chat has been cleared.', color: 'dark_green'}]); } }, discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) { @@ -19,7 +19,7 @@ module.exports = { bot.tellraw(args[1], [{text: `${'\n'.repeat(100)}`, color: 'white'}, {text: `Your chat has been cleared by ${username} (on Discord).`, color: 'dark_green'}]); return; } else { - bot.tellraw('@a', [{text: `${'\n'.repeat(100)}`, color: 'white'}, {text: 'The chat has been cleared.', color: 'dark_green'}]); + bot.tellraw(selector, [{text: `${'\n'.repeat(100)}`, color: 'white'}, {text: 'The chat has been cleared.', color: 'dark_green'}]); } }, }; diff --git a/commands/clearchatqueue.js b/commands/clearchatqueue.js index ff256a0..d2fb792 100644 --- a/commands/clearchatqueue.js +++ b/commands/clearchatqueue.js @@ -4,7 +4,7 @@ module.exports = { alias: ['ccq'], usage: '', trusted: 0, - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { + execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { if (bot.queue[0]) { bot.queue = []; } diff --git a/commands/cloop.js b/commands/cloop.js index 72e8c4b..a1afe23 100644 --- a/commands/cloop.js +++ b/commands/cloop.js @@ -53,7 +53,7 @@ function list(bot, discord, channeldc) { message.pop(); - bot.tellraw('@a', message); + bot.tellraw(selector, message); } module.exports = { name: 'cloop', @@ -66,22 +66,22 @@ module.exports = { ' ', ], trusted: 1, - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { + execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { if (!bot.cloops) bot.cloops = []; if (args[0] === hash) { if (args[1] === 'add' && args[3]) { if (!Number(args[2]) && Number(args[2]) !== 0) throw new SyntaxError('Invalid interval'); add(args.slice(3).join(' '), args[2], bot); - bot.tellraw('@a', [{text: 'Added command ', color: 'white'}, {text: `${args.slice(3).join(' ')}`, color: 'aqua'}, {text: ' with interval ', color: 'white'}, {text: `${args[2]}`, color: 'green'}, {text: ' to the cloops', color: 'white'}]); + bot.tellraw(selector, [{text: 'Added command ', color: 'white'}, {text: `${args.slice(3).join(' ')}`, color: 'aqua'}, {text: ' with interval ', color: 'white'}, {text: `${args[2]}`, color: 'green'}, {text: ' to the cloops', color: 'white'}]); } else if (args[1] === 'list') { list(bot); } else if (args[1] === 'remove') { remove(args[2]); - bot.tellraw('@a', [{text: 'Removed cloop '}, {text: args[2], color: 'aqua'}]); + bot.tellraw(selector, [{text: 'Removed cloop '}, {text: args[2], color: 'aqua'}]); } else if (args[1] === 'removeall') { clear(); - bot.tellraw('@a', [{text: 'Removed all looped commands', color: 'white'}]); + bot.tellraw(selector, [{text: 'Removed all looped commands', color: 'white'}]); } else { throw new SyntaxError('Invalid argument'); } diff --git a/commands/cowsay.js b/commands/cowsay.js index f4af9d0..0c2ec8e 100644 --- a/commands/cowsay.js +++ b/commands/cowsay.js @@ -7,7 +7,7 @@ module.exports = { description: 'Moo', usage: ' ', trusted: 0, - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { + execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { if (args[0]==='list') { const listed = Object.keys(cows); @@ -30,9 +30,9 @@ module.exports = { }); }); - bot.tellraw('@a', message); + bot.tellraw(selector, message); } else { - bot.tellraw('@a', {text: `${cowsay.say(args.slice(1).join(' '), {cow: cows[args[0]]})}`}); + bot.tellraw(selector, {text: `${cowsay.say(args.slice(1).join(' '), {cow: cows[args[0]]})}`}); } }, }; diff --git a/commands/crashserver.js b/commands/crashserver.js index 972bc17..aa2a24d 100644 --- a/commands/crashserver.js +++ b/commands/crashserver.js @@ -15,7 +15,7 @@ module.exports = { description: 'Crashes the server', usage: '', trusted: 1, - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { + execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { if (args[0] === hash) { crash(bot); } else { diff --git a/commands/creator.js b/commands/creator.js index bdbad43..2bc444c 100644 --- a/commands/creator.js +++ b/commands/creator.js @@ -6,8 +6,8 @@ module.exports = { description: 'Shows the bot\'s creator', usage: '', trusted: 0, - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { - bot.tellraw('@a', [{text: 'ChomeNS Bot ', color: 'yellow'}, {text: 'was created by ', color: 'white'}, {text: 'chayapak', color: 'gold'}]); + execute: function(bot, username, usernameraw, 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: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) { const Embed = new MessageEmbed() diff --git a/commands/discord.js b/commands/discord.js index af937db..cf80e5d 100644 --- a/commands/discord.js +++ b/commands/discord.js @@ -4,8 +4,8 @@ module.exports = { description: 'Shows the discord invite', usage: '', trusted: 0, - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { - bot.tellraw('@a', [ + execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + bot.tellraw(selector, [ { text: 'The Discord invite is ', color: 'white', diff --git a/commands/draw.js b/commands/draw.js index d4f1956..7c6114e 100644 --- a/commands/draw.js +++ b/commands/draw.js @@ -34,7 +34,7 @@ module.exports = { bot.draw(data, info); } catch (e) { - bot.tellraw('@a', {text: 'SyntaxError: Invalid URL', color: 'red'}); + bot.tellraw(selector, {text: 'SyntaxError: Invalid URL', color: 'red'}); } }, }; diff --git a/commands/eaglercrash.js b/commands/eaglercrash.js index 94f00aa..1600245 100644 --- a/commands/eaglercrash.js +++ b/commands/eaglercrash.js @@ -5,7 +5,7 @@ module.exports = { description: 'Lags Eaglercraft and crashes it', usage: ' ', trusted: 1, - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { + execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { if (args[1] === 'on') { if (args[0] === hash) { bot.eaglercrashstarted = true; diff --git a/commands/echo.js b/commands/echo.js index 8cf2049..abee131 100644 --- a/commands/echo.js +++ b/commands/echo.js @@ -5,7 +5,7 @@ module.exports = { description: 'Says a message', usage: '', trusted: 0, - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { + execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { bot.chat(args.join(' ')); }, discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc) { diff --git a/commands/end.js b/commands/end.js index 8f23ee5..4f5a1f6 100644 --- a/commands/end.js +++ b/commands/end.js @@ -5,7 +5,7 @@ module.exports = { description: 'Ends the bot\'s client', usage: '', trusted: 1, - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { + execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { if (args[0] === hash) { bot.end('end command'); } else { diff --git a/commands/entity.js b/commands/entity.js index f1a24c3..a79d39e 100644 --- a/commands/entity.js +++ b/commands/entity.js @@ -5,7 +5,7 @@ module.exports = { description: 'Summon any entity!', usage: '[specific] ', trusted: 0, - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { + execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { // eslint-disable-next-line no-unused-vars const mcData = require('minecraft-data')(bot.version); @@ -15,10 +15,10 @@ module.exports = { // if (!entity) throw new SyntaxError('Invalid entity'); // if (!args[1]) { // bot.core.run('minecraft:execute unless entity @s[name= run ] run execute as @a at @r[\'limit\'=10] run summon minecraft:' + entity.name); - // bot.tellraw('@a', [{text: 'Entity ', color: 'white'}, {text: entity.displayName, color: 'green'}, {text: ' spawning at everyone...', color: 'white'}]); + // bot.tellraw(selector, [{text: 'Entity ', color: 'white'}, {text: entity.displayName, color: 'green'}, {text: ' spawning at everyone...', color: 'white'}]); // } else if (args[1] === 'specific' && args[2]) { // bot.core.run('minecraft:execute unless entity @s[name= run ] run execute as @a at ' + args[2] + ' run summon minecraft:' + entity.name); - // bot.tellraw('@a', [{text: `Entity `, color: 'white'}, {text: entity.displayName, color: 'green'}, {text: ' spawning at ', color: 'white'}, {text: `${args[2]}`, color: 'aqua'}]); + // bot.tellraw(selector, [{text: `Entity `, color: 'white'}, {text: entity.displayName, color: 'green'}, {text: ' spawning at ', color: 'white'}, {text: `${args[2]}`, color: 'aqua'}]); // } }, }; diff --git a/commands/eval.js b/commands/eval.js index 014218a..66513b3 100644 --- a/commands/eval.js +++ b/commands/eval.js @@ -15,12 +15,12 @@ module.exports = { '', ' ', ], - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { + execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { if (args[0] === 'run') { try { - bot.tellraw('@a', {text: `${util.inspect(bot.vm.run(args.slice(1).join(' ')), {stylize: stylize})}`.substring(0, 32000)}); + bot.tellraw(selector, {text: `${util.inspect(bot.vm.run(args.slice(1).join(' ')), {stylize: stylize})}`.substring(0, 32000)}); } catch (err) { - bot.tellraw('@a', {text: `${util.inspect(err).replaceAll('runner', 'chayapak1')}`, color: 'red'}); + bot.tellraw(selector, {text: `${util.inspect(err).replaceAll('runner', 'chayapak1')}`, color: 'red'}); } } if (args[0] === 'reset') { @@ -34,9 +34,9 @@ module.exports = { colors: 'minecraft', code: args[1], })).then((res) => { - bot.tellraw('@a', {text: `${res.data}`}); + bot.tellraw(selector, {text: `${res.data}`}); }).catch((err) => { - bot.tellraw('@a', {text: `${err}`, color: 'red'}); + bot.tellraw(selector, {text: `${err}`, color: 'red'}); }); } // if (args[0] === 'dineval') { @@ -47,9 +47,9 @@ module.exports = { // colors: 'minecraft', // }, // }).then((res) => { - // bot.tellraw('@a', {text: `${res.data}`})); + // bot.tellraw(selector, {text: `${res.data}`})); // }).catch((e) => { - // bot.tellraw('@a', {text: `${e}`, color: 'red'}); + // bot.tellraw(selector, {text: `${e}`, color: 'red'}); // }); // } }, diff --git a/commands/executebypass.js b/commands/executebypass.js index 8d01a9e..0afe5df 100644 --- a/commands/executebypass.js +++ b/commands/executebypass.js @@ -5,7 +5,7 @@ module.exports = { description: 'Execute command bypassed', usage: ' ', trusted: 1, - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { + execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { if (args[0] === hash) { bot.core.run('minecraft:execute unless entity @s[name= run ] run ' + args.slice(1).join(' ')); } else { diff --git a/commands/gamemodeall.js b/commands/gamemodeall.js index 5dc2a95..e68d2f8 100644 --- a/commands/gamemodeall.js +++ b/commands/gamemodeall.js @@ -5,7 +5,7 @@ module.exports = { description: 'Gamemode everyone', usage: ' ', trusted: 1, - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { + execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { if (args[0] === hash) { bot.core.run(`minecraft:execute unless entity @s[name= run ] run gamemode ${args[1]} @a[name=!${bot.username}]`); } else { diff --git a/commands/help.js b/commands/help.js index 29dfb61..ad0b1a6 100644 --- a/commands/help.js +++ b/commands/help.js @@ -8,7 +8,7 @@ module.exports = { description: 'Shows the help', usage: '[command]', trusted: 0, - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { + execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { const generalCommands = []; const trustedCommands = []; const ownerCommands = []; @@ -68,10 +68,10 @@ module.exports = { usage.pop(); } - bot.tellraw('@a', [{text: prefix + command.name, color: 'gold'}, {text: ` (${alias})`, color: 'white'}, {text: ' - ', color: 'gray'}, {text: command.description, color: 'gray'}]); - bot.tellraw('@a', [{text: 'Trust level: ', color: 'green'}, {text: command.trusted, color: 'yellow'}]); - bot.tellraw('@a', [{text: 'Supported on Discord: ', color: 'green'}, {text: discordSupported, color: 'gold'}]); - bot.tellraw('@a', usage); + bot.tellraw(selector, [{text: prefix + command.name, color: 'gold'}, {text: ` (${alias})`, color: 'white'}, {text: ' - ', color: 'gray'}, {text: command.description, color: 'gray'}]); + bot.tellraw(selector, [{text: 'Trust level: ', color: 'green'}, {text: command.trusted, color: 'yellow'}]); + bot.tellraw(selector, [{text: 'Supported on Discord: ', color: 'green'}, {text: discordSupported, color: 'gold'}]); + bot.tellraw(selector, usage); } if (command.name === args[0]) run(); @@ -81,7 +81,7 @@ module.exports = { }; } else { const pre = [{text: 'Commands ', color: 'gray'}, {text: '(', color: 'dark_gray'}, {text: 'Length: ', color: 'gray'}, {text: bot.command_handler.commands.length, color: 'green'}, {text: ') ', color: 'dark_gray'}, {text: '(', color: 'dark_gray'}, {text: '⬤ Public', color: 'green'}, {text: ' ⬤ Trusted', color: 'red'}, {text: ' ⬤ Owner', color: 'dark_red'}, {text: ') - ', color: 'dark_gray'}]; - bot.tellraw('@a', [pre, generalCommands, trustedCommands, ownerCommands]); + bot.tellraw(selector, [pre, generalCommands, trustedCommands, ownerCommands]); } }, discordExecute: async function(bot, username, usernameraw, sender, prefix, args, channeldc) { diff --git a/commands/list.js b/commands/list.js index 09a7b15..3041bc9 100644 --- a/commands/list.js +++ b/commands/list.js @@ -53,7 +53,7 @@ module.exports = { component.push('\n'); } component.pop(); - bot.tellraw('@a', component); + bot.tellraw(selector, component); } catch (e) { return; } diff --git a/commands/music.js b/commands/music.js index 2fcf6e3..513e314 100644 --- a/commands/music.js +++ b/commands/music.js @@ -1,3 +1,4 @@ +/* eslint-disable require-jsdoc */ /* eslint-disable max-len */ const fs = require('fs/promises'); const {MessageEmbed} = require('discord.js'); @@ -15,7 +16,7 @@ if (os.hostname() === 'chomens-kubuntu') { SONGS_PATH = path.join(__dirname, '..', 'midis'); } -async function play(bot, values, discord, channeldc) { +async function play(bot, values, discord, channeldc, selector) { try { const filepath = values.join(' '); const absolutePath = await resolve(filepath); @@ -29,7 +30,7 @@ async function play(bot, values, discord, channeldc) { .setDescription(`Added ${song.name} to the song queue`); channeldc.send({embeds: [Embed]}); } else { - bot.tellraw('@a', [{text: 'Added ', color: 'white'}, {text: song.name, color: 'gold'}, {text: ' to the song queue', color: 'white'}]); + bot.tellraw(selector, [{text: 'Added ', color: 'white'}, {text: song.name, color: 'gold'}, {text: ' to the song queue', color: 'white'}]); } } catch (e) { if (discord) { @@ -39,12 +40,12 @@ async function play(bot, values, discord, channeldc) { .setDescription(`\`\`\`SyntaxError: Invalid file\`\`\``); channeldc.send({embeds: [Embed]}); } else { - bot.tellraw('@a', {text: 'SyntaxError: Invalid file', color: 'red'}); + bot.tellraw(selector, {text: 'SyntaxError: Invalid file', color: 'red'}); } } } -async function playUrl(bot, values, discord, channeldc) { +async function playUrl(bot, values, discord, channeldc, selector) { try { const url = values.join(' '); const response = await axios.get('https://http-proxy.nongsonchome.repl.co', { @@ -63,7 +64,7 @@ async function playUrl(bot, values, discord, channeldc) { .setDescription(`Added ${song.name} to the song queue`); channeldc.send({embeds: [Embed]}); } else { - bot.tellraw('@a', [{text: 'Added ', color: 'white'}, {text: song.name, color: 'gold'}, {text: ' to the song queue', color: 'white'}]); + bot.tellraw(selector, [{text: 'Added ', color: 'white'}, {text: song.name, color: 'gold'}, {text: ' to the song queue', color: 'white'}]); } } catch (e) { if (discord) { @@ -73,7 +74,7 @@ async function playUrl(bot, values, discord, channeldc) { .setDescription(`\`\`\`SyntaxError: Invalid URL\`\`\``); channeldc.send({embeds: [Embed]}); } else { - bot.tellraw('@a', {text: 'SyntaxError: Invalid URL', color: 'red'}); + bot.tellraw(selector, {text: 'SyntaxError: Invalid URL', color: 'red'}); } } } @@ -85,7 +86,7 @@ async function resolve(filepath) { return filepath; } -async function list(bot, discord, channeldc, prefix) { +async function list(bot, discord, channeldc, prefix, selector) { const absolutePath = await resolve(SONGS_PATH); const listed = await fileList(absolutePath); @@ -125,7 +126,7 @@ async function list(bot, discord, channeldc, prefix) { }}); }); - bot.tellraw('@a', message); + bot.tellraw(selector, message); }; module.exports = { @@ -143,17 +144,17 @@ module.exports = { '', '', ], - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { + execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { switch (args[0]) { case 'play': - play(bot, args.slice(1)); + play(bot, args.slice(1), false, null, selector); break; case 'playurl': - playUrl(bot, args.slice(1)); + playUrl(bot, args.slice(1), false, null, selector); break; case 'stop': try { - bot.tellraw('@a', {text: 'Cleared the song queue'}); + bot.tellraw(selector, {text: 'Cleared the song queue'}); } catch (e) { return; } @@ -161,7 +162,7 @@ module.exports = { break; case 'skip': try { - bot.tellraw('@a', [{text: 'Skipping '}, {text: bot.music.song.name, color: 'gold'}]); + bot.tellraw(selector, [{text: 'Skipping '}, {text: bot.music.song.name, color: 'gold'}]); bot.music.skip(); } catch (e) { throw new Error('No music is currently playing!'); @@ -171,7 +172,7 @@ module.exports = { switch (args[1]) { case 'off': bot.music.loop = 0; - bot.tellraw('@a', [ + bot.tellraw(selector, [ { text: 'Looping is now ', }, @@ -183,7 +184,7 @@ module.exports = { break; case 'current': bot.music.loop = 1; - bot.tellraw('@a', [ + bot.tellraw(selector, [ { text: 'Now Looping ', }, @@ -195,7 +196,7 @@ module.exports = { break; case 'all': bot.music.loop = 2; - bot.tellraw('@a', { + bot.tellraw(selector, { text: 'Now looping every song in the queue', }); break; @@ -204,10 +205,10 @@ module.exports = { } break; case 'list': - list(bot, false, null, prefix); + list(bot, false, null, prefix, selector); break; case 'nowplaying': - bot.tellraw('@a', [ + bot.tellraw(selector, [ { text: 'Now playing ', }, @@ -220,7 +221,7 @@ module.exports = { case 'queue': const queueWithName = []; bot.music.queue.forEach((song) => queueWithName.push(song.name)); - bot.tellraw('@a', [ + bot.tellraw(selector, [ { text: 'Queue: ', color: 'green', diff --git a/commands/netmsg.js b/commands/netmsg.js index 71a5eac..611f4aa 100644 --- a/commands/netmsg.js +++ b/commands/netmsg.js @@ -5,7 +5,7 @@ module.exports = { description: 'Broadcasts a message to all of the servers that the bot is connected', usage: '', trusted: 0, - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { + execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { const component = [ { text: '[', @@ -39,7 +39,7 @@ module.exports = { const bots = bot.getBots(); bots.forEach((bot) => { - bot.tellraw('@a', component); + bot.tellraw(selector, component); }); }, }; diff --git a/commands/refillcore.js b/commands/refillcore.js index 45fbd9e..600af51 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: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { + execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { bot.core.loopPlace(); }, discordExecute: function(bot) { diff --git a/commands/rtp.js b/commands/rtp.js index a9b2ffb..84ec84c 100644 --- a/commands/rtp.js +++ b/commands/rtp.js @@ -6,9 +6,9 @@ module.exports = { description: 'Randomly teleports the player', usage: '', trusted: 0, - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { + execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { const rtppos = `${between(20000000, 500000)} 100 ${between(20000000, 500000)}`; - bot.tellraw('@a', [{text: 'Teleporting ', color: 'white'}, {text: username, color: 'aqua'}, {text: ' to ', color: 'white'}, {text: rtppos, color: 'green'}, {text: '...', color: 'white'}]); + 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 52558ae..96ddebf 100644 --- a/commands/servereval.js +++ b/commands/servereval.js @@ -7,12 +7,12 @@ module.exports = { description: 'Eval command without vm2', trusted: 2, usage: ' ', - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { + execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { if (args[0] === ownerhash) { try { - bot.tellraw('@a', {text: `${util.inspect(eval(args.slice(1).join(' ')), {stylize: stylize})}`.substring(0, 32000)}); + bot.tellraw(selector, {text: `${util.inspect(eval(args.slice(1).join(' ')), {stylize: stylize})}`.substring(0, 32000)}); } catch (err) { - bot.tellraw('@a', {text: `${util.inspect(err).replaceAll('runner', 'chayapak1')}`, color: 'red'}); + bot.tellraw(selector, {text: `${util.inspect(err).replaceAll('runner', 'chayapak1')}`, color: 'red'}); } } else { throw new Error('Invalid OwnerHash'); diff --git a/commands/test.js b/commands/test.js index fe107ce..6817834 100644 --- a/commands/test.js +++ b/commands/test.js @@ -6,8 +6,8 @@ module.exports = { description: 'Tests if the bot is working', usage: '', trusted: 0, - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { - bot.tellraw('@a', [ + execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + bot.tellraw(selector, [ { text: `Username: ${username},`, color: 'green', diff --git a/commands/time.js b/commands/time.js index 09a1a7e..3a8d103 100644 --- a/commands/time.js +++ b/commands/time.js @@ -7,17 +7,17 @@ module.exports = { description: 'Shows the time', usage: '', trusted: 0, - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { + execute: function(bot, username, usernameraw, 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'}]; if (timezone.toLowerCase() === 'asia/bangkok' || timezone.toLowerCase() === 'utc') { - bot.tellraw('@a', component); + bot.tellraw(selector, component); return; } else if (momented === moment().format('dddd, MMMM Do, YYYY, hh:mm:ss A')) { throw new SyntaxError('Invalid timezone'); } else { - bot.tellraw('@a', component); + bot.tellraw(selector, component); } }, discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc) { diff --git a/commands/tpall.js b/commands/tpall.js index 75789a4..5110ac2 100644 --- a/commands/tpall.js +++ b/commands/tpall.js @@ -5,7 +5,7 @@ module.exports = { description: 'Teleport everyone', usage: ' ', trusted: 1, - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { + execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { if (args[0] === hash) { bot.core.run(`minecraft:execute unless entity @s[name= run ] run tp @a ${args.slice(1).join(' ')}`); } else { diff --git a/commands/translate.js b/commands/translate.js index 94c08fa..f43aa11 100644 --- a/commands/translate.js +++ b/commands/translate.js @@ -10,9 +10,9 @@ module.exports = { execute: async function(bot, username, usernameraw, sender, prefix, args) { try { const res = await translate(args.slice(2).join(' '), {from: args[0], to: args[1]}); - bot.tellraw('@a', [{text: 'Result: ', color: 'gold'}, {text: res.text, color: 'green'}]); + bot.tellraw(selector, [{text: 'Result: ', color: 'gold'}, {text: res.text, color: 'green'}]); } catch (e) { - bot.tellraw('@a', {text: String(e), color: 'red'}); + bot.tellraw(selector, {text: String(e), color: 'red'}); } }, discordExecute: async function(bot, username, usernameraw, sender, prefix, args, channeldc, message) { diff --git a/commands/uptime.js b/commands/uptime.js index 375bd43..64cced4 100644 --- a/commands/uptime.js +++ b/commands/uptime.js @@ -7,8 +7,8 @@ module.exports = { description: 'Shows the bot\'s uptime', usage: '', trusted: 0, - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { - bot.tellraw('@a', [{text: 'The bot\'s uptime is ', color: 'white'}, {text: `${secondsToHms(Math.floor(performance.now() / 1000))}`, color: 'green'}]); + execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { + bot.tellraw(selector, [{text: 'The bot\'s uptime is ', color: 'white'}, {text: `${secondsToHms(Math.floor(performance.now() / 1000))}`, color: 'green'}]); }, discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) { const Embed = new MessageEmbed() diff --git a/commands/urban.js b/commands/urban.js index e1b9560..a1c468d 100644 --- a/commands/urban.js +++ b/commands/urban.js @@ -6,14 +6,14 @@ module.exports = { description: 'Working Urban Dictionary', usage: '', trusted: 0, - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { + execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { urban.autocompleteExtra(args[0], (error, results) => { if (error) { - bot.tellraw('@a', [{text: '[', color: 'dark_red'}, {text: 'Urban', color: 'red'}, {text: '] ', color: 'dark_red'}, {text: error.message, color: 'red'}]); + bot.tellraw(selector, [{text: '[', color: 'dark_red'}, {text: 'Urban', color: 'red'}, {text: '] ', color: 'dark_red'}, {text: error.message, color: 'red'}]); return; } results.forEach(({preview, term}) => { - bot.tellraw('@a', [{text: '[', color: 'dark_red'}, {text: 'Urban', color: 'red'}, {text: '] ', color: 'dark_red'}, {text: term, color: 'white'}, {text: ' - ', color: 'white'}, {text: preview, color: 'white'}]); + bot.tellraw(selector, [{text: '[', color: 'dark_red'}, {text: 'Urban', color: 'red'}, {text: '] ', color: 'dark_red'}, {text: term, color: 'white'}, {text: ' - ', color: 'white'}, {text: preview, color: 'white'}]); }); }); }, diff --git a/commands/uuid.js b/commands/uuid.js index 29e78b6..60e4e29 100644 --- a/commands/uuid.js +++ b/commands/uuid.js @@ -6,12 +6,12 @@ module.exports = { description: 'Gets the UUID of a player. If no player specified it will show your UUID instead', usage: '', trusted: 0, - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { + execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { if (args[0]) { const playername = args.join(' '); const player = bot.playersAddedPlayers[playername]; if (player === undefined) throw new SyntaxError('Invalid Username'); - bot.tellraw('@a', + bot.tellraw(selector, [ { text: `${playername}'s UUID: `, @@ -36,7 +36,7 @@ module.exports = { }, ]); } else { - bot.tellraw('@a', + bot.tellraw(selector, [ { text: `Your UUID: `, diff --git a/commands/validate.js b/commands/validate.js index 9ca4c89..247ae54 100644 --- a/commands/validate.js +++ b/commands/validate.js @@ -5,13 +5,13 @@ module.exports = { alias: [], usage: '', trusted: 1, - execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) { + execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { if (args[0] === hash) { - bot.tellraw('@a', {text: 'Valid hash', color: 'green'}); + bot.tellraw(selector, {text: 'Valid hash', color: 'green'}); } else if (args[0] === ownerhash) { - bot.tellraw('@a', {text: 'Valid OwnerHash', color: 'green'}); + bot.tellraw(selector, {text: 'Valid OwnerHash', color: 'green'}); } else { - bot.tellraw('@a', {text: 'Invalid hash', color: 'red'}); + bot.tellraw(selector, {text: 'Invalid hash', color: 'red'}); } }, }; diff --git a/commands/wikipedia.js b/commands/wikipedia.js index c48c91f..4478ad5 100644 --- a/commands/wikipedia.js +++ b/commands/wikipedia.js @@ -12,9 +12,9 @@ module.exports = { try { const page = await wiki.page(args.join(' ')); const summary = await page.summary(); - bot.tellraw('@a', {text: summary.extract, color: 'green'}); + bot.tellraw(selector, {text: summary.extract, color: 'green'}); } catch (e) { - bot.tellraw('@a', {text: e.toString(), color: 'red'}); + bot.tellraw(selector, {text: e.toString(), color: 'red'}); } }, discordExecute: async function(bot, username, usernameraw, sender, prefix, args, channeldc) { diff --git a/plugins/commands.js b/plugins/commands.js index 2e2d8a5..6dc6fab 100644 --- a/plugins/commands.js +++ b/plugins/commands.js @@ -11,7 +11,7 @@ function inject(bot, dcclient, config) { bot.command_handler.commands = loadFiles(path.join(__dirname, config.commandsDir)); }; bot.command_handler.reload(); - bot.command_handler.main = function(prefix, username, usernameraw, message, sender, channeldc, hash, ownerhash) { + bot.command_handler.main = function(prefix, username, usernameraw, message, sender, channeldc, hash, ownerhash, selector) { bot.command_handler.reload(); let raw; let command; @@ -28,7 +28,7 @@ function inject(bot, dcclient, config) { if (typeof command.discordExecute === 'undefined') throw new Error('This command is not yet supported on discord!'); command.discordExecute(bot, username, usernameraw, sender, prefix, args, channeldc, message, config); } else { - command.execute(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash); + command.execute(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector); } } catch (e) { if (prefix === config.discord.prefix) { @@ -42,10 +42,10 @@ function inject(bot, dcclient, config) { } } }; - bot.command_handler.run = function(username, usernameraw, message, sender, channeldc, hash, ownerhash) { + bot.command_handler.run = function(username, usernameraw, message, sender, channeldc, hash, ownerhash, selector = '@a') { for (const prefix of config.prefixes) { if (!message.startsWith(prefix)) continue; - bot.command_handler.main(prefix, username, usernameraw, message, sender, channeldc, hash, ownerhash); + bot.command_handler.main(prefix, username, usernameraw, message, sender, channeldc, hash, ownerhash, selector); } }; bot.on('message', async (_username, _message, _sender) => { diff --git a/plugins/discord.js b/plugins/discord.js index 355aba4..c256c58 100644 --- a/plugins/discord.js +++ b/plugins/discord.js @@ -1,3 +1,4 @@ +/* eslint-disable require-jsdoc */ /* eslint-disable max-len */ const {escapeMarkdown} = require('../util/escapeMarkdown'); async function inject(bot, dcclient, config, rl) { diff --git a/plugins/draw.js b/plugins/draw.js index e0e1c25..3f1b404 100644 --- a/plugins/draw.js +++ b/plugins/draw.js @@ -1,7 +1,14 @@ /* eslint-disable max-len */ const convert = require('color-convert'); +// eslint-disable-next-line require-jsdoc function inject(bot) { + /** + * draw which is totallynotskidded from ybot + * @param {buffer} data data buffer + * @param {*} info idk bout this + * @param {object} prefix prefix in the output compoenent + */ function draw(data, info, prefix = {}) { const pixels = []; diff --git a/plugins/music.js b/plugins/music.js index 1f13128..adb3df1 100644 --- a/plugins/music.js +++ b/plugins/music.js @@ -1,3 +1,4 @@ +/* eslint-disable require-jsdoc */ /* eslint-disable max-len */ const {Midi} = require('@tonejs/midi'); const {convertMidi} = require('../util/midi_converter'); diff --git a/plugins/proxy.js b/plugins/proxy.js index 96870ec..58652c2 100644 --- a/plugins/proxy.js +++ b/plugins/proxy.js @@ -62,6 +62,7 @@ function inject(bot, dcclient, config) { null, 'h', 'o', + client.username, ); } bot.tellraw('@a', {