This commit is contained in:
ChomeNS 2022-11-08 21:01:38 +07:00
parent 0ec4a8a3ef
commit c972240c28
3 changed files with 56 additions and 28 deletions

View file

@ -9,18 +9,28 @@ module.exports = {
trusted: 0, trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args) {
if (args[0]==='list') { if (args[0]==='list') {
let color = '§6'; const listed = Object.keys(cows);
let message = '';
Object.keys(cows).forEach((value) => { let color = 'gold';
if (color === '§6') { const message = [];
color = '§e';
} else if (color === '§e') { listed.forEach((value) => {
color = '§6'; 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 { } else {
bot.tellraw('@a', {text: `${cowsay.say(args.slice(1).join(' '), {cow: cows[args[0]]})}`}); bot.tellraw('@a', {text: `${cowsay.say(args.slice(1).join(' '), {cow: cows[args[0]]})}`});
} }

View file

@ -8,24 +8,41 @@ module.exports = {
usage: '[command]', usage: '[command]',
trusted: 0, trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args) {
let generalCommands = ''; const generalCommands = [];
let trustedCommands = ''; const trustedCommands = [];
let ownerCommands = ''; 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) { for (const command of bot.command_handler.commands) {
if (command.trusted !== 0) continue; if (command.trusted !== 0) continue;
generalCommands += ' ' + command.name; generalCommands.push(component(command, 'green'));
} }
for (const command of bot.command_handler.commands) { for (const command of bot.command_handler.commands) {
if (command.trusted !== 1) continue; if (command.trusted !== 1) continue;
trustedCommands += ' ' + command.name; trustedCommands.push(component(command, 'red'));
} }
for (const command of bot.command_handler.commands) { for (const command of bot.command_handler.commands) {
if (command.trusted !== 2) continue; if (command.trusted !== 2) continue;
ownerCommands += ' ' + command.name; ownerCommands.push(component(command, 'dark_red'));
} }
if (typeof args[0] !== 'undefined') { if (typeof args[0] !== 'undefined') {
for (const command of bot.command_handler.commands) { for (const command of bot.command_handler.commands) {
function m() { function run() {
let discordSupported; let discordSupported;
let alias = command.name; let alias = command.name;
if (typeof command.discordExecute === 'undefined') { 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'}]); 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) { for (const alias of command.alias) {
if (alias === args[0]) m(); if (alias === args[0]) run();
} }
}; };
} else { } 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'}]; 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'}]); bot.tellraw('@a', [pre, generalCommands, trustedCommands, ownerCommands]);
} }
}, },
discordExecute: async function(bot, username, usernameraw, sender, prefix, args, channeldc) { discordExecute: async function(bot, username, usernameraw, sender, prefix, args, channeldc) {
if (typeof args[0] !== 'undefined') { if (typeof args[0] !== 'undefined') {
for (const command of bot.command_handler.commands) { for (const command of bot.command_handler.commands) {
function m() { function run() {
let discordSupported; let discordSupported;
let alias = command.name; let alias = command.name;
if (typeof command.discordExecute === 'undefined') { if (typeof command.discordExecute === 'undefined') {
@ -76,9 +93,9 @@ module.exports = {
channeldc.send({embeds: [Embed]}); channeldc.send({embeds: [Embed]});
} }
if (command.name === args[0]) m(); if (command.name === args[0]) run();
for (const alias of command.alias) { for (const alias of command.alias) {
if (alias === args[0]) m(); if (alias === args[0]) run();
} }
}; };
} else { } else {

View file

@ -85,7 +85,7 @@ async function resolve(filepath) {
return filepath; return filepath;
} }
async function list(bot, discord, channeldc) { async function list(bot, discord, channeldc, prefix) {
const absolutePath = await resolve(SONGS_PATH); const absolutePath = await resolve(SONGS_PATH);
const listed = await fileList(absolutePath); const listed = await fileList(absolutePath);
@ -107,11 +107,12 @@ async function list(bot, discord, channeldc) {
} else if (color === 'yellow') { } else if (color === 'yellow') {
color = 'gold'; color = 'gold';
}; };
message.push({text: value + ' ', message.push({
text: value + ' ',
color, color,
clickEvent: { clickEvent: {
action: 'suggest_command', action: 'suggest_command',
value: `*music play ${value}`, value: `${prefix}music play ${value}`,
}, },
hoverEvent: { hoverEvent: {
action: 'show_text', action: 'show_text',
@ -166,7 +167,7 @@ module.exports = {
throw new SyntaxError('Invalid argument'); throw new SyntaxError('Invalid argument');
} }
} else if (args[0] === 'list') { } else if (args[0] === 'list') {
list(bot); list(bot, false, null, prefix);
} else if (args[0] === 'nowplaying') { } else if (args[0] === 'nowplaying') {
bot.tellraw('@a', [{text: 'Now playing '}, {text: bot.music.song.name, color: 'gold'}]); bot.tellraw('@a', [{text: 'Now playing '}, {text: bot.music.song.name, color: 'gold'}]);
} else { } else {
@ -231,7 +232,7 @@ module.exports = {
} }
} }
if (args[0] === 'list') { if (args[0] === 'list') {
list(bot, true, channeldc); list(bot, true, channeldc, prefix);
} }
if (args[0] === 'nowplaying') { if (args[0] === 'nowplaying') {
const Embed = new MessageEmbed() const Embed = new MessageEmbed()