From c972240c287d80232be136fea432fbc01020225a Mon Sep 17 00:00:00 2001 From: ChomeNS Date: Tue, 8 Nov 2022 21:01:38 +0700 Subject: [PATCH] reaaaa --- commands/cowsay.js | 28 +++++++++++++++++++--------- commands/help.js | 45 +++++++++++++++++++++++++++++++-------------- commands/music.js | 11 ++++++----- 3 files changed, 56 insertions(+), 28 deletions(-) diff --git a/commands/cowsay.js b/commands/cowsay.js index ff31879..82854e9 100644 --- a/commands/cowsay.js +++ b/commands/cowsay.js @@ -9,18 +9,28 @@ module.exports = { trusted: 0, execute: function(bot, username, usernameraw, sender, prefix, args) { if (args[0]==='list') { - let color = '§6'; - let message = ''; + const listed = Object.keys(cows); - Object.keys(cows).forEach((value) => { - if (color === '§6') { - color = '§e'; - } else if (color === '§e') { - color = '§6'; + let color = 'gold'; + const message = []; + + listed.forEach((value) => { + if (color === 'gold') { + color = 'yellow'; + } else if (color === 'yellow') { + color = 'gold'; }; - message += color + value + ' '; + message.push({ + text: value + ' ', + color, + clickEvent: { + action: 'suggest_command', + value: `${prefix}cowsay ${value} `, + }, + }); }); - bot.tellraw('@a', [{text: 'Cows: ', color: 'green'}, '\n', {text: message, color: 'red'}]); + + bot.tellraw('@a', message); } else { bot.tellraw('@a', {text: `${cowsay.say(args.slice(1).join(' '), {cow: cows[args[0]]})}`}); } diff --git a/commands/help.js b/commands/help.js index 8209711..26d4098 100644 --- a/commands/help.js +++ b/commands/help.js @@ -8,24 +8,41 @@ module.exports = { usage: '[command]', trusted: 0, execute: function(bot, username, usernameraw, sender, prefix, args) { - let generalCommands = ''; - let trustedCommands = ''; - let ownerCommands = ''; + const generalCommands = []; + const trustedCommands = []; + const ownerCommands = []; + function component(command, color) { + return { + text: command.name + ' ', + color, + hoverEvent: { + action: 'show_text', + contents: [{ + text: 'Click here to see the information for this command', + color: 'green', + }], + }, + clickEvent: { + action: 'run_command', + value: `${prefix}help ${command.name}`, + }, + }; + }; for (const command of bot.command_handler.commands) { if (command.trusted !== 0) continue; - generalCommands += ' ' + command.name; + generalCommands.push(component(command, 'green')); } for (const command of bot.command_handler.commands) { if (command.trusted !== 1) continue; - trustedCommands += ' ' + command.name; + trustedCommands.push(component(command, 'red')); } for (const command of bot.command_handler.commands) { if (command.trusted !== 2) continue; - ownerCommands += ' ' + command.name; + ownerCommands.push(component(command, 'dark_red')); } if (typeof args[0] !== 'undefined') { for (const command of bot.command_handler.commands) { - function m() { + function run() { let discordSupported; let alias = command.name; if (typeof command.discordExecute === 'undefined') { @@ -42,20 +59,20 @@ module.exports = { bot.tellraw('@a', [{text: prefix + command.name, color: 'gold'}, {text: ' ' + command.usage, color: 'aqua'}]); } - if (command.name === args[0]) m(); + if (command.name === args[0]) run(); for (const alias of command.alias) { - if (alias === args[0]) m(); + if (alias === args[0]) run(); } }; } 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, {text: generalCommands, color: 'green'}, {text: trustedCommands, color: 'red'}, {text: ownerCommands, color: 'dark_red'}]); + 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]); } }, discordExecute: async function(bot, username, usernameraw, sender, prefix, args, channeldc) { if (typeof args[0] !== 'undefined') { for (const command of bot.command_handler.commands) { - function m() { + function run() { let discordSupported; let alias = command.name; if (typeof command.discordExecute === 'undefined') { @@ -76,9 +93,9 @@ module.exports = { channeldc.send({embeds: [Embed]}); } - if (command.name === args[0]) m(); + if (command.name === args[0]) run(); for (const alias of command.alias) { - if (alias === args[0]) m(); + if (alias === args[0]) run(); } }; } else { diff --git a/commands/music.js b/commands/music.js index d740f90..80a8a33 100644 --- a/commands/music.js +++ b/commands/music.js @@ -85,7 +85,7 @@ async function resolve(filepath) { return filepath; } -async function list(bot, discord, channeldc) { +async function list(bot, discord, channeldc, prefix) { const absolutePath = await resolve(SONGS_PATH); const listed = await fileList(absolutePath); @@ -107,11 +107,12 @@ async function list(bot, discord, channeldc) { } else if (color === 'yellow') { color = 'gold'; }; - message.push({text: value + ' ', + message.push({ + text: value + ' ', color, clickEvent: { action: 'suggest_command', - value: `*music play ${value}`, + value: `${prefix}music play ${value}`, }, hoverEvent: { action: 'show_text', @@ -166,7 +167,7 @@ module.exports = { throw new SyntaxError('Invalid argument'); } } else if (args[0] === 'list') { - list(bot); + list(bot, false, null, prefix); } else if (args[0] === 'nowplaying') { bot.tellraw('@a', [{text: 'Now playing '}, {text: bot.music.song.name, color: 'gold'}]); } else { @@ -231,7 +232,7 @@ module.exports = { } } if (args[0] === 'list') { - list(bot, true, channeldc); + list(bot, true, channeldc, prefix); } if (args[0] === 'nowplaying') { const Embed = new MessageEmbed()