mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-06 06:10:49 +02:00
Improve Errors
This commit is contained in:
@@ -45,9 +45,9 @@ module.exports = class YearsCommand extends Command {
|
||||
avatar.src = body;
|
||||
generate();
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'az.png' }] })
|
||||
.catch(() => msg.say('An Error Occurred while sending the image.'));
|
||||
.catch(() => msg.say(err.message));
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred while creating the image.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -46,9 +46,9 @@ module.exports = class BeautifulCommand extends Command {
|
||||
avatar.src = body;
|
||||
generate();
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'grunkle.png' }] })
|
||||
.catch(() => msg.say('An Error Occurred while sending the image.'));
|
||||
.catch(() => msg.say(err.message));
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred while creating the image.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -49,9 +49,9 @@ module.exports = class BobRossCommand extends Command {
|
||||
avatar.src = body;
|
||||
generate();
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'ross.png' }] })
|
||||
.catch(() => msg.say('An Error Occurred while sending the image.'));
|
||||
.catch(() => msg.say(err.message));
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred while creating the image.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -68,9 +68,9 @@ module.exports = class CardCommand extends Command {
|
||||
avatar.src = body;
|
||||
generate();
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'card.png' }] })
|
||||
.catch(() => msg.say('An Error Occurred while sending the image.'));
|
||||
.catch(() => msg.say(err.message));
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred while creating the image.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -48,9 +48,9 @@ module.exports = class GreyscaleCommand extends Command {
|
||||
avatar.src = avatarImg.body;
|
||||
generate();
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'greyscale.png' }] })
|
||||
.catch(() => msg.say('An Error Occurred while sending the image.'));
|
||||
.catch(() => msg.say(err.message));
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred while creating the image.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -46,9 +46,9 @@ module.exports = class InvertCommand extends Command {
|
||||
avatar.src = avatarImg.body;
|
||||
generate();
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'invert.png' }] })
|
||||
.catch(() => msg.say('An Error Occurred while sending the image.'));
|
||||
.catch(() => msg.say(err.message));
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred while creating the image.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -54,9 +54,9 @@ module.exports = class RIPCommand extends Command {
|
||||
avatar.src = avatarImg.body;
|
||||
generate();
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'rip.png' }] })
|
||||
.catch(() => msg.say('An Error Occurred while sending the image.'));
|
||||
.catch(() => msg.say(err.message));
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred while creating the image.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -46,9 +46,9 @@ module.exports = class SimbaCommand extends Command {
|
||||
avatar.src = body;
|
||||
generate();
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'simba.png' }] })
|
||||
.catch(() => msg.say('An Error Occurred while sending the image.'));
|
||||
.catch(() => msg.say(err.message));
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred while creating the image.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -50,9 +50,9 @@ module.exports = class SteamCardCommand extends Command {
|
||||
avatar.src = body;
|
||||
generate();
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'card.png' }] })
|
||||
.catch(() => msg.say('An Error Occurred while sending the image.'));
|
||||
.catch(() => msg.say(err.message));
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred while creating the image.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -52,9 +52,9 @@ module.exports = class TriggeredCommand extends Command {
|
||||
avatar.src = body;
|
||||
generate();
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'triggered.png' }] })
|
||||
.catch(() => msg.say('An Error Occurred while sending the image.'));
|
||||
.catch(() => msg.say(err.message));
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred while creating the image.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -44,9 +44,9 @@ module.exports = class WantedCommand extends Command {
|
||||
avatar.src = body;
|
||||
generate();
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'wanted.png' }] })
|
||||
.catch(() => msg.say('An Error Occurred while sending the image.'));
|
||||
.catch(() => msg.say(err.message));
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred while creating the image.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -45,7 +45,7 @@ module.exports = class QuizCommand extends Command {
|
||||
return msg.say(`Time! The correct answer is: ${answer}`);
|
||||
}
|
||||
} catch (err) {
|
||||
return msg.say(`An Error Occurred: ${err}.`);
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -67,7 +67,7 @@ module.exports = class BanCommand extends Command {
|
||||
`);
|
||||
return modlogs.send({ embed });
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -66,7 +66,7 @@ module.exports = class KickCommand extends Command {
|
||||
`);
|
||||
return modlogs.send({ embed });
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -40,14 +40,14 @@ module.exports = class LockdownCommand extends Command {
|
||||
Please use \`lockdown stop\` to end the lockdown.
|
||||
`);
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
} else if (type === 'stop') {
|
||||
try {
|
||||
await msg.channel.overwritePermissions(msg.guild.defaultRole, { SEND_MESSAGES: true });
|
||||
return msg.say('Lockdown Ended, users without Administrator can now post messages.');
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ module.exports = class SoftbanCommand extends Command {
|
||||
`);
|
||||
return modlogs.send({ embed });
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -65,7 +65,7 @@ module.exports = class UnbanCommand extends Command {
|
||||
`);
|
||||
return modlogs.send({ embed });
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -45,7 +45,7 @@ module.exports = class CurrencyCommand extends Command {
|
||||
if (base === to) return msg.say(`Converting ${base} to ${to} is the same value, dummy.`);
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get(`http://api.fixer.io/latest`)
|
||||
.get('http://api.fixer.io/latest')
|
||||
.query({
|
||||
base,
|
||||
symbols: to
|
||||
@@ -53,7 +53,7 @@ module.exports = class CurrencyCommand extends Command {
|
||||
const rate = body.rates[to];
|
||||
return msg.say(`${amount} ${base} is ${amount * rate} ${to}.`);
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -48,7 +48,7 @@ module.exports = class HoroscopeCommand extends Command {
|
||||
body.date, true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -49,7 +49,7 @@ module.exports = class SoundboardCommand extends Command {
|
||||
return null;
|
||||
});
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -46,7 +46,7 @@ module.exports = class StrawpollCommand extends Command {
|
||||
http://strawpoll.me/${body.id}
|
||||
`);
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -30,7 +30,7 @@ module.exports = class TodayCommand extends Command {
|
||||
.setDescription(`${event.year}: ${event.text}`);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -27,7 +27,7 @@ module.exports = class WouldYouRatherCommand extends Command {
|
||||
.setDescription(`${body.choicea} OR ${body.choiceb}?`);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -22,7 +22,7 @@ module.exports = class CatCommand extends Command {
|
||||
return msg.say({ files: [body.file] })
|
||||
.catch(() => msg.say('An Error Occurred while sending the image.'));
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -21,7 +21,7 @@ module.exports = class DogCommand extends Command {
|
||||
return msg.say({ files: [body.url] })
|
||||
.catch(() => msg.say('An Error Occurred while sending the image.'));
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -41,7 +41,7 @@ module.exports = class XKCDCommand extends Command {
|
||||
.catch(() => msg.say('An Error Occurred while sending the image.'));
|
||||
}
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -57,7 +57,7 @@ module.exports = class AnimeCommand extends Command {
|
||||
anime.entry[0].end_date[0], true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred. There were most likely no results.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -43,7 +43,7 @@ module.exports = class BotSearchCommand extends Command {
|
||||
body.prefix, true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred. There were most likely no results.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -42,7 +42,7 @@ module.exports = class DefineCommand extends Command {
|
||||
.setDescription(body[0].text);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred. There were most likely no results.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -54,7 +54,7 @@ module.exports = class ForecastCommand extends Command {
|
||||
`**High:** ${forecasts[6].high}°F, **Low:** ${forecasts[6].low}°F, **Condition:** ${forecasts[6].text}`);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred. There were most likely no results.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -25,7 +25,7 @@ module.exports = class GoogleCommand extends Command {
|
||||
const message = await msg.say('Searching...');
|
||||
try {
|
||||
const { text } = await snekfetch
|
||||
.get(`https://www.google.com/search`)
|
||||
.get('https://www.google.com/search')
|
||||
.query({
|
||||
q: query
|
||||
});
|
||||
@@ -35,7 +35,7 @@ module.exports = class GoogleCommand extends Command {
|
||||
href = querystring.parse(href.replace('/url?', ''));
|
||||
return message.edit(href.q);
|
||||
} catch (err) {
|
||||
return message.edit('An Error Occurred. There were most likely no results.');
|
||||
return message.edit(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -26,7 +26,7 @@ module.exports = class IMDBCommand extends Command {
|
||||
const { query } = args;
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get(`http://www.omdbapi.com/`)
|
||||
.get('http://www.omdbapi.com/')
|
||||
.query({
|
||||
t: query,
|
||||
plot: 'full'
|
||||
@@ -54,7 +54,7 @@ module.exports = class IMDBCommand extends Command {
|
||||
body.Actors);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred. There were most likely no results.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -36,7 +36,7 @@ module.exports = class KonachanCommand extends Command {
|
||||
return msg.say(query ? `Result for ${query}:` : 'Random Image:', { files: [`https:${body[0].file_url}`] })
|
||||
.catch(() => msg.say('An Error Occurred while sending the image.'));
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred. There were most likely no results.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -57,7 +57,7 @@ module.exports = class MangaCommand extends Command {
|
||||
manga.entry[0].end_date[0], true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred. There were most likely no results.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -47,7 +47,7 @@ module.exports = class MapCommand extends Command {
|
||||
return msg.say({ files: [{ attachment: body, name: 'map.png' }] })
|
||||
.catch(() => msg.say('An Error Occurred while sending the image.'));
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred. There were most likely no results.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -34,7 +34,7 @@ module.exports = class NeopetCommand extends Command {
|
||||
if (!link.includes('cp')) throw new Error('Invalid Pet Name.');
|
||||
return msg.say(link);
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred. There were most likely no results.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -64,7 +64,7 @@ module.exports = class OsuCommand extends Command {
|
||||
body[0].count_rank_a, true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred. There were most likely no results.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -27,7 +27,7 @@ module.exports = class SoundCloudCommand extends Command {
|
||||
const { query } = args;
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get(`https://api.soundcloud.com/tracks`)
|
||||
.get('https://api.soundcloud.com/tracks')
|
||||
.query({
|
||||
q: query,
|
||||
client_id: SOUNDCLOUD_KEY
|
||||
@@ -51,7 +51,7 @@ module.exports = class SoundCloudCommand extends Command {
|
||||
body[0].favoritings_count, true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred. There were most likely no results.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -26,7 +26,7 @@ module.exports = class UrbanCommand extends Command {
|
||||
const { query } = args;
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get(`http://api.urbandictionary.com/v0/define`)
|
||||
.get('http://api.urbandictionary.com/v0/define')
|
||||
.query({
|
||||
term: query
|
||||
});
|
||||
@@ -41,7 +41,7 @@ module.exports = class UrbanCommand extends Command {
|
||||
body.list[0].example.substr(0, 2000) || 'None');
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred. There were most likely no results.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -27,7 +27,7 @@ module.exports = class WattpadCommand extends Command {
|
||||
const { query } = args;
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get(`https://api.wattpad.com:443/v4/stories`)
|
||||
.get('https://api.wattpad.com:443/v4/stories')
|
||||
.query({
|
||||
query,
|
||||
limit: 1
|
||||
@@ -54,7 +54,7 @@ module.exports = class WattpadCommand extends Command {
|
||||
body.stories[0].commentCount, true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred. There were most likely no results.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -63,7 +63,7 @@ module.exports = class WeatherCommand extends Command {
|
||||
body.query.results.channel.wind.speed, true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred. There were most likely no results.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -45,7 +45,7 @@ module.exports = class WikipediaCommand extends Command {
|
||||
.setDescription(body.query.pages[0].extract.substr(0, 2000).replace(/[\n]/g, '\n\n'));
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred. There were most likely no results.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -45,7 +45,7 @@ module.exports = class YouTubeCommand extends Command {
|
||||
.setThumbnail(body.items[0].snippet.thumbnails.default.url);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred. There were most likely no results.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -59,7 +59,7 @@ module.exports = class YuGiOhCommand extends Command {
|
||||
return msg.embed(embed);
|
||||
}
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred. There were most likely no results.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -36,7 +36,7 @@ module.exports = class WebhookCommand extends Command {
|
||||
.send({ content });
|
||||
return null;
|
||||
} catch (err) {
|
||||
return msg.say('An Error Occurred.');
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user