Files
SupportBot/Commands/embed.js
T

67 lines
1.9 KiB
JavaScript
Raw Normal View History

2021-10-24 22:41:46 +01:00
// SupportBot | Emerald Services
// Embed Command
const fs = require("fs");
const Discord = require("discord.js");
const yaml = require("js-yaml");
2021-10-27 19:30:10 -05:00
const supportbot = yaml.load(
fs.readFileSync("./Configs/supportbot.yml", "utf8")
);
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
2021-10-24 22:41:46 +01:00
const Command = require("../Structures/Command.js");
module.exports = new Command({
name: cmdconfig.EmbedCommand,
description: cmdconfig.EmbedCommandDesc,
options: [
2021-10-24 22:41:46 +01:00
{
2021-10-25 00:02:23 -05:00
name: "title",
description: "Embed Title",
type: "STRING",
},
2021-10-24 22:41:46 +01:00
{
name: "message",
description: "Embed Message",
type: "STRING",
},
],
permissions: ["SEND_MESSAGES"],
2021-10-24 22:41:46 +01:00
async run(interaction) {
const { getRole, getChannel, getCategory } = interaction.client;
let SupportStaff = await getRole(supportbot.Staff, interaction.guild);
let Admin = await getRole(supportbot.Admin, interaction.guild);
2021-10-24 22:41:46 +01:00
if (!SupportStaff || !Admin)
2021-11-21 18:42:18 -06:00
return interaction.reply(
"Some roles seem to be missing!\nPlease check for errors when starting the bot."
);
2021-10-24 22:41:46 +01:00
const NoPerms = new Discord.MessageEmbed()
.setTitle("Invalid Permissions!")
.setDescription(
`${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\` or \`${supportbot.Admin}\``
)
.setColor(supportbot.WarningColour);
if (
interaction.member.roles.cache.has(SupportStaff.id) ||
interaction.member.roles.cache.has(Admin.id)
2021-10-24 22:41:46 +01:00
) {
2021-10-25 00:02:23 -05:00
const EmbedTitle = interaction.options.getString("title");
const EmbedSubject = interaction.options.getString("message");
2021-10-24 22:41:46 +01:00
2021-10-25 00:02:23 -05:00
const EmbedMsg = new Discord.MessageEmbed()
.setTitle(EmbedTitle)
.setDescription(EmbedSubject);
2021-10-24 22:41:46 +01:00
2021-10-25 00:02:23 -05:00
interaction.reply({
embeds: [EmbedMsg],
});
2021-10-24 22:41:46 +01:00
} else {
2021-10-25 00:02:23 -05:00
return interaction.reply({ embeds: [NoPerms] });
2021-10-24 22:41:46 +01:00
}
},
});