Fix avatar url handling for error messages
This commit is contained in:
parent
fb3f26cdd4
commit
8c9c083d26
|
@ -8,16 +8,17 @@ module.exports = {
|
|||
const index = Math.floor(Math.random() * config.answers.length);
|
||||
const answer = config.answers[index]
|
||||
const question = args.slice(0).join(" ")
|
||||
const avatarURL = message.author.displayAvatarURL()
|
||||
|
||||
if (!question) {
|
||||
await message.channel.send(client.generateErrorMessage("You need to ask a question!"));
|
||||
await message.channel.send(client.generateErrorMessage("You need to ask a question!", avatarURL));
|
||||
} else {
|
||||
await message.channel.send({embeds: [{
|
||||
"title": ":8ball: 8Ball",
|
||||
"description": `Your amazing question: **${question}**`,
|
||||
"color": 9442302,
|
||||
"footer": {
|
||||
"icon_url": message.author.displayAvatarURL(),
|
||||
"icon_url": avatarURL,
|
||||
"text": config.footerTxt
|
||||
},
|
||||
"fields": [
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
const avatar = require('./avatar');
|
||||
|
||||
module.exports = {
|
||||
|
||||
name: require('path').parse(__filename).name,
|
||||
|
@ -5,16 +7,17 @@ module.exports = {
|
|||
|
||||
async execute(client, message, _, config) {
|
||||
const taggedUser = message.mentions.users.first();
|
||||
const avatarURL = message.author.displayAvatarURL();
|
||||
|
||||
if(!taggedUser) {
|
||||
await message.channel.send(client.generateErrorMessage("You need to @mention a user!"));
|
||||
await message.channel.send(client.generateErrorMessage("You need to @mention a user!", avatarURL));
|
||||
} else {
|
||||
await message.channel.send({embeds: [{
|
||||
"title": "<a:SylvBonk:801185845847130113> Bonk",
|
||||
"description": `${taggedUser} You have been bonked by ${message.author}!`,
|
||||
"color": 9442302,
|
||||
"footer": {
|
||||
"icon_url": message.author.displayAvatarURL(),
|
||||
"icon_url": avatarURL,
|
||||
"text": config.footerTxt
|
||||
},
|
||||
"image": {
|
||||
|
|
|
@ -4,12 +4,13 @@ module.exports = {
|
|||
description: "Give some lines of input, and get one back at random",
|
||||
|
||||
async execute(client, message, _, config) {
|
||||
const avatarURL = message.author.displayAvatarURL();
|
||||
var [head, ...options] = message.content.split(/\s*\n\s*/);
|
||||
head = head.slice(this.name.length + config.prefix.length);
|
||||
if (head) options.push(head);
|
||||
|
||||
if (!options.length) {
|
||||
await message.channel.send(client.generateErrorMessage("You need to provide some input!"));
|
||||
await message.channel.send(client.generateErrorMessage("You need to provide some input!", avatarURL));
|
||||
} else {
|
||||
const answer = options[Math.floor(Math.random() * options.length)];
|
||||
await message.channel.send({embeds: [{
|
||||
|
@ -17,7 +18,7 @@ module.exports = {
|
|||
"description": answer,
|
||||
"color": 8311585,
|
||||
"footer": {
|
||||
"icon_url": message.author.displayAvatarURL(),
|
||||
"icon_url": avatarURL,
|
||||
"text": config.footerTxt
|
||||
},
|
||||
}]});
|
||||
|
|
|
@ -14,16 +14,17 @@ module.exports = {
|
|||
const taggedUser = message.mentions.users.first();
|
||||
const index = Math.floor(Math.random() * gifchoices.length);
|
||||
const gif = (gifchoices[index]);
|
||||
const avatarURL = message.author.displayAvatarURL();
|
||||
|
||||
if(!taggedUser) {
|
||||
await message.channel.send(client.generateErrorMessage("You need to @mention a user!"));
|
||||
await message.channel.send(client.generateErrorMessage("You need to @mention a user!", avatarURL));
|
||||
} else {
|
||||
await message.channel.send({embeds: [{
|
||||
"title": ":heart: Cuddle",
|
||||
"description": `${taggedUser} You have been cuddled by ${message.author}!`,
|
||||
"color": 9442302,
|
||||
"footer": {
|
||||
"icon_url": message.author.displayAvatarURL(),
|
||||
"icon_url": avatarURL,
|
||||
"text": config.footerTxt
|
||||
},
|
||||
"image": {
|
||||
|
|
|
@ -13,9 +13,10 @@ module.exports = {
|
|||
|
||||
async execute(client, message, _, config) {
|
||||
const taggedUser = message.mentions.users.first();
|
||||
const avatarURL = message.author.displayAvatarURL();
|
||||
|
||||
if(!taggedUser) {
|
||||
await message.channel.send(client.generateErrorMessage("You need to @mention a user!"));
|
||||
await message.channel.send(client.generateErrorMessage("You need to @mention a user!", avatarURL));
|
||||
} else {
|
||||
const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)];
|
||||
await message.channel.send({embeds: [{
|
||||
|
@ -23,7 +24,7 @@ module.exports = {
|
|||
"description": `${taggedUser} You have been hugged by ${message.author}!`,
|
||||
"color": 8311585,
|
||||
"footer": {
|
||||
"icon_url": message.author.displayAvatarURL(),
|
||||
"icon_url": avatarURL,
|
||||
"text": config.footerTxt
|
||||
},
|
||||
"image": {
|
||||
|
|
|
@ -13,9 +13,10 @@ module.exports = {
|
|||
|
||||
async execute(client, message, _, config) {
|
||||
const taggedUser = message.mentions.users.first();
|
||||
const avatarURL = message.author.displayAvatarURL();
|
||||
|
||||
if(!taggedUser) {
|
||||
await message.channel.send(client.generateErrorMessage("You need to @mention a user!"));
|
||||
await message.channel.send(client.generateErrorMessage("You need to @mention a user!", avatarURL));
|
||||
} else {
|
||||
const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)];
|
||||
await message.channel.send({embeds: [{
|
||||
|
@ -23,7 +24,7 @@ module.exports = {
|
|||
"description": `${taggedUser} You have been kissed by ${message.author}!`,
|
||||
"color": 9442302,
|
||||
"footer": {
|
||||
"icon_url": message.author.displayAvatarURL(),
|
||||
"icon_url": avatarURL,
|
||||
"text": config.footerTxt
|
||||
},
|
||||
"image": {
|
||||
|
|
|
@ -23,9 +23,10 @@ module.exports = {
|
|||
|
||||
async execute(client, message, _, config) {
|
||||
const taggedUser = message.mentions.users.first();
|
||||
const avatarURL = message.author.displayAvatarURL();
|
||||
|
||||
if(!taggedUser) {
|
||||
await message.channel.send(client.generateErrorMessage("You need to @mention a user!"));
|
||||
await message.channel.send(client.generateErrorMessage("You need to @mention a user!", avatarURL));
|
||||
} else {
|
||||
const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)];
|
||||
await message.channel.send({embeds: [{
|
||||
|
@ -33,7 +34,7 @@ module.exports = {
|
|||
"description": `${taggedUser} You have been kissed by ${message.author}!`,
|
||||
"color": 8311585,
|
||||
"footer": {
|
||||
"icon_url": message.author.displayAvatarURL(),
|
||||
"icon_url": avatarURL,
|
||||
"text": config.footerTxt
|
||||
},
|
||||
"image": {
|
||||
|
|
|
@ -12,9 +12,10 @@ module.exports = {
|
|||
|
||||
async execute(client, message, _, config) {
|
||||
const taggedUser = message.mentions.users.first();
|
||||
const avatarURL = message.author.displayAvatarURL();
|
||||
|
||||
if(!taggedUser) {
|
||||
await message.channel.send(client.generateErrorMessage("You need to @mention a user!"));
|
||||
await message.channel.send(client.generateErrorMessage("You need to @mention a user!", avatarURL));
|
||||
} else {
|
||||
const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)];
|
||||
await message.channel.send({embeds: [{
|
||||
|
@ -22,7 +23,7 @@ module.exports = {
|
|||
"description": `${taggedUser} You have been licked by ${message.author}!`,
|
||||
"color": 8311585,
|
||||
"footer": {
|
||||
"icon_url": message.author.displayAvatarURL(),
|
||||
"icon_url": avatarURL,
|
||||
"text": config.footerTxt
|
||||
},
|
||||
"image": {
|
||||
|
|
|
@ -11,10 +11,11 @@ module.exports = {
|
|||
description: "Noms an user!",
|
||||
|
||||
async execute(client, message, _, config) {
|
||||
const taggedUser = message.mentions.users.first();
|
||||
const taggedUser = message.mentions.users.first();
|
||||
const avatarURL = message.author.displayAvatarURL();
|
||||
|
||||
if(!taggedUser) {
|
||||
await message.channel.send(client.generateErrorMessage("You need to @mention a user!"));
|
||||
await message.channel.send(client.generateErrorMessage("You need to @mention a user!", avatarURL));
|
||||
} else {
|
||||
const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)];
|
||||
await message.channel.send({embeds: [{
|
||||
|
@ -22,7 +23,7 @@ module.exports = {
|
|||
"description": `${taggedUser} You have been nommed by ${message.author}!`,
|
||||
"color": 8311585,
|
||||
"footer": {
|
||||
"icon_url": message.author.displayAvatarURL(),
|
||||
"icon_url": avatarURL,
|
||||
"text": config.footerTxt
|
||||
},
|
||||
"image": {
|
||||
|
|
|
@ -11,9 +11,10 @@ module.exports = {
|
|||
|
||||
async execute(client, message, _, config) {
|
||||
const taggedUser = message.mentions.users.first();
|
||||
const avatarURL = message.author.displayAvatarURL();
|
||||
|
||||
if(!taggedUser) {
|
||||
await message.channel.send(client.generateErrorMessage("You need to @mention a user!"));
|
||||
await message.channel.send(client.generateErrorMessage("You need to @mention a user!", avatarURL));
|
||||
} else {
|
||||
const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)];
|
||||
await message.channel.send({embeds: [{
|
||||
|
@ -21,7 +22,7 @@ module.exports = {
|
|||
"description": `${taggedUser} You have been patted by ${message.author}!`,
|
||||
"color": 8311585,
|
||||
"footer": {
|
||||
"icon_url": message.author.displayAvatarURL(),
|
||||
"icon_url": avatarURL,
|
||||
"text": config.footerTxt
|
||||
},
|
||||
"image": {
|
||||
|
|
|
@ -11,9 +11,10 @@ module.exports = {
|
|||
|
||||
async execute(client, message, _, config) {
|
||||
const taggedUser = message.mentions.users.first();
|
||||
const avatarURL = message.author.displayAvatarURL();
|
||||
|
||||
if(!taggedUser) {
|
||||
await message.channel.send(client.generateErrorMessage("You need to @mention a user!"));
|
||||
await message.channel.send(client.generateErrorMessage("You need to @mention a user!", avatarURL));
|
||||
} else {
|
||||
const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)];
|
||||
await message.channel.send({embeds: [{
|
||||
|
@ -21,7 +22,7 @@ module.exports = {
|
|||
"description": `${taggedUser} You have been poked by ${message.author}!`,
|
||||
"color": 8311585,
|
||||
"footer": {
|
||||
"icon_url": message.author.displayAvatarURL(),
|
||||
"icon_url": avatarURL,
|
||||
"text": config.footerTxt
|
||||
},
|
||||
"image": {
|
||||
|
|
|
@ -4,9 +4,10 @@ module.exports = {
|
|||
description: 'Reloads a command',
|
||||
|
||||
async execute(client, message, args, config) {
|
||||
const avatarURL = message.author.displayAvatarURL();
|
||||
if (message.author.id = config.ownerID) {
|
||||
if (!args.length) {
|
||||
await message.channel.send(client.generateErrorMessage("You forgot to provide anything to reload, you pillock",message.author.displayAvatarURL()));
|
||||
await message.channel.send(client.generateErrorMessage("You forgot to provide anything to reload, you pillock", avatarURL));
|
||||
}
|
||||
args.forEach(async (arg) => {
|
||||
const commandName = arg.toLowerCase();
|
||||
|
@ -14,7 +15,7 @@ module.exports = {
|
|||
|| message.client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
|
||||
|
||||
if (!command) {
|
||||
await message.channel.send(client.generateErrorMessage(`There is no command with name or alias \`${commandName}\`, ${message.author}!`,message.author.displayAvatarURL()));
|
||||
await message.channel.send(client.generateErrorMessage(`There is no command with name or alias \`${commandName}\`, ${message.author}!`, avatarURL));
|
||||
} else {
|
||||
delete require.cache[require.resolve(`./${command.name}.js`)];
|
||||
|
||||
|
@ -25,7 +26,7 @@ module.exports = {
|
|||
console.log(`User reloaded ${command.name}.`)
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
await message.channel.send(client.generateErrorMessage(`There was an error while reloading \`${command.name}\`:\n\`${error.message}\``, message.author.displayAvatarURL()));
|
||||
await message.channel.send(client.generateErrorMessage(`There was an error while reloading \`${command.name}\`:\n\`${error.message}\``, avatarURL));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -35,7 +36,7 @@ module.exports = {
|
|||
"title": "<:AnitroxDenied:809651936642203668> **403 Forbidden**",
|
||||
"color": 13632027,
|
||||
"footer": {
|
||||
"icon_url": message.author.displayAvatarURL(),
|
||||
"icon_url": avatarURL,
|
||||
"text": config.footerTxt
|
||||
},
|
||||
"fields": [
|
||||
|
|
|
@ -4,6 +4,8 @@ module.exports = {
|
|||
description: 'Sets your nickname',
|
||||
|
||||
async execute(client, message, args, config) {
|
||||
const avatarURL = message.author.displayAvatarURL();
|
||||
|
||||
if (message.channel.permissionsFor(message.author).has("CHANGE_NICKNAME")) {
|
||||
const newnick = args.slice(0).join(" ")
|
||||
try {
|
||||
|
@ -28,10 +30,10 @@ module.exports = {
|
|||
]
|
||||
}]});
|
||||
} catch (error) {
|
||||
await message.channel.send(client.generateErrorMessage("Failed to set user nickname. Does the bot have the correct permissions?", message.author.displayAvatarURL()));
|
||||
await message.channel.send(client.generateErrorMessage("Failed to set user nickname. Does the bot have the correct permissions?", avatarURL));
|
||||
};
|
||||
} else {
|
||||
await message.channel.send(client.generateErrorMessage("You need to have permission ``CHANGE_NICKNAME`` to change your nick!", message.author.displayAvatarURL()));
|
||||
await message.channel.send(client.generateErrorMessage("You need to have permission ``CHANGE_NICKNAME`` to change your nick!", avatarURL));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,16 +5,17 @@ module.exports = {
|
|||
|
||||
async execute(client, message, _, config) {
|
||||
const taggedUser = message.mentions.users.first();
|
||||
const avatarURL = message.author.displayAvatarURL();
|
||||
|
||||
if(!taggedUser) {
|
||||
await message.channel.send(client.generateErrorMessage("You need to @mention a user!"));
|
||||
await message.channel.send(client.generateErrorMessage("You need to @mention a user!", avatarURL));
|
||||
} else {
|
||||
await message.channel.send({embeds: [{
|
||||
"title": ":anger: Slap",
|
||||
"description": `${taggedUser} You have been slapped by ${message.author}!`,
|
||||
"color": 9442302,
|
||||
"footer": {
|
||||
"icon_url": message.author.displayAvatarURL(),
|
||||
"icon_url": avatarURL,
|
||||
"text": config.footerTxt
|
||||
},
|
||||
"image": {
|
||||
|
|
|
@ -12,9 +12,10 @@ module.exports = {
|
|||
|
||||
async execute(client, message, _, config) {
|
||||
const taggedUser = message.mentions.users.first();
|
||||
const avatarURL = message.author.displayAvatarURL();
|
||||
|
||||
if(!taggedUser) {
|
||||
await message.channel.send(client.generateErrorMessage("You need to @mention a user!"));
|
||||
await message.channel.send(client.generateErrorMessage("You need to @mention a user!", avatarURL));
|
||||
} else {
|
||||
const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)];
|
||||
await message.channel.send({embeds: [{
|
||||
|
@ -22,7 +23,7 @@ module.exports = {
|
|||
"description": `${taggedUser} You have been snuggled by ${message.author}!`,
|
||||
"color": 9442302,
|
||||
"footer": {
|
||||
"icon_url": message.author.displayAvatarURL(),
|
||||
"icon_url": avatarURL,
|
||||
"text": config.footerTxt
|
||||
},
|
||||
"image": {
|
||||
|
|
4
start.js
4
start.js
|
@ -14,11 +14,11 @@ for (const file of commandFiles) {
|
|||
client.commands.set(command.name, command);
|
||||
}
|
||||
|
||||
client.generateErrorMessage = (errorMsg, messageAuthorURL) => ({embeds: [{
|
||||
client.generateErrorMessage = (errorMsg, avatarURL) => ({embeds: [{
|
||||
"title": "<:AnitroxError:809651936563429416> Error",
|
||||
"color": 13632027,
|
||||
"footer": {
|
||||
"icon_url": message.author.displayAvatarURL(),
|
||||
"icon_url": avatarURL,
|
||||
"text": config.footerTxt
|
||||
},
|
||||
"fields": [
|
||||
|
|
Reference in New Issue