mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-25 14:21:41 +02:00
Better Error Handling
This commit is contained in:
@@ -35,7 +35,7 @@ module.exports = class YearsCommand extends Command {
|
|||||||
avatar.resize(200, 200);
|
avatar.resize(200, 200);
|
||||||
az.composite(avatar, 461, 127);
|
az.composite(avatar, 461, 127);
|
||||||
az.getBuffer(Jimp.MIME_PNG, (err, buff) => {
|
az.getBuffer(Jimp.MIME_PNG, (err, buff) => {
|
||||||
if(err) return msg.say('An Unknown Error Occurred.');
|
if(err) return msg.say(`An Error Occurred: ${err}`);
|
||||||
return msg.channel.send({ files: [{ attachment: buff, name: 'az.png' }] })
|
return msg.channel.send({ files: [{ attachment: buff, name: 'az.png' }] })
|
||||||
.catch(err => msg.say(`An Error Occurred: ${err}`));
|
.catch(err => msg.say(`An Error Occurred: ${err}`));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ module.exports = class BeautifulCommand extends Command {
|
|||||||
grunkle.composite(avatar, 341, 35);
|
grunkle.composite(avatar, 341, 35);
|
||||||
grunkle.composite(avatar, 342, 301);
|
grunkle.composite(avatar, 342, 301);
|
||||||
grunkle.getBuffer(Jimp.MIME_PNG, (err, buff) => {
|
grunkle.getBuffer(Jimp.MIME_PNG, (err, buff) => {
|
||||||
if(err) return msg.say('An Unknown Error Occurred.');
|
if(err) return msg.say(`An Error Occurred: ${err}`);
|
||||||
return msg.channel.send({ files: [{ attachment: buff, name: 'beautiful.png' }] })
|
return msg.channel.send({ files: [{ attachment: buff, name: 'beautiful.png' }] })
|
||||||
.catch(err => msg.say(`An Error Occurred: ${err}`));
|
.catch(err => msg.say(`An Error Occurred: ${err}`));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ module.exports = class BobRossCommand extends Command {
|
|||||||
blank.composite(avatar, 44, 85);
|
blank.composite(avatar, 44, 85);
|
||||||
blank.composite(bob, 0, 0);
|
blank.composite(bob, 0, 0);
|
||||||
blank.getBuffer(Jimp.MIME_PNG, (err, buff) => {
|
blank.getBuffer(Jimp.MIME_PNG, (err, buff) => {
|
||||||
if(err) return msg.say('An Unknown Error Occurred.');
|
if(err) return msg.say(`An Error Occurred: ${err}`);
|
||||||
return msg.channel.send({ files: [{ attachment: buff, name: 'bobross.png' }] })
|
return msg.channel.send({ files: [{ attachment: buff, name: 'bobross.png' }] })
|
||||||
.catch(err => msg.say(`An Error Occurred: ${err}`));
|
.catch(err => msg.say(`An Error Occurred: ${err}`));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ module.exports = class GreyscaleCommand extends Command {
|
|||||||
const avatar = await Jimp.read(avatarURL);
|
const avatar = await Jimp.read(avatarURL);
|
||||||
avatar.greyscale();
|
avatar.greyscale();
|
||||||
avatar.getBuffer(Jimp.MIME_PNG, (err, buff) => {
|
avatar.getBuffer(Jimp.MIME_PNG, (err, buff) => {
|
||||||
if(err) return msg.say('An Unknown Error Occurred.');
|
if(err) return msg.say(`An Error Occurred: ${err}`);
|
||||||
return msg.channel.send({ files: [{ attachment: buff, name: 'greyscale.png' }] })
|
return msg.channel.send({ files: [{ attachment: buff, name: 'greyscale.png' }] })
|
||||||
.catch(err => msg.say(`An Error Occurred: ${err}`));
|
.catch(err => msg.say(`An Error Occurred: ${err}`));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ module.exports = class InvertCommand extends Command {
|
|||||||
const avatar = await Jimp.read(avatarURL);
|
const avatar = await Jimp.read(avatarURL);
|
||||||
avatar.invert();
|
avatar.invert();
|
||||||
avatar.getBuffer(Jimp.MIME_PNG, (err, buff) => {
|
avatar.getBuffer(Jimp.MIME_PNG, (err, buff) => {
|
||||||
if(err) return msg.say('An Unknown Error Occurred.');
|
if(err) return msg.say(`An Error Occurred: ${err}`);
|
||||||
return msg.channel.send({ files: [{ attachment: buff, name: 'invert.png' }] })
|
return msg.channel.send({ files: [{ attachment: buff, name: 'invert.png' }] })
|
||||||
.catch(err => msg.say(`An Error Occurred: ${err}`));
|
.catch(err => msg.say(`An Error Occurred: ${err}`));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ module.exports = class RIPCommand extends Command {
|
|||||||
avatar.resize(200, 200);
|
avatar.resize(200, 200);
|
||||||
grave.composite(avatar, 158, 51);
|
grave.composite(avatar, 158, 51);
|
||||||
grave.getBuffer(Jimp.MIME_PNG, (err, buff) => {
|
grave.getBuffer(Jimp.MIME_PNG, (err, buff) => {
|
||||||
if(err) return msg.say('An Unknown Error Occurred.');
|
if(err) return msg.say(`An Error Occurred: ${err}`);
|
||||||
return msg.channel.send({ files: [{ attachment: buff, name: 'rip.png' }] })
|
return msg.channel.send({ files: [{ attachment: buff, name: 'rip.png' }] })
|
||||||
.catch(err => msg.say(`An Error Occurred: ${err}`));
|
.catch(err => msg.say(`An Error Occurred: ${err}`));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ module.exports = class SteamCardCommand extends Command {
|
|||||||
blank.composite(card, 0, 0);
|
blank.composite(card, 0, 0);
|
||||||
blank.print(font, 38, 20, username);
|
blank.print(font, 38, 20, username);
|
||||||
blank.getBuffer(Jimp.MIME_PNG, (err, buff) => {
|
blank.getBuffer(Jimp.MIME_PNG, (err, buff) => {
|
||||||
if(err) return msg.say('An Unknown Error Occurred.');
|
if(err) return msg.say(`An Error Occurred: ${err}`);
|
||||||
return msg.channel.send({ files: [{ attachment: buff, name: 'steamcard.png' }] })
|
return msg.channel.send({ files: [{ attachment: buff, name: 'steamcard.png' }] })
|
||||||
.catch(err => msg.say(`An Error Occurred: ${err}`));
|
.catch(err => msg.say(`An Error Occurred: ${err}`));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ module.exports = class TriggeredCommand extends Command {
|
|||||||
blank.composite(avatar, 0, 0);
|
blank.composite(avatar, 0, 0);
|
||||||
blank.composite(triggered, 0, 0);
|
blank.composite(triggered, 0, 0);
|
||||||
blank.getBuffer(Jimp.MIME_PNG, (err, buff) => {
|
blank.getBuffer(Jimp.MIME_PNG, (err, buff) => {
|
||||||
if(err) return msg.say('An Unknown Error Occurred.');
|
if(err) return msg.say(`An Error Occurred: ${err}`);
|
||||||
return msg.channel.send({ files: [{ attachment: buff, name: 'triggered.png' }] })
|
return msg.channel.send({ files: [{ attachment: buff, name: 'triggered.png' }] })
|
||||||
.catch(err => msg.say(`An Error Occurred: ${err}`));
|
.catch(err => msg.say(`An Error Occurred: ${err}`));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ module.exports = class WantedCommand extends Command {
|
|||||||
avatar.resize(500, 500);
|
avatar.resize(500, 500);
|
||||||
wanted.composite(avatar, 189, 438);
|
wanted.composite(avatar, 189, 438);
|
||||||
wanted.getBuffer(Jimp.MIME_PNG, (err, buff) => {
|
wanted.getBuffer(Jimp.MIME_PNG, (err, buff) => {
|
||||||
if(err) return msg.say('An Unknown Error Occurred.');
|
if(err) return msg.say(`An Error Occurred: ${err}`);
|
||||||
return msg.channel.send({ files: [{ attachment: buff, name: 'wanted.png' }] })
|
return msg.channel.send({ files: [{ attachment: buff, name: 'wanted.png' }] })
|
||||||
.catch(err => msg.say(`An Error Occurred: ${err}`));
|
.catch(err => msg.say(`An Error Occurred: ${err}`));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
const { Command } = require('discord.js-commando');
|
const { Command } = require('discord.js-commando');
|
||||||
const { RichEmbed } = require('discord.js');
|
const { RichEmbed } = require('discord.js');
|
||||||
const { stripIndents } = require('common-tags');
|
|
||||||
const math = require('mathjs');
|
const math = require('mathjs');
|
||||||
const operations = ['+', '-', '*'];
|
const operations = ['+', '-', '*'];
|
||||||
|
|
||||||
@@ -14,12 +13,11 @@ module.exports = class MathGameCommand extends Command {
|
|||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
key: 'difficulty',
|
key: 'difficulty',
|
||||||
prompt: 'What should the difficulty of the math game be? `Easy`, `Medium`, `Hard`, `Extreme`, or `Impossible`?',
|
prompt: 'What should the difficulty of the game be? `Easy`, `Medium`, `Hard`, `Extreme`, or `Impossible`?',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
validate: difficulty => {
|
validate: difficulty => {
|
||||||
if(['easy', 'medium', 'hard', 'extreme', 'impossible'].includes(difficulty.toLowerCase()))
|
if(['easy', 'medium', 'hard', 'extreme', 'impossible'].includes(difficulty.toLowerCase())) return true;
|
||||||
return true;
|
return 'The difficulty must be either `easy`, `medium`, `hard`, `extreme`, or `impossible`.';
|
||||||
return 'Please set the difficulty to either `easy`, `medium`, `hard`, `extreme`, or `impossible`.';
|
|
||||||
},
|
},
|
||||||
parse: difficulty => difficulty.toLowerCase()
|
parse: difficulty => difficulty.toLowerCase()
|
||||||
}
|
}
|
||||||
@@ -64,16 +62,10 @@ module.exports = class MathGameCommand extends Command {
|
|||||||
errors: ['time']
|
errors: ['time']
|
||||||
});
|
});
|
||||||
if(collected.first().content !== solved)
|
if(collected.first().content !== solved)
|
||||||
return msg.say(stripIndents`
|
return msg.say(`Nope! The correct answer is: ${solved}.`);
|
||||||
Aw... Too bad, try again next time!
|
return msg.say(`Perfect! ${solved} is the correct answer!`);
|
||||||
The correct answer is: ${solved}
|
|
||||||
`);
|
|
||||||
return msg.say(`Good Job! You won! ${solved} is the correct answer!`);
|
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say(stripIndents`
|
return msg.say(`Time! The correct answer is ${solved}.`);
|
||||||
Aw... Too bad, try again next time!
|
|
||||||
The correct answer is: ${solved}
|
|
||||||
`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -38,16 +38,13 @@ module.exports = class QuizCommand extends Command {
|
|||||||
errors: ['time']
|
errors: ['time']
|
||||||
});
|
});
|
||||||
if(collected.first().content.toLowerCase() !== answer)
|
if(collected.first().content.toLowerCase() !== answer)
|
||||||
return msg.say(`The correct answer is: ${answer}`);
|
return msg.say(`The correct answer is: ${answer}.`);
|
||||||
return msg.say(`Perfect! The correct answer is: ${answer}`);
|
return msg.say(`Perfect! The correct answer is: ${answer}.`);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say(stripIndents`
|
return msg.say(`Time! The correct answer is: ${answer}`);
|
||||||
Aw... Too bad, try again next time!
|
|
||||||
The Correct Answer was: ${answer}
|
|
||||||
`);
|
|
||||||
}
|
}
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say('An Unknown Error Occurred.');
|
return msg.say(`An Error Occurred: ${err}.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,8 +17,7 @@ module.exports = class RockPaperScissorsCommand extends Command {
|
|||||||
prompt: '`Rock`, `Paper`, or `Scissors`?',
|
prompt: '`Rock`, `Paper`, or `Scissors`?',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
validate: choice => {
|
validate: choice => {
|
||||||
if(['rock', 'paper', 'scissors'].includes(choice.toLowerCase()))
|
if(['rock', 'paper', 'scissors'].includes(choice.toLowerCase())) return true;
|
||||||
return true;
|
|
||||||
return 'Please enter either `rock`, `paper`, or `scissors`.';
|
return 'Please enter either `rock`, `paper`, or `scissors`.';
|
||||||
},
|
},
|
||||||
parse: choice => choice.toLowerCase()
|
parse: choice => choice.toLowerCase()
|
||||||
|
|||||||
@@ -12,12 +12,11 @@ module.exports = class TypingGameCommand extends Command {
|
|||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
key: 'difficulty',
|
key: 'difficulty',
|
||||||
prompt: 'What should the difficulty of the typing game be? `Easy`, `Medium`, `Hard`, `Extreme`, or `Impossible`?',
|
prompt: 'What should the difficulty of the game be? `Easy`, `Medium`, `Hard`, `Extreme`, or `Impossible`?',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
validate: difficulty => {
|
validate: difficulty => {
|
||||||
if(['easy', 'medium', 'hard', 'extreme', 'impossible'].includes(difficulty.toLowerCase()))
|
if(['easy', 'medium', 'hard', 'extreme', 'impossible'].includes(difficulty.toLowerCase())) return true;
|
||||||
return true;
|
return 'The difficulty must be either `easy`, `medium`, `hard`, `extreme`, or `impossible`.';
|
||||||
return 'Please set the difficulty to either `easy`, `medium`, `hard`, `extreme`, or `impossible`.';
|
|
||||||
},
|
},
|
||||||
parse: difficulty => difficulty.toLowerCase()
|
parse: difficulty => difficulty.toLowerCase()
|
||||||
}
|
}
|
||||||
@@ -63,7 +62,7 @@ module.exports = class TypingGameCommand extends Command {
|
|||||||
return msg.say('Nope, your sentence does not match the original. Try again next time!');
|
return msg.say('Nope, your sentence does not match the original. Try again next time!');
|
||||||
return msg.say(`Good Job! You won!`);
|
return msg.say(`Good Job! You won!`);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say('Aw... Too bad, try again next time!');
|
return msg.say('Time! Try again next time!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,9 +15,8 @@ module.exports = class MemeCommand extends Command {
|
|||||||
prompt: 'What meme type do you want to use?',
|
prompt: 'What meme type do you want to use?',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
validate: type => {
|
validate: type => {
|
||||||
if(codes.includes(type.toLowerCase()))
|
if(codes.includes(type.toLowerCase())) return true;
|
||||||
return true;
|
return 'Invalid meme type. Use `help meme` to view a list of meme types.';
|
||||||
return `${type.toLowerCase()} is not a valid meme type. Use \`help meme\` to view a list of types.`;
|
|
||||||
},
|
},
|
||||||
parse: type => type.toLowerCase()
|
parse: type => type.toLowerCase()
|
||||||
},
|
},
|
||||||
@@ -25,23 +24,13 @@ module.exports = class MemeCommand extends Command {
|
|||||||
key: 'top',
|
key: 'top',
|
||||||
prompt: 'What should the top row of the meme to be?',
|
prompt: 'What should the top row of the meme to be?',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
validate: top => {
|
parse: top => encodeURIComponent(top.replace(/[ ]/g, '-'))
|
||||||
if(/[a-zA-Z0-9.,!?'\s]+$/g.test(top) && top.length < 100)
|
|
||||||
return true;
|
|
||||||
return `Please do not use special characters and keep the rows under 100 characters each, top row has ${top.length}.`;
|
|
||||||
},
|
|
||||||
parse: top => top.replace(/[ ]/g, '-').replace(/[?]/g, '~q')
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'bottom',
|
key: 'bottom',
|
||||||
prompt: 'What should the bottom row of the meme to be?',
|
prompt: 'What should the bottom row of the meme to be?',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
validate: bottom => {
|
parse: bottom => encodeURIComponent(bottom.replace(/[ ]/g, '-'))
|
||||||
if(/[a-zA-Z0-9.,!?'\s]+$/g.test(bottom) && bottom.length < 100)
|
|
||||||
return true;
|
|
||||||
return `Please do not use special characters and keep the rows under 100 characters each, bottom row has ${bottom.length}.`;
|
|
||||||
},
|
|
||||||
parse: bottom => bottom.replace(/[ ]/g, '-').replace(/[?]/g, '~q')
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ module.exports = class BanCommand extends Command {
|
|||||||
],
|
],
|
||||||
group: 'moderation',
|
group: 'moderation',
|
||||||
memberName: 'ban',
|
memberName: 'ban',
|
||||||
description: 'Bans a user and logs the ban to the mod_logs.',
|
description: 'Bans a user and logs the ban to the mod logs.',
|
||||||
guildOnly: true,
|
guildOnly: true,
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
@@ -24,9 +24,8 @@ module.exports = class BanCommand extends Command {
|
|||||||
prompt: 'What do you want to set the reason as?',
|
prompt: 'What do you want to set the reason as?',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
validate: reason => {
|
validate: reason => {
|
||||||
if(reason.length < 140)
|
if(reason.length < 140) return true;
|
||||||
return true;
|
return 'Invalid Reason. Reason must be under 140 characters.';
|
||||||
return `Please keep your reason under 140 characters, you have ${reason.length}.`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -55,7 +54,7 @@ module.exports = class BanCommand extends Command {
|
|||||||
Reason: ${reason}.
|
Reason: ${reason}.
|
||||||
`);
|
`);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
await msg.say('Failed to send DM to user.');
|
await msg.say('Failed to send DM to the user.');
|
||||||
}
|
}
|
||||||
await member.ban({ days: 7, reason });
|
await member.ban({ days: 7, reason });
|
||||||
await msg.say(':ok_hand:');
|
await msg.say(':ok_hand:');
|
||||||
@@ -70,7 +69,7 @@ module.exports = class BanCommand extends Command {
|
|||||||
`);
|
`);
|
||||||
return modlogs.send({ embed });
|
return modlogs.send({ embed });
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say('An Unknown Error Occurred.');
|
return msg.say(`An Error Occurred: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ module.exports = class KickCommand extends Command {
|
|||||||
name: 'kick',
|
name: 'kick',
|
||||||
group: 'moderation',
|
group: 'moderation',
|
||||||
memberName: 'kick',
|
memberName: 'kick',
|
||||||
description: 'Kicks a user and logs the kick to the mod_logs.',
|
description: 'Kicks a user and logs the kick to the mod logs.',
|
||||||
guildOnly: true,
|
guildOnly: true,
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
@@ -21,9 +21,8 @@ module.exports = class KickCommand extends Command {
|
|||||||
prompt: 'What do you want to set the reason as?',
|
prompt: 'What do you want to set the reason as?',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
validate: reason => {
|
validate: reason => {
|
||||||
if(reason.length < 140)
|
if(reason.length < 140) return true;
|
||||||
return true;
|
return 'Invalid Reason. Reason must be under 140 characters.';
|
||||||
return `Please keep your reason under 140 characters, you have ${reason.length}.`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -67,7 +66,7 @@ module.exports = class KickCommand extends Command {
|
|||||||
`);
|
`);
|
||||||
return modlogs.send({ embed });
|
return modlogs.send({ embed });
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say('An Unknown Error Occurred.');
|
return msg.say(`An Error Occurred: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,8 +15,7 @@ module.exports = class LockdownCommand extends Command {
|
|||||||
prompt: 'Please enter either `start` or `stop`.',
|
prompt: 'Please enter either `start` or `stop`.',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
validate: type => {
|
validate: type => {
|
||||||
if(['start', 'stop'].includes(type.toLowerCase()))
|
if(['start', 'stop'].includes(type.toLowerCase())) return true;
|
||||||
return true;
|
|
||||||
return 'Please enter either `start` or `stop`.';
|
return 'Please enter either `start` or `stop`.';
|
||||||
},
|
},
|
||||||
parse: type => type.toLowerCase()
|
parse: type => type.toLowerCase()
|
||||||
@@ -38,17 +37,17 @@ module.exports = class LockdownCommand extends Command {
|
|||||||
await msg.channel.overwritePermissions(msg.guild.defaultRole, { SEND_MESSAGES: false });
|
await msg.channel.overwritePermissions(msg.guild.defaultRole, { SEND_MESSAGES: false });
|
||||||
return msg.say(stripIndents`
|
return msg.say(stripIndents`
|
||||||
Lockdown Started, users without Administrator can no longer post messages.
|
Lockdown Started, users without Administrator can no longer post messages.
|
||||||
Please use \`;lockdown stop\` to end the lockdown.
|
Please use \`lockdown stop\` to end the lockdown.
|
||||||
`);
|
`);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say('Something went wrong!');
|
return msg.say(`An Error Occurred: ${err}`);
|
||||||
}
|
}
|
||||||
} else if(type === 'stop') {
|
} else if(type === 'stop') {
|
||||||
try {
|
try {
|
||||||
await msg.channel.overwritePermissions(msg.guild.defaultRole, { SEND_MESSAGES: true });
|
await msg.channel.overwritePermissions(msg.guild.defaultRole, { SEND_MESSAGES: true });
|
||||||
return msg.say('Lockdown Ended, users without Administrator can now post messages.');
|
return msg.say('Lockdown Ended, users without Administrator can now post messages.');
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say('An Unknown Error Occurred.');
|
return msg.say(`An Error Occurred: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,9 +19,8 @@ module.exports = class PruneCommand extends Command {
|
|||||||
prompt: 'How many messages do you want to delete? Limit of up to 99.',
|
prompt: 'How many messages do you want to delete? Limit of up to 99.',
|
||||||
type: 'integer',
|
type: 'integer',
|
||||||
validate: count => {
|
validate: count => {
|
||||||
if(count < 100 && count > 0)
|
if(count < 100 && count > 0) return true;
|
||||||
return true;
|
return 'Invalid Count. Count must be from 1-99.';
|
||||||
return `${count} is not a valid amount of messages. Limit 1-99.`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ module.exports = class SoftbanCommand extends Command {
|
|||||||
name: 'softban',
|
name: 'softban',
|
||||||
group: 'moderation',
|
group: 'moderation',
|
||||||
memberName: 'softban',
|
memberName: 'softban',
|
||||||
description: 'Kicks a user and deletes their messages, and logs the softban to the mod_logs.',
|
description: 'Kicks a user and deletes their messages, and logs the softban to the mod logs.',
|
||||||
guildOnly: true,
|
guildOnly: true,
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
@@ -21,9 +21,8 @@ module.exports = class SoftbanCommand extends Command {
|
|||||||
prompt: 'What do you want to set the reason as?',
|
prompt: 'What do you want to set the reason as?',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
validate: reason => {
|
validate: reason => {
|
||||||
if(reason.length < 140)
|
if(reason.length < 140) return true;
|
||||||
return true;
|
return 'Invalid Reason. Reason must be under 140 characters.';
|
||||||
return `Please keep your reason under 140 characters, you have ${reason.length}.`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -70,7 +69,7 @@ module.exports = class SoftbanCommand extends Command {
|
|||||||
`);
|
`);
|
||||||
return modlogs.send({ embed });
|
return modlogs.send({ embed });
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say('An Unknown Error Occurred.');
|
return msg.say(`An Error Occurred: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ module.exports = class UnbanCommand extends Command {
|
|||||||
],
|
],
|
||||||
group: 'moderation',
|
group: 'moderation',
|
||||||
memberName: 'unban',
|
memberName: 'unban',
|
||||||
description: 'Unbans a user and logs the unban to the mod_logs.',
|
description: 'Unbans a user and logs the unban to the mod logs.',
|
||||||
guildOnly: true,
|
guildOnly: true,
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
@@ -19,9 +19,8 @@ module.exports = class UnbanCommand extends Command {
|
|||||||
prompt: 'What member do you want to unban? Please enter the ID of the user.',
|
prompt: 'What member do you want to unban? Please enter the ID of the user.',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
validate: id => {
|
validate: id => {
|
||||||
if(id.length === 18)
|
if(id.length === 18) return true;
|
||||||
return true;
|
return 'Invalid ID.';
|
||||||
return `${id} is not a valid ID. Please enter the user you wish to unban's ID.`;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -29,9 +28,8 @@ module.exports = class UnbanCommand extends Command {
|
|||||||
prompt: 'What do you want to set the reason as?',
|
prompt: 'What do you want to set the reason as?',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
validate: reason => {
|
validate: reason => {
|
||||||
if(reason.length < 140)
|
if(reason.length < 140) return true;
|
||||||
return true;
|
return 'Invalid Reason. Reason must be under 140 characters.';
|
||||||
return `Please keep your reason under 140 characters, you have ${reason.length}.`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -45,7 +43,7 @@ module.exports = class UnbanCommand extends Command {
|
|||||||
async run(msg, args) {
|
async run(msg, args) {
|
||||||
if(!msg.channel.permissionsFor(this.client.user).has('BAN_MEMBERS'))
|
if(!msg.channel.permissionsFor(this.client.user).has('BAN_MEMBERS'))
|
||||||
return msg.say('This Command requires the `Ban Members` Permission.');
|
return msg.say('This Command requires the `Ban Members` Permission.');
|
||||||
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog', 'mod_logs'));
|
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog'));
|
||||||
if(!modlogs)
|
if(!modlogs)
|
||||||
return msg.say('This Command requires a channel set with the `modchannel` command.');
|
return msg.say('This Command requires a channel set with the `modchannel` command.');
|
||||||
if(!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
|
if(!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
|
||||||
@@ -69,7 +67,7 @@ module.exports = class UnbanCommand extends Command {
|
|||||||
`);
|
`);
|
||||||
return modlogs.send({ embed });
|
return modlogs.send({ embed });
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say('An Unknown Error Occurred.');
|
return msg.say(`An Error Occurred: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ module.exports = class WarnCommand extends Command {
|
|||||||
name: 'warn',
|
name: 'warn',
|
||||||
group: 'moderation',
|
group: 'moderation',
|
||||||
memberName: 'warn',
|
memberName: 'warn',
|
||||||
description: 'Warns a user and logs the warn to the mod_logs.',
|
description: 'Warns a user and logs the warn to the mod logs.',
|
||||||
guildOnly: true,
|
guildOnly: true,
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
@@ -21,9 +21,8 @@ module.exports = class WarnCommand extends Command {
|
|||||||
prompt: 'What do you want to set the reason as?',
|
prompt: 'What do you want to set the reason as?',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
validate: reason => {
|
validate: reason => {
|
||||||
if(reason.length < 140)
|
if(reason.length < 140) return true;
|
||||||
return true;
|
return 'Invalid Reason. Reason must be under 140 characters.';
|
||||||
return `Please keep your reason under 140 characters, you have ${reason.length}.`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -35,7 +34,7 @@ module.exports = class WarnCommand extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async run(msg, args) {
|
async run(msg, args) {
|
||||||
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog', 'mod_logs'));
|
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog'));
|
||||||
if(!modlogs)
|
if(!modlogs)
|
||||||
return msg.say('This Command requires a channel set with the `modchannel` command.');
|
return msg.say('This Command requires a channel set with the `modchannel` command.');
|
||||||
if(!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
|
if(!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
|
||||||
@@ -54,7 +53,7 @@ module.exports = class WarnCommand extends Command {
|
|||||||
`);
|
`);
|
||||||
return modlogs.send({ embed });
|
return modlogs.send({ embed });
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say('An Unknown Error Occurred.');
|
return msg.say(`An Error Occurred: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,9 +16,8 @@ module.exports = class CurrencyCommand extends Command {
|
|||||||
prompt: 'What currency code do you want to use as the base?',
|
prompt: 'What currency code do you want to use as the base?',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
validate: base => {
|
validate: base => {
|
||||||
if(codes.includes(base.toUpperCase()))
|
if(codes.includes(base.toUpperCase())) return true;
|
||||||
return true;
|
return 'Invalid Currency Code. Use `help currency` to view a list of currency codes.';
|
||||||
return `${base} is not a valid currency code. Use \`help currency\` to view a list of codes.`;
|
|
||||||
},
|
},
|
||||||
parse: base => base.toUpperCase()
|
parse: base => base.toUpperCase()
|
||||||
},
|
},
|
||||||
@@ -27,9 +26,8 @@ module.exports = class CurrencyCommand extends Command {
|
|||||||
prompt: 'What currency code do you want to convert to?',
|
prompt: 'What currency code do you want to convert to?',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
validate: to => {
|
validate: to => {
|
||||||
if(codes.includes(to.toUpperCase()))
|
if(codes.includes(to.toUpperCase())) return true;
|
||||||
return true;
|
return 'Invalid Currency Code. Use `help currency` to view a list of currency codes.';
|
||||||
return `${to} is not a valid currency code. Use \`help currency\` to view a list of codes.`;
|
|
||||||
},
|
},
|
||||||
parse: to => to.toUpperCase()
|
parse: to => to.toUpperCase()
|
||||||
},
|
},
|
||||||
@@ -52,7 +50,7 @@ module.exports = class CurrencyCommand extends Command {
|
|||||||
const converted = rate * amount;
|
const converted = rate * amount;
|
||||||
return msg.say(`${amount} ${base} is ${converted} ${to}.`);
|
return msg.say(`${amount} ${base} is ${converted} ${to}.`);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say('An Unknown Error Occurred.');
|
return msg.say(`An Error Occurred: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,8 +17,7 @@ module.exports = class EasterEggCommand extends Command {
|
|||||||
prompt: 'What easter egg do you want to view?',
|
prompt: 'What easter egg do you want to view?',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
validate: tag => {
|
validate: tag => {
|
||||||
if(eastereggs[tag.toLowerCase()])
|
if(eastereggs[tag.toLowerCase()]) return true;
|
||||||
return true;
|
|
||||||
return 'Nope, that\'s not a valid easter egg. Try again!';
|
return 'Nope, that\'s not a valid easter egg. Try again!';
|
||||||
},
|
},
|
||||||
parse: tag => tag.toLowerCase()
|
parse: tag => tag.toLowerCase()
|
||||||
|
|||||||
@@ -15,9 +15,8 @@ module.exports = class StrawpollCommand extends Command {
|
|||||||
prompt: 'What would you like the title of the Strawpoll to be?',
|
prompt: 'What would you like the title of the Strawpoll to be?',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
validate: title => {
|
validate: title => {
|
||||||
if(title.length < 200)
|
if(title.length < 200) return true;
|
||||||
return true;
|
return 'Invalid Title. Title must be under 200 characters.';
|
||||||
return `Please keep your title under 200 characters, you have ${title.length}.`;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -26,9 +25,8 @@ module.exports = class StrawpollCommand extends Command {
|
|||||||
type: 'string',
|
type: 'string',
|
||||||
infinite: true,
|
infinite: true,
|
||||||
validate: choice => {
|
validate: choice => {
|
||||||
if(choice.length < 160)
|
if(choice.length < 160) return true;
|
||||||
return true;
|
return 'Invalid Choice. Choices must be under 140 characters each.';
|
||||||
return `Please keep your options under 160 characters each, you have ${choice.length}.`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -50,7 +48,7 @@ module.exports = class StrawpollCommand extends Command {
|
|||||||
http://strawpoll.me/${body.id}
|
http://strawpoll.me/${body.id}
|
||||||
`);
|
`);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say('An Unknown Error Occurred.');
|
return msg.say(`An Error Occurred: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ module.exports = class TodayCommand extends Command {
|
|||||||
.setDescription(`${events[random].year}: ${events[random].text}`);
|
.setDescription(`${events[random].year}: ${events[random].text}`);
|
||||||
return msg.embed(embed);
|
return msg.embed(embed);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say('An Unknown Error Occurred.');
|
return msg.say(`An Error Occurred: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ module.exports = class WouldYouRatherCommand extends Command {
|
|||||||
.setDescription(`${body.choicea} OR ${body.choiceb}?`);
|
.setDescription(`${body.choicea} OR ${body.choiceb}?`);
|
||||||
return msg.embed(embed);
|
return msg.embed(embed);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say('An Unknown Error Occurred.');
|
return msg.say(`An Error Occurred: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ module.exports = class CatCommand extends Command {
|
|||||||
return msg.channel.send({ files: [body.file] })
|
return msg.channel.send({ files: [body.file] })
|
||||||
.catch(err => msg.say(`An Error Occurred: ${err}`));
|
.catch(err => msg.say(`An Error Occurred: ${err}`));
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say('An Unknown Error Occurred.');
|
return msg.say(`An Error Occurred: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ module.exports = class DogCommand extends Command {
|
|||||||
return msg.channel.send({ files: [body.url] })
|
return msg.channel.send({ files: [body.url] })
|
||||||
.catch(err => msg.say(`An Error Occurred: ${err}`));
|
.catch(err => msg.say(`An Error Occurred: ${err}`));
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say('An Unknown Error Occurred.');
|
return msg.say(`An Error Occurred: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,8 +14,7 @@ module.exports = class RandomNameCommand extends Command {
|
|||||||
prompt: 'Which gender do you want to generate a name for?',
|
prompt: 'Which gender do you want to generate a name for?',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
validate: gender => {
|
validate: gender => {
|
||||||
if(['male', 'female'].includes(gender.toLowerCase()))
|
if(['male', 'female'].includes(gender.toLowerCase())) return true;
|
||||||
return true;
|
|
||||||
return 'Please enter either `male` or `female`.';
|
return 'Please enter either `male` or `female`.';
|
||||||
},
|
},
|
||||||
parse: gender => gender.toLowerCase()
|
parse: gender => gender.toLowerCase()
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ module.exports = class BotSearchCommand extends Command {
|
|||||||
body.prefix, true);
|
body.prefix, true);
|
||||||
return msg.embed(embed);
|
return msg.embed(embed);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say('An Error Occurred. The bot may not have been found.');
|
return msg.say(`An Error Occurred: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -28,13 +28,14 @@ module.exports = class DefineCommand extends Command {
|
|||||||
try {
|
try {
|
||||||
const { body } = await request
|
const { body } = await request
|
||||||
.get(`http://api.wordnik.com:80/v4/word.json/${query}/definitions?limit=1&includeRelated=false&useCanonical=false&api_key=${process.env.WORDNIK_KEY}`);
|
.get(`http://api.wordnik.com:80/v4/word.json/${query}/definitions?limit=1&includeRelated=false&useCanonical=false&api_key=${process.env.WORDNIK_KEY}`);
|
||||||
|
if(body.length === 0) throw new Error('No Results.');
|
||||||
const embed = new RichEmbed()
|
const embed = new RichEmbed()
|
||||||
.setColor(0x9797FF)
|
.setColor(0x9797FF)
|
||||||
.setTitle(body[0].word)
|
.setTitle(body[0].word)
|
||||||
.setDescription(body[0].text);
|
.setDescription(body[0].text);
|
||||||
return msg.embed(embed);
|
return msg.embed(embed);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say('An Error Occurred. The word may not have been found.');
|
return msg.say(`An Error Occurred: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -18,8 +18,7 @@ module.exports = class DiscrimCommand extends Command {
|
|||||||
prompt: 'Which discriminator would you like to search for?',
|
prompt: 'Which discriminator would you like to search for?',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
validate: discrim => {
|
validate: discrim => {
|
||||||
if(/[0-9]+$/g.test(discrim) && discrim.length === 4)
|
if(/[0-9]+$/g.test(discrim) && discrim.length === 4) return true;
|
||||||
return true;
|
|
||||||
return `${discrim} is not a valid discriminator.`;
|
return `${discrim} is not a valid discriminator.`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ module.exports = class ForecastCommand extends Command {
|
|||||||
try {
|
try {
|
||||||
const { body } = await request
|
const { body } = await request
|
||||||
.get(`https://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where u=\'f\' AND woeid in (select woeid from geo.places(1) where text="${query}")&format=json`);
|
.get(`https://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where u=\'f\' AND woeid in (select woeid from geo.places(1) where text="${query}")&format=json`);
|
||||||
|
if(body.query.count === 0) throw new Error('Location Not Found.');
|
||||||
const forecasts = body.query.results.channel.item.forecast;
|
const forecasts = body.query.results.channel.item.forecast;
|
||||||
const embed = new RichEmbed()
|
const embed = new RichEmbed()
|
||||||
.setColor(0x0000FF)
|
.setColor(0x0000FF)
|
||||||
@@ -49,7 +50,7 @@ module.exports = class ForecastCommand extends Command {
|
|||||||
`**High:** ${forecasts[6].high}°F, **Low:** ${forecasts[6].low}°F, **Condition:** ${forecasts[6].text}`);
|
`**High:** ${forecasts[6].high}°F, **Low:** ${forecasts[6].low}°F, **Condition:** ${forecasts[6].text}`);
|
||||||
return msg.embed(embed);
|
return msg.embed(embed);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say('An Error Occurred. The location may not have been found.');
|
return msg.say(`An Error Occurred: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -29,11 +29,11 @@ module.exports = class GoogleCommand extends Command {
|
|||||||
.get(`https://www.google.com/search?q=${query}`);
|
.get(`https://www.google.com/search?q=${query}`);
|
||||||
const $ = cheerio.load(text);
|
const $ = cheerio.load(text);
|
||||||
let href = $('.r').first().find('a').first().attr('href');
|
let href = $('.r').first().find('a').first().attr('href');
|
||||||
if(!href) throw new Error('No Results');
|
if(!href) throw new Error('No Results.');
|
||||||
href = querystring.parse(href.replace('/url?', ''));
|
href = querystring.parse(href.replace('/url?', ''));
|
||||||
return message.edit(href.q);
|
return message.edit(href.q);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return message.edit('No Results Found.');
|
return message.edit('An Error Occurred: No Results.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ module.exports = class IMDBCommand extends Command {
|
|||||||
try {
|
try {
|
||||||
const { body } = await request
|
const { body } = await request
|
||||||
.get(`http://www.omdbapi.com/?t=${query}&plot=full`);
|
.get(`http://www.omdbapi.com/?t=${query}&plot=full`);
|
||||||
|
if(body.Error) throw new Error('No Results.');
|
||||||
const embed = new RichEmbed()
|
const embed = new RichEmbed()
|
||||||
.setColor(0xDBA628)
|
.setColor(0xDBA628)
|
||||||
.setAuthor('IMDB', 'https://i.imgur.com/sXwwIQs.png')
|
.setAuthor('IMDB', 'https://i.imgur.com/sXwwIQs.png')
|
||||||
@@ -50,7 +51,7 @@ module.exports = class IMDBCommand extends Command {
|
|||||||
body.Actors);
|
body.Actors);
|
||||||
return msg.embed(embed);
|
return msg.embed(embed);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say('An Error Occurred. The film may not have been found.');
|
return msg.say(`An Error Occurred: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ module.exports = class MapCommand extends Command {
|
|||||||
return msg.channel.send({ files: [{ attachment: body, name: 'map.png' }] })
|
return msg.channel.send({ files: [{ attachment: body, name: 'map.png' }] })
|
||||||
.catch(err => msg.say(`An Error Occurred: ${err}`));
|
.catch(err => msg.say(`An Error Occurred: ${err}`));
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say('An Error Occurred. The location may not have been found.');
|
return msg.say(`An Error Occurred: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -27,11 +27,10 @@ module.exports = class NeopetCommand extends Command {
|
|||||||
.get(`http://www.sunnyneo.com/petimagefinder.php?name=${query}&size=5&mood=1`);
|
.get(`http://www.sunnyneo.com/petimagefinder.php?name=${query}&size=5&mood=1`);
|
||||||
const $ = cheerio.load(text);
|
const $ = cheerio.load(text);
|
||||||
const link = $('textarea').first().text();
|
const link = $('textarea').first().text();
|
||||||
if(!link.includes('cp'))
|
if(!link.includes('cp')) throw new Error('Invalid Pet Name.');
|
||||||
return msg.say('This is not a valid pet name.');
|
|
||||||
return msg.say(link);
|
return msg.say(link);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say('An Unknown Error Occurred.');
|
return msg.say(`An Error Occurred: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ module.exports = class OsuCommand extends Command {
|
|||||||
try {
|
try {
|
||||||
const { body } = await request
|
const { body } = await request
|
||||||
.get(`https://osu.ppy.sh/api/get_user?k=${process.env.OSU_KEY}&u=${query}&type=string`);
|
.get(`https://osu.ppy.sh/api/get_user?k=${process.env.OSU_KEY}&u=${query}&type=string`);
|
||||||
|
if(body.length === 0) throw new Error('No Results.');
|
||||||
const embed = new RichEmbed()
|
const embed = new RichEmbed()
|
||||||
.setColor(0xFF66AA)
|
.setColor(0xFF66AA)
|
||||||
.setAuthor('osu!', 'https://i.imgur.com/EmnUp00.png')
|
.setAuthor('osu!', 'https://i.imgur.com/EmnUp00.png')
|
||||||
@@ -58,7 +59,7 @@ module.exports = class OsuCommand extends Command {
|
|||||||
body[0].count_rank_a, true);
|
body[0].count_rank_a, true);
|
||||||
return msg.embed(embed);
|
return msg.embed(embed);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say('An Error Occurred. The user may not have been found.');
|
return msg.say(`An Error Occurred: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ module.exports = class SoundCloudCommand extends Command {
|
|||||||
try {
|
try {
|
||||||
const { body } = await request
|
const { body } = await request
|
||||||
.get(`https://api.soundcloud.com/tracks?q=${query}&client_id=${process.env.SOUNDCLOUD_KEY}`);
|
.get(`https://api.soundcloud.com/tracks?q=${query}&client_id=${process.env.SOUNDCLOUD_KEY}`);
|
||||||
|
if(body.length === 0) throw new Error('No Results.');
|
||||||
const embed = new RichEmbed()
|
const embed = new RichEmbed()
|
||||||
.setColor(0xF15A22)
|
.setColor(0xF15A22)
|
||||||
.setAuthor(body[0].title, 'https://i.imgur.com/lFIz7RU.png')
|
.setAuthor(body[0].title, 'https://i.imgur.com/lFIz7RU.png')
|
||||||
@@ -45,7 +46,7 @@ module.exports = class SoundCloudCommand extends Command {
|
|||||||
body[0].favoritings_count, true);
|
body[0].favoritings_count, true);
|
||||||
return msg.embed(embed);
|
return msg.embed(embed);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say('An Error Occurred. The song may not have been found.');
|
return msg.say(`An Error Occurred: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ module.exports = class UrbanCommand extends Command {
|
|||||||
try {
|
try {
|
||||||
const { body } = await request
|
const { body } = await request
|
||||||
.get(`http://api.urbandictionary.com/v0/define?term=${query}`);
|
.get(`http://api.urbandictionary.com/v0/define?term=${query}`);
|
||||||
|
if(body.list.length === 0) throw new Error('No Results.');
|
||||||
const embed = new RichEmbed()
|
const embed = new RichEmbed()
|
||||||
.setColor(0x32a8f0)
|
.setColor(0x32a8f0)
|
||||||
.setAuthor('Urban Dictionary', 'https://i.imgur.com/fzFuuL7.png')
|
.setAuthor('Urban Dictionary', 'https://i.imgur.com/fzFuuL7.png')
|
||||||
@@ -38,7 +39,7 @@ module.exports = class UrbanCommand extends Command {
|
|||||||
body.list[0].example.substr(0, 2000) || 'None');
|
body.list[0].example.substr(0, 2000) || 'None');
|
||||||
return msg.embed(embed);
|
return msg.embed(embed);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say('An Error Occurred. The word may not have been found.');
|
return msg.say(`An Error Occurred: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ module.exports = class WattpadCommand extends Command {
|
|||||||
const { body } = await request
|
const { body } = await request
|
||||||
.get(`https://api.wattpad.com:443/v4/stories?query=${query}&limit=1`)
|
.get(`https://api.wattpad.com:443/v4/stories?query=${query}&limit=1`)
|
||||||
.set({ 'Authorization': `Basic ${process.env.WATTPAD_KEY}` });
|
.set({ 'Authorization': `Basic ${process.env.WATTPAD_KEY}` });
|
||||||
|
if(body.stories.length === 0) throw new Error('No Results.');
|
||||||
const embed = new RichEmbed()
|
const embed = new RichEmbed()
|
||||||
.setColor(0xF89C34)
|
.setColor(0xF89C34)
|
||||||
.setAuthor('Wattpad', 'https://i.imgur.com/Rw9vRQB.png')
|
.setAuthor('Wattpad', 'https://i.imgur.com/Rw9vRQB.png')
|
||||||
@@ -49,7 +50,7 @@ module.exports = class WattpadCommand extends Command {
|
|||||||
body.stories[0].commentCount, true);
|
body.stories[0].commentCount, true);
|
||||||
return msg.embed(embed);
|
return msg.embed(embed);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say('An Error Occurred. The book may not have been found.');
|
return msg.say(`An Error Occurred: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ module.exports = class WeatherCommand extends Command {
|
|||||||
try {
|
try {
|
||||||
const { body } = await request
|
const { body } = await request
|
||||||
.get(`https://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where u=\'f\' AND woeid in (select woeid from geo.places(1) where text="${query}")&format=json`);
|
.get(`https://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where u=\'f\' AND woeid in (select woeid from geo.places(1) where text="${query}")&format=json`);
|
||||||
|
if(body.query.count === 0) throw new Error('Location Not Found.');
|
||||||
const embed = new RichEmbed()
|
const embed = new RichEmbed()
|
||||||
.setColor(0x0000FF)
|
.setColor(0x0000FF)
|
||||||
.setAuthor(body.query.results.channel.title, 'https://i.imgur.com/2MT0ViC.png')
|
.setAuthor(body.query.results.channel.title, 'https://i.imgur.com/2MT0ViC.png')
|
||||||
@@ -58,7 +59,7 @@ module.exports = class WeatherCommand extends Command {
|
|||||||
body.query.results.channel.wind.speed, true);
|
body.query.results.channel.wind.speed, true);
|
||||||
return msg.embed(embed);
|
return msg.embed(embed);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say('An Error Occurred. The location may not have been found.');
|
return msg.say(`An Error Occurred: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ module.exports = class WikipediaCommand extends Command {
|
|||||||
try {
|
try {
|
||||||
const { body } = await request
|
const { body } = await request
|
||||||
.get(`https://en.wikipedia.org/w/api.php?action=query&prop=extracts&format=json&titles=${query}&exintro=&explaintext=&redirects=&formatversion=2`);
|
.get(`https://en.wikipedia.org/w/api.php?action=query&prop=extracts&format=json&titles=${query}&exintro=&explaintext=&redirects=&formatversion=2`);
|
||||||
|
if(body.query.pages[0].missing) throw new Error('No Results.');
|
||||||
const embed = new RichEmbed()
|
const embed = new RichEmbed()
|
||||||
.setColor(0xE7E7E7)
|
.setColor(0xE7E7E7)
|
||||||
.setTitle(body.query.pages[0].title)
|
.setTitle(body.query.pages[0].title)
|
||||||
@@ -36,7 +37,7 @@ module.exports = class WikipediaCommand extends Command {
|
|||||||
.setDescription(body.query.pages[0].extract.substr(0, 2000).replace(/[\n]/g, '\n\n'));
|
.setDescription(body.query.pages[0].extract.substr(0, 2000).replace(/[\n]/g, '\n\n'));
|
||||||
return msg.embed(embed);
|
return msg.embed(embed);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say('An Error Occurred. The page may not have been found.');
|
return msg.say(`An Error Occurred: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ module.exports = class YouTubeCommand extends Command {
|
|||||||
try {
|
try {
|
||||||
const { body } = await request
|
const { body } = await request
|
||||||
.get(`https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&maxResults=1&q=${query}&key=${process.env.GOOGLE_KEY}`);
|
.get(`https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&maxResults=1&q=${query}&key=${process.env.GOOGLE_KEY}`);
|
||||||
|
if(body.items.length === 0) throw new Error('No Results.');
|
||||||
const embed = new RichEmbed()
|
const embed = new RichEmbed()
|
||||||
.setColor(0xDD2825)
|
.setColor(0xDD2825)
|
||||||
.setTitle(body.items[0].snippet.title)
|
.setTitle(body.items[0].snippet.title)
|
||||||
@@ -37,7 +38,7 @@ module.exports = class YouTubeCommand extends Command {
|
|||||||
.setThumbnail(body.items[0].snippet.thumbnails.default.url);
|
.setThumbnail(body.items[0].snippet.thumbnails.default.url);
|
||||||
return msg.embed(embed);
|
return msg.embed(embed);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say('An Error Occurred. The video may not have been found.');
|
return msg.say(`An Error Occurred: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ module.exports = class YuGiOhCommand extends Command {
|
|||||||
try {
|
try {
|
||||||
const { body } = await request
|
const { body } = await request
|
||||||
.get(`http://yugiohprices.com/api/card_data/${query}`);
|
.get(`http://yugiohprices.com/api/card_data/${query}`);
|
||||||
|
if(body.status === 'fail') throw new Error('No Results.');
|
||||||
if(body.data.card_type === 'monster') {
|
if(body.data.card_type === 'monster') {
|
||||||
const embed = new RichEmbed()
|
const embed = new RichEmbed()
|
||||||
.setColor(0xBE5F1F)
|
.setColor(0xBE5F1F)
|
||||||
@@ -35,7 +36,7 @@ module.exports = class YuGiOhCommand extends Command {
|
|||||||
.setDescription(body.data.text)
|
.setDescription(body.data.text)
|
||||||
.setAuthor('Yu-Gi-Oh!', 'https://i.imgur.com/7gPm9Rr.png')
|
.setAuthor('Yu-Gi-Oh!', 'https://i.imgur.com/7gPm9Rr.png')
|
||||||
.addField('**Card Type:**',
|
.addField('**Card Type:**',
|
||||||
'Monster', true)
|
'monster', true)
|
||||||
.addField('**Type:**',
|
.addField('**Type:**',
|
||||||
body.data.type, true)
|
body.data.type, true)
|
||||||
.addField('**Attribute:**',
|
.addField('**Attribute:**',
|
||||||
@@ -57,7 +58,7 @@ module.exports = class YuGiOhCommand extends Command {
|
|||||||
body.data.card_type, true);
|
body.data.card_type, true);
|
||||||
return msg.embed(embed);
|
return msg.embed(embed);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say('An Error Occurred. The card may not have been found.');
|
return msg.say(`An Error Occurred: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,9 +20,8 @@ module.exports = class BinaryCommand extends Command {
|
|||||||
prompt: 'What text would you like to convert to binary?',
|
prompt: 'What text would you like to convert to binary?',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
validate: text => {
|
validate: text => {
|
||||||
if(binary(text).length < 2000)
|
if(binary(text).length < 2000) return true;
|
||||||
return true;
|
return 'Your text is too long.';
|
||||||
return 'Your message content is too long.';
|
|
||||||
},
|
},
|
||||||
parse: text => binary(text)
|
parse: text => binary(text)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,8 @@ module.exports = class CowsayCommand extends Command {
|
|||||||
prompt: 'What text would you like the cow to say?',
|
prompt: 'What text would you like the cow to say?',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
validate: text => {
|
validate: text => {
|
||||||
if(text.length < 1500)
|
if(text.length < 1500) return true;
|
||||||
return true;
|
return 'Invalid Text. Text must be under 1500 characters.';
|
||||||
return `Please keep your content under 1500 characters, you have ${text.length}.`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -15,9 +15,8 @@ module.exports = class MorseCommand extends Command {
|
|||||||
prompt: 'What text would you like to convert to morse?',
|
prompt: 'What text would you like to convert to morse?',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
validate: text => {
|
validate: text => {
|
||||||
if(letterTrans(text, dictionary, ' ').length < 1999)
|
if(letterTrans(text, dictionary, ' ').length < 1999) return true;
|
||||||
return true;
|
return 'Your text is too long.';
|
||||||
return 'Your message content is too long.';
|
|
||||||
},
|
},
|
||||||
parse: text => letterTrans(text.toLowerCase(), dictionary, ' ')
|
parse: text => letterTrans(text.toLowerCase(), dictionary, ' ')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,9 +15,8 @@ module.exports = class PirateCommand extends Command {
|
|||||||
prompt: 'What text would you like to convert to pirate?',
|
prompt: 'What text would you like to convert to pirate?',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
validate: text => {
|
validate: text => {
|
||||||
if(wordTrans(text, dictionary).length < 1999)
|
if(wordTrans(text, dictionary).length < 1999) return true;
|
||||||
return true;
|
return 'Your text is too long.';
|
||||||
return 'Your message content is too long.';
|
|
||||||
},
|
},
|
||||||
parse: text => wordTrans(text, dictionary)
|
parse: text => wordTrans(text, dictionary)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,9 +15,8 @@ module.exports = class TemmieCommand extends Command {
|
|||||||
prompt: 'What text would you like to convert to Temmie speak?',
|
prompt: 'What text would you like to convert to Temmie speak?',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
validate: text => {
|
validate: text => {
|
||||||
if(wordTrans(text, dictionary).length < 1999)
|
if(wordTrans(text, dictionary).length < 1999) return true;
|
||||||
return true;
|
return 'Your text is too long.';
|
||||||
return 'Your message content is too long.';
|
|
||||||
},
|
},
|
||||||
parse: text => wordTrans(text, dictionary)
|
parse: text => wordTrans(text, dictionary)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ module.exports = class WebhookCommand extends Command {
|
|||||||
.send({ content });
|
.send({ content });
|
||||||
return null;
|
return null;
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return msg.say('An Unknown Error Occurred.');
|
return msg.say(`An Error Occurred: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,9 +14,8 @@ module.exports = class ZalgoCommand extends Command {
|
|||||||
prompt: 'What text would you like to convert to zalgo?',
|
prompt: 'What text would you like to convert to zalgo?',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
validate: text => {
|
validate: text => {
|
||||||
if(text.length < 500)
|
if(text.length < 500) return true;
|
||||||
return true;
|
return 'Invalid Text. Text must be under 500 characters.';
|
||||||
return `Please keep your text under 500 characters, you have ${text.length}.`;
|
|
||||||
},
|
},
|
||||||
parse: text => zalgo(text)
|
parse: text => zalgo(text)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,7 @@ module.exports = class ClearSettingCommand extends Command {
|
|||||||
prompt: 'What setting do you want to clear? `modLog`, `memberLog`, `staffRole`, or `singleRole`?',
|
prompt: 'What setting do you want to clear? `modLog`, `memberLog`, `staffRole`, or `singleRole`?',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
validate: setting => {
|
validate: setting => {
|
||||||
if(['modLog', 'memberLog', 'staffRole', 'singleRole'].includes(setting))
|
if(['modLog', 'memberLog', 'staffRole', 'singleRole'].includes(setting)) return true;
|
||||||
return true;
|
|
||||||
return 'Please enter either `modLog`, `memberLog`, `staffRole`, or `singleRole`.';
|
return 'Please enter either `modLog`, `memberLog`, `staffRole`, or `singleRole`.';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiaobot",
|
"name": "xiaobot",
|
||||||
"version": "18.2.1",
|
"version": "18.2.2",
|
||||||
"description": "A Discord Bot",
|
"description": "A Discord Bot",
|
||||||
"main": "shardingmanager.js",
|
"main": "shardingmanager.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user