nyx/commands/Utilities/emojiadd.js

62 lines
2.3 KiB
JavaScript
Raw Normal View History

2021-06-12 12:53:51 +02:00
const { Client, Message, MessageEmbed, Util } = require("discord.js");
module.exports = {
name: "emojiadd",
2021-07-13 05:17:39 +02:00
usage: "(Link/Photo) (Name)",
2021-06-12 12:53:51 +02:00
aliases: ["addemoji"],
description: "Show an emoji URL or add the emoji to the server",
category: "Utilities",
run: async (client, message, args) => {
if (!args.length) return client.err(message, "Utilities", "emojiadd", 0);
2021-06-24 09:53:19 +02:00
2021-06-12 12:53:51 +02:00
if (message.attachments) {
message.attachments.map(m => {
if (
m.name.endsWith(".png") ||
m.name.endsWith(".jpeg") ||
m.name.endsWith(".jpeg") ||
m.name.endsWith(".gif") ||
m.name.endsWith(".webp")
) {
try {
if (message.attachments.map(u => u.size) > 256000)
2021-06-24 09:53:19 +02:00
return client.err(message, "Utilities", "emojiadd", 50);
2021-06-12 12:53:51 +02:00
if (args[0].length < 2 || args[0].match(/\W/))
return client.err(message, "Utilities", "emojiadd", 49);
message.attachments.map(u => {
try {
2021-06-24 09:53:19 +02:00
message.guild.emojis.create(u.url, args[0]).then(msg => {
const em = message.guild.emojis.cache.find(
a => a.name == args[0]
);
message.inlineReply(
`Added <:${em.name}:${em.id}> to the server`
);
});
2021-06-12 12:53:51 +02:00
} catch (e) {
console.log(e);
return client.err(message, "Utilities", "emojiadd", 999);
}
});
} catch (e) {
console.log(e);
return client.err(message, "Utilities", "emojiadd", 999);
}
} else return client.err(message, "Utilities", "emojiadd", 48);
});
}
if (args[0].includes("https")) {
try {
2021-06-24 09:53:19 +02:00
if (args[1].length < 2 || args[1].match(/\W/))
2021-06-12 12:53:51 +02:00
return client.err(message, "Utilities", "emojiadd", 49);
2021-06-24 09:53:19 +02:00
message.guild.emojis.create(args[0], args[1]).then(msg => {
const em = message.guild.emojis.cache.find(a => a.name == args[1]);
message.inlineReply(`Added <:${em.name}:${em.id}> to the server`);
});
2021-06-12 12:53:51 +02:00
} catch (e) {
console.log(e);
return client.err(message, "Utilities", "emojiadd", 999);
}
} else return client.err(message, "Utilities", "emojiadd", 101);
},
};