JaBa/commands/General/fortniteshop.js

61 lines
2 KiB
JavaScript
Raw Normal View History

2021-12-10 21:39:54 +05:00
const Command = require("../../base/Command.js"),
Discord = require("discord.js"),
Canvas = require("discord-canvas");
class Fortniteshop extends Command {
2021-12-26 19:29:37 +05:00
constructor(client) {
2021-12-10 21:39:54 +05:00
super(client, {
name: "fortniteshop",
dirname: __dirname,
enabled: true,
guildOnly: false,
2021-12-26 19:29:37 +05:00
aliases: ["fnshop"],
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: 3000
2021-12-10 21:39:54 +05:00
});
}
async run(message, args, data) {
if (!data.config.apiKeys.fortniteFNBR || data.config.apiKeys.fortniteFNBR.length === "") return message.error("misc:COMMAND_DISABLED");
2021-12-26 19:29:37 +05:00
const m = await message.sendT("misc:PLEASE_WAIT", null, {
prefixEmoji: "loading"
});
2021-12-10 21:39:54 +05:00
const momentName = this.client.languages.find((language) => language.name === data.guild.language || language.aliases.includes(data.guild.language)).moment;
const shop = new Canvas.FortniteShop();
const image = await shop
.setToken(data.config.apiKeys.fortniteFNBR)
.setText("header", message.translate("general/fortniteshop:HEADER"))
.setText("daily", message.translate("general/fortniteshop:DAILY"))
.setText("featured", message.translate("general/fortniteshop:FEATURED"))
2021-12-26 19:29:37 +05:00
.setText("date", message.translate("general/fortniteshop:DATE", {
skipInterpolation: true
}).replace("{{date}}", "{date}"))
2021-12-10 21:39:54 +05:00
.setText("footer", message.translate("general/fortniteshop:FOOTER"))
.lang(momentName)
.toAttachment();
const attachment = new Discord.MessageAttachment(image, "shop.png");
const embed = new Discord.MessageEmbed()
2021-12-26 19:29:37 +05:00
.setAuthor(message.translate("general/fortniteshop:HEADER", {
date: message.printDate(new Date(Date.now()))
}), this.client.user.displayAvatarURL({
size: 512,
dynamic: true,
format: "png"
}))
2021-12-10 21:39:54 +05:00
.attachFiles(attachment)
.setImage("attachment://shop.png")
.setColor(this.client.config.embed.color)
.setFooter(this.client.config.embed.footer);
await message.channel.send(embed);
await m.delete();
return;
}
};
module.exports = Fortniteshop;