chomens-bot-js/commands/cowsay.js
2022-11-18 17:10:34 +07:00

33 lines
913 B
JavaScript

/* eslint-disable max-len */
const cowsay = require('cowsay2');
const cows = require('cowsay2/cows');
module.exports = {
name: 'cowsay',
alias: [],
description: 'Moo',
usage: '<cow|list> <message>',
trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
if (args[0]==='list') {
const listed = Object.keys(cows);
let primary = true;
const message = [];
listed.forEach((value) => {
message.push({
text: value + ' ',
color: (!((primary = !primary)) ? 'gold' : 'yellow'),
clickEvent: {
action: 'suggest_command',
value: `${prefix}cowsay ${value} `,
},
});
});
bot.tellraw(selector, message);
} else {
bot.tellraw(selector, {text: `${cowsay.say(args.slice(1).join(' '), {cow: cows[args[0]]})}`});
}
},
};