JaBa/commands/General/quote.js

98 lines
2.3 KiB
JavaScript
Raw Normal View History

2021-12-10 21:39:54 +05:00
const Command = require("../../base/Command.js"),
Discord = require("discord.js");
class Quote extends Command {
2021-12-26 19:29:37 +05:00
constructor(client) {
2021-12-10 21:39:54 +05:00
super(client, {
name: "quote",
dirname: __dirname,
enabled: true,
guildOnly: true,
2021-12-26 19:29:37 +05:00
aliases: ["quoter"],
2021-12-10 21:39:54 +05:00
memberPermissions: [],
2021-12-26 19:29:37 +05:00
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"],
2021-12-10 21:39:54 +05:00
nsfw: false,
ownerOnly: false,
cooldown: 1000
2021-12-10 21:39:54 +05:00
});
}
2021-12-26 19:29:37 +05:00
async run(message, args, data) {
2021-12-11 21:08:37 +05:00
function embed(m) {
2021-12-10 21:39:54 +05:00
const embed = new Discord.MessageEmbed()
2022-01-04 00:35:11 +05:00
.setAuthor({
name: m.author.tag,
iconURL: m.author.displayAvatarURL({
size: 512,
dynamic: true,
format: "png"
})
})
2021-12-10 21:39:54 +05:00
.setDescription(m.content)
.setColor(m.member ? m.member.roles.highest ? m.member.roles.highest.color : data.config.embed.color : data.config.embed.color)
2022-01-04 00:35:11 +05:00
.setFooter({
text: m.guild.name + " | #" + m.channel.name
})
2021-12-10 21:39:54 +05:00
.setTimestamp(m.createdTimestamp);
if (m.attachments.size > 0) embed.setImage(m.attachments.first().url);
return embed;
};
const msgID = args[0];
if (isNaN(msgID)) {
2022-01-04 00:35:11 +05:00
message.author.send({
content: message.translate("general/quote:MISSING_ID")
}).then(() => {
2021-12-10 21:39:54 +05:00
message.delete();
}).catch(() => {
message.error("misc:CANNOT_DM");
});
return;
};
2021-12-30 20:03:36 +05:00
let channel = args[1];
if (args[1]) {
2021-12-10 21:39:54 +05:00
channel = this.client.channels.cache.get(args[1]);
if (!channel) {
message.author.send(message.translate("general/quote:NO_MESSAGE_ID")).then(() => {
message.delete();
2021-12-26 19:29:37 +05:00
}).catch(() => {
message.error("misc:CANNOT_DM")
});
2021-12-10 21:39:54 +05:00
return;
};
};
if (!channel) {
message.channel.messages.fetch(msgID).catch(() => {
message.author.send((message.translate("general/quote:NO_MESSAGE_ID"))).then(() => {
message.delete();
2021-12-26 19:29:37 +05:00
}).catch(() => {
message.error("misc:CANNOT_DM")
});
2021-12-10 21:39:54 +05:00
return;
}).then((msg) => {
message.delete();
2022-01-04 00:35:11 +05:00
message.channel.send({
embeds: [embed(msg)]
});
2021-12-10 21:39:54 +05:00
});
} else {
channel.messages.fetch(msgID).catch(() => {
message.author.send(message.translate("general/quote:NO_MESSAGE_ID")).then(() => {
message.delete();
2021-12-26 19:29:37 +05:00
}).catch(() => {
message.error("misc:CANNOT_DM")
});
2021-12-10 21:39:54 +05:00
return;
}).then((msg) => {
message.delete();
2022-01-04 00:35:11 +05:00
message.channel.send({
embeds: [embed(msg)]
});
2021-12-10 21:39:54 +05:00
});
};
}
};
module.exports = Quote;