mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-18 05:49:49 +02:00
22.0.0
This commit is contained in:
@@ -29,12 +29,7 @@ module.exports = class CleverbotCommand extends Command {
|
||||
|
||||
async run(msg, args) {
|
||||
const { text } = args;
|
||||
msg.channel.startTyping();
|
||||
try {
|
||||
const { response } = await this.clevs.ask(text);
|
||||
return msg.reply(response).then(() => msg.channel.stopTyping());
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
}
|
||||
const { response } = await this.clevs.ask(text);
|
||||
return msg.reply(response);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -14,11 +14,14 @@ module.exports = class EasterEggCommand extends Command {
|
||||
key: 'tag',
|
||||
prompt: 'What easter egg do you want to view?',
|
||||
type: 'string',
|
||||
validate: tag => {
|
||||
if (eastereggs[tag.toLowerCase()]) return true;
|
||||
return 'Nope, that\'s not a valid easter egg. Try again!';
|
||||
validate: (tag) => {
|
||||
if (eastereggs[tag.toLowerCase()]) {
|
||||
return true;
|
||||
} else {
|
||||
return 'Nope, that\'s not a valid easter egg. Try again!';
|
||||
}
|
||||
},
|
||||
parse: tag => tag.toLowerCase()
|
||||
parse: (tag) => tag.toLowerCase()
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
@@ -17,11 +17,14 @@ module.exports = class HoroscopeCommand extends Command {
|
||||
key: 'sign',
|
||||
prompt: 'Which sign would you like to get the horoscope for?',
|
||||
type: 'string',
|
||||
validate: sign => {
|
||||
if (signs.includes(sign.toLowerCase())) return true;
|
||||
return 'Invalid sign. Use `help horoscope` for a list of signs.';
|
||||
validate: (sign) => {
|
||||
if (signs.includes(sign.toLowerCase())) {
|
||||
return true;
|
||||
} else {
|
||||
return 'Invalid sign. Use `help horoscope` for a list of signs.';
|
||||
}
|
||||
},
|
||||
parse: sign => sign.toLowerCase()
|
||||
parse: (sign) => sign.toLowerCase()
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -29,24 +32,20 @@ module.exports = class HoroscopeCommand extends Command {
|
||||
|
||||
async run(msg, args) {
|
||||
const { sign } = args;
|
||||
try {
|
||||
const { text } = await snekfetch
|
||||
.get(`http://sandipbgt.com/theastrologer/api/horoscope/${sign}/today`);
|
||||
const body = JSON.parse(text);
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x9797FF)
|
||||
.setTitle(`Horoscope for ${body.sunsign}...`)
|
||||
.setTimestamp()
|
||||
.setDescription(body.horoscope)
|
||||
.addField('Mood',
|
||||
body.meta.mood, true)
|
||||
.addField('Intensity',
|
||||
body.meta.intensity, true)
|
||||
.addField('Date',
|
||||
body.date, true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
}
|
||||
const { text } = await snekfetch
|
||||
.get(`http://sandipbgt.com/theastrologer/api/horoscope/${sign}/today`);
|
||||
const body = JSON.parse(text);
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x9797FF)
|
||||
.setTitle(`Horoscope for ${body.sunsign}...`)
|
||||
.setTimestamp()
|
||||
.setDescription(body.horoscope)
|
||||
.addField('Mood',
|
||||
body.meta.mood, true)
|
||||
.addField('Intensity',
|
||||
body.meta.intensity, true)
|
||||
.addField('Date',
|
||||
body.date, true);
|
||||
return msg.embed(embed);
|
||||
}
|
||||
};
|
||||
|
||||
+10
-8
@@ -15,23 +15,26 @@ module.exports = class MemeCommand extends Command {
|
||||
key: 'type',
|
||||
prompt: 'What meme type do you want to use?',
|
||||
type: 'string',
|
||||
validate: type => {
|
||||
if (codes.includes(type.toLowerCase())) return true;
|
||||
return 'Invalid meme type. Use `help meme` to view a list of meme types.';
|
||||
validate: (type) => {
|
||||
if (codes.includes(type.toLowerCase())) {
|
||||
return true;
|
||||
} else {
|
||||
return 'Invalid meme type. Use `help meme` to view a list of meme types.';
|
||||
}
|
||||
},
|
||||
parse: type => type.toLowerCase()
|
||||
parse: (type) => type.toLowerCase()
|
||||
},
|
||||
{
|
||||
key: 'top',
|
||||
prompt: 'What should the top row of the meme to be?',
|
||||
type: 'string',
|
||||
parse: top => encodeURIComponent(top.replace(/[ ]/g, '-'))
|
||||
parse: (top) => encodeURIComponent(top.replace(/[ ]/g, '-'))
|
||||
},
|
||||
{
|
||||
key: 'bottom',
|
||||
prompt: 'What should the bottom row of the meme to be?',
|
||||
type: 'string',
|
||||
parse: bottom => encodeURIComponent(bottom.replace(/[ ]/g, '-'))
|
||||
parse: (bottom) => encodeURIComponent(bottom.replace(/[ ]/g, '-'))
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -39,7 +42,6 @@ module.exports = class MemeCommand extends Command {
|
||||
|
||||
run(msg, args) {
|
||||
const { type, top, bottom } = args;
|
||||
return msg.say({ files: [`https://memegen.link/${type}/${top}/${bottom}.jpg`] })
|
||||
.catch(err => msg.say(`${err.name}: ${err.message}`));
|
||||
return msg.say({ files: [`https://memegen.link/${type}/${top}/${bottom}.jpg`] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -22,11 +22,14 @@ module.exports = class SoundboardCommand extends Command {
|
||||
key: 'sound',
|
||||
prompt: 'What sound would you like to play?',
|
||||
type: 'string',
|
||||
validate: sound => {
|
||||
if (names.includes(sound.toLowerCase())) return true;
|
||||
return 'Invalid Sound. Use `help soundboard` for a list of sounds.';
|
||||
validate: (sound) => {
|
||||
if (names.includes(sound.toLowerCase())) {
|
||||
return true;
|
||||
} else {
|
||||
return 'Invalid Sound. Use `help soundboard` for a list of sounds.';
|
||||
}
|
||||
},
|
||||
parse: sound => sound.toLowerCase()
|
||||
parse: (sound) => sound.toLowerCase()
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -34,26 +37,25 @@ module.exports = class SoundboardCommand extends Command {
|
||||
|
||||
async run(msg, args) {
|
||||
const voiceChannel = msg.member.voiceChannel;
|
||||
if (!voiceChannel) return msg.say('Please enter a Voice Channel first.');
|
||||
if (!voiceChannel.permissionsFor(this.client.user).has('CONNECT'))
|
||||
if (!voiceChannel) {
|
||||
return msg.say('Please enter a Voice Channel first.');
|
||||
} else if (!voiceChannel.permissionsFor(this.client.user).has('CONNECT')) {
|
||||
return msg.say('This Command requires the `CONNECT` Permission.');
|
||||
if (!voiceChannel.permissionsFor(this.client.user).has('SPEAK'))
|
||||
} else if (!voiceChannel.permissionsFor(this.client.user).has('SPEAK')) {
|
||||
return msg.say('This Command requires the `SPEAK` Permission.');
|
||||
if (!voiceChannel.joinable) return msg.say('This Voice Channel is not joinable.');
|
||||
const alreadyConnected = this.client.voiceConnections.get(voiceChannel.guild.id);
|
||||
if (alreadyConnected) return msg.say('I am already playing a sound.');
|
||||
const { sound } = args;
|
||||
try {
|
||||
const connection = await voiceChannel.join();
|
||||
msg.react('🔊');
|
||||
const dispatcher = connection.playFile(path.join(__dirname, '..', '..', 'assets', 'sounds', paths[sound]));
|
||||
dispatcher.on('end', () => {
|
||||
voiceChannel.leave();
|
||||
msg.react('✅');
|
||||
return null;
|
||||
});
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
} else if (!voiceChannel.joinable) {
|
||||
return msg.say('This Voice Channel is not joinable.');
|
||||
} else if (this.client.voiceConnections.get(voiceChannel.guild.id)) {
|
||||
return msg.say('I am already playing a sound.');
|
||||
}
|
||||
const { sound } = args;
|
||||
const connection = await voiceChannel.join();
|
||||
msg.react('🔊');
|
||||
const dispatcher = connection.playFile(path.join(__dirname, '..', '..', 'assets', 'sounds', paths[sound]));
|
||||
dispatcher.on('end', () => {
|
||||
voiceChannel.leave();
|
||||
msg.react('✅');
|
||||
return null;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -13,7 +13,6 @@ module.exports = class SpamCommand extends Command {
|
||||
}
|
||||
|
||||
run(msg) {
|
||||
return msg.say({ files: [path.join(__dirname, '..', '..', 'assets', 'images', 'spam.png')] })
|
||||
.catch(err => msg.say(`${err.name}: ${err.message}`));
|
||||
return msg.say({ files: [path.join(__dirname, '..', '..', 'assets', 'images', 'spam.png')] });
|
||||
}
|
||||
};
|
||||
|
||||
+20
-11
@@ -1,5 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const moment = require('moment');
|
||||
|
||||
module.exports = class StarCommand extends Command {
|
||||
@@ -24,23 +25,31 @@ module.exports = class StarCommand extends Command {
|
||||
async run(msg, args, reaction) {
|
||||
const { id } = args;
|
||||
const channel = msg.guild.channels.get(msg.guild.settings.get('starboard'));
|
||||
if (!channel || !channel.permissionsFor(this.client.user).has(['SEND_MESSAGES', 'EMBED_LINKS'])) return null;
|
||||
if (this.starred.includes(id)) return null;
|
||||
try {
|
||||
const message = await msg.channel.fetchMessage(id);
|
||||
if (!reaction && msg.author.id === message.author.id)
|
||||
return msg.reply('You cannot star your own messages, baka.');
|
||||
if (!channel || this.starred.includes(id)) {
|
||||
return null;
|
||||
} else if (!channel.permissionsFor(this.client.user).has('SEND_MESSAGES')) {
|
||||
return msg.say('I do not have Permission to send the message.');
|
||||
}
|
||||
const message = await msg.channel.fetchMessage(id);
|
||||
if (!reaction && msg.author.id === message.author.id) {
|
||||
return msg.reply('You cannot star your own messages, baka.');
|
||||
}
|
||||
this.starred.push(id);
|
||||
if (!channel.permissionsFor(this.client.user).has('EMBED_LINKS')) {
|
||||
return msg.say(stripIndents`
|
||||
**Author:** ${message.author.tag}
|
||||
**Content:** ${message.content}
|
||||
**Date:** ${moment(message.createdTimestamp).format('MMMM Do YYYY h:mm:ss A')}
|
||||
${message.attachments.first() ? `**Image:** ${message.attachments.first().url}` : ''}
|
||||
`);
|
||||
} else {
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xFFFF00)
|
||||
.setAuthor(message.author.tag, message.author.displayAvatarURL)
|
||||
.setDescription(message.content)
|
||||
.setImage(message.attachments.first() ? message.attachments.first().url : null)
|
||||
.setFooter(moment(message.createdTimestamp).format('MMMM Do YYYY h:mm:ss A'));
|
||||
this.starred.push(id);
|
||||
await channel.send({ embed });
|
||||
return null;
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
return channel.send({ embed });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { FriendlyError } = require('discord.js-commando');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
@@ -14,9 +15,12 @@ module.exports = class StrawpollCommand extends Command {
|
||||
key: 'title',
|
||||
prompt: 'What would you like the title of the Strawpoll to be?',
|
||||
type: 'string',
|
||||
validate: title => {
|
||||
if (title.length < 200) return true;
|
||||
return 'Invalid Title. Title must be under 200 characters.';
|
||||
validate: (title) => {
|
||||
if (title.length < 200) {
|
||||
return true;
|
||||
} else {
|
||||
return 'Invalid Title. Title must be under 200 characters.';
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -24,9 +28,12 @@ module.exports = class StrawpollCommand extends Command {
|
||||
prompt: 'What options do you want me pick from? Maximum of 31.',
|
||||
type: 'string',
|
||||
infinite: true,
|
||||
validate: choice => {
|
||||
if (choice.length < 160) return true;
|
||||
return 'Invalid Choice. Choices must be under 140 characters each.';
|
||||
validate: (choice) => {
|
||||
if (choice.length < 160) {
|
||||
return true;
|
||||
} else {
|
||||
return 'Invalid Choice. Choices must be under 140 characters each.';
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -35,18 +42,17 @@ module.exports = class StrawpollCommand extends Command {
|
||||
|
||||
async run(msg, args) {
|
||||
const { title, options } = args;
|
||||
if (options.length < 2) return msg.say('You provided less than two choices.');
|
||||
if (options.length > 31) return msg.say('You provided more than thirty choices.');
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.post('https://strawpoll.me/api/v2/polls')
|
||||
.send({ title, options });
|
||||
return msg.say(stripIndents`
|
||||
${body.title}
|
||||
http://strawpoll.me/${body.id}
|
||||
`);
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
if (options.length < 2) {
|
||||
throw new FriendlyError('You provided less than two choices.');
|
||||
} else if (options.length > 31) {
|
||||
throw new FriendlyError('You provided more than thirty choices.');
|
||||
}
|
||||
const { body } = await snekfetch
|
||||
.post('https://strawpoll.me/api/v2/polls')
|
||||
.send({ title, options });
|
||||
return msg.say(stripIndents`
|
||||
${body.title}
|
||||
http://strawpoll.me/${body.id}
|
||||
`);
|
||||
}
|
||||
};
|
||||
|
||||
+12
-16
@@ -14,21 +14,17 @@ module.exports = class TodayCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { text } = await snekfetch
|
||||
.get('http://history.muffinlabs.com/date');
|
||||
const body = JSON.parse(text);
|
||||
const events = body.data.Events;
|
||||
const event = events[Math.floor(Math.random() * events.length)];
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x9797FF)
|
||||
.setURL(body.url)
|
||||
.setTitle(`On this day (${body.date})...`)
|
||||
.setTimestamp()
|
||||
.setDescription(`${event.year}: ${event.text}`);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
}
|
||||
const { text } = await snekfetch
|
||||
.get('http://history.muffinlabs.com/date');
|
||||
const body = JSON.parse(text);
|
||||
const events = body.data.Events;
|
||||
const event = events[Math.floor(Math.random() * events.length)];
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x9797FF)
|
||||
.setURL(body.url)
|
||||
.setTitle(`On this day (${body.date})...`)
|
||||
.setTimestamp()
|
||||
.setDescription(`${event.year}: ${event.text}`);
|
||||
return msg.embed(embed);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -15,17 +15,13 @@ module.exports = class WouldYouRatherCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('http://www.rrrather.com/botapi');
|
||||
const embed = new RichEmbed()
|
||||
.setTitle(`${body.title}...`)
|
||||
.setURL(body.link)
|
||||
.setColor(0x9797FF)
|
||||
.setDescription(`${body.choicea} OR ${body.choiceb}?`);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
}
|
||||
const { body } = await snekfetch
|
||||
.get('http://www.rrrather.com/botapi');
|
||||
const embed = new RichEmbed()
|
||||
.setTitle(`${body.title}...`)
|
||||
.setURL(body.link)
|
||||
.setColor(0x9797FF)
|
||||
.setDescription(`${body.choicea} OR ${body.choiceb}?`);
|
||||
return msg.embed(embed);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user