SupportBot 8.0
This commit is contained in:
1 parent
2c5bfe8e33
commit
c95b8ccb32
30 files changed
+1426
-2293
No files matched your search
+87
-40
@@ -1,22 +1,12 @@
|
||||
// SupportBot | Emerald Services
|
||||
// Embed Command
|
||||
// File path: ./commands/embed.js
|
||||
|
||||
const fs = require("fs");
|
||||
|
||||
const Discord = require("discord.js");
|
||||
const yaml = require("js-yaml");
|
||||
|
||||
const supportbot = yaml.load(
|
||||
fs.readFileSync("./Configs/supportbot.yml", "utf8")
|
||||
);
|
||||
|
||||
const cmdconfig = yaml.load(
|
||||
fs.readFileSync("./Configs/commands.yml", "utf8")
|
||||
);
|
||||
|
||||
const msgconfig = yaml.load(
|
||||
fs.readFileSync("./Configs/messages.yml", "utf8")
|
||||
)
|
||||
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
||||
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
||||
const msgconfig = yaml.load(fs.readFileSync("./Configs/messages.yml", "utf8"));
|
||||
|
||||
const Command = require("../Structures/Command.js");
|
||||
|
||||
@@ -44,21 +34,14 @@ module.exports = new Command({
|
||||
required: false,
|
||||
},
|
||||
{
|
||||
name: "fieldtitle",
|
||||
description: "Add an additional Embed Field",
|
||||
type: Discord.ApplicationCommandOptionType.String,
|
||||
required: false,
|
||||
},
|
||||
{
|
||||
name: "fieldcontent",
|
||||
description: "Add an additional Embed Field",
|
||||
name: "fields",
|
||||
description: "Embed Fields (title|content;title|content;...)",
|
||||
type: Discord.ApplicationCommandOptionType.String,
|
||||
required: false,
|
||||
},
|
||||
{
|
||||
name: "thumbnail",
|
||||
description: "Embed Thumbnail URL",
|
||||
|
||||
type: Discord.ApplicationCommandOptionType.String,
|
||||
required: false,
|
||||
},
|
||||
@@ -68,47 +51,111 @@ module.exports = new Command({
|
||||
type: Discord.ApplicationCommandOptionType.String,
|
||||
required: false,
|
||||
},
|
||||
{
|
||||
name: "footer",
|
||||
description: "Embed Footer Text",
|
||||
type: Discord.ApplicationCommandOptionType.String,
|
||||
required: false,
|
||||
},
|
||||
{
|
||||
name: "footericon",
|
||||
description: "Embed Footer Icon URL",
|
||||
type: Discord.ApplicationCommandOptionType.String,
|
||||
required: false,
|
||||
},
|
||||
{
|
||||
name: "author",
|
||||
description: "Embed Author Name",
|
||||
type: Discord.ApplicationCommandOptionType.String,
|
||||
required: false,
|
||||
},
|
||||
{
|
||||
name: "authoricon",
|
||||
description: "Embed Author Icon URL",
|
||||
type: Discord.ApplicationCommandOptionType.String,
|
||||
required: false,
|
||||
},
|
||||
{
|
||||
name: "authorurl",
|
||||
description: "Embed Author URL",
|
||||
type: Discord.ApplicationCommandOptionType.String,
|
||||
required: false,
|
||||
},
|
||||
{
|
||||
name: "timestamp",
|
||||
description: "Include Timestamp",
|
||||
type: Discord.ApplicationCommandOptionType.Boolean,
|
||||
required: false,
|
||||
},
|
||||
{
|
||||
name: "inline",
|
||||
description: "Make Fields Inline",
|
||||
type: Discord.ApplicationCommandOptionType.Boolean,
|
||||
required: false,
|
||||
}
|
||||
],
|
||||
permissions: cmdconfig.Embed.Permission,
|
||||
|
||||
async run(interaction) {
|
||||
let disableCommand = true;
|
||||
|
||||
const { getRole } = interaction.client;
|
||||
let SupportStaff = await getRole(supportbot.Roles.StaffMember.Staff, interaction.guild);
|
||||
let Admin = await getRole(supportbot.Roles.StaffMember.Admin, interaction.guild);
|
||||
|
||||
if (!SupportStaff || !Admin)
|
||||
return interaction.reply(
|
||||
"Some roles seem to be missing!\nPlease check for errors when starting the bot."
|
||||
);
|
||||
if (!SupportStaff || !Admin) {
|
||||
return interaction.reply("Some roles seem to be missing!\nPlease check for errors when starting the bot.");
|
||||
}
|
||||
|
||||
const NoPerms = new Discord.EmbedBuilder()
|
||||
const NoPerms = new Discord.EmbedBuilder()
|
||||
.setTitle("Invalid Permissions!")
|
||||
.setDescription(
|
||||
`${msgconfig.Error.IncorrectPerms}\n\nRole Required: \`${supportbot.Roles.StaffMember.Staff}\` or \`${supportbot.Roles.StaffMember.Admin}\``
|
||||
)
|
||||
.setDescription(`${msgconfig.Error.IncorrectPerms}\n\nRole Required: \`${supportbot.Roles.StaffMember.Staff}\` or \`${supportbot.Roles.StaffMember.Admin}\``)
|
||||
.setColor(supportbot.Embed.Colours.Warn);
|
||||
|
||||
if (
|
||||
interaction.member.roles.cache.has(SupportStaff.id) ||
|
||||
interaction.member.roles.cache.has(Admin.id)
|
||||
) {
|
||||
const EmbedTitle = interaction.options.getString("title");
|
||||
const EmbedSubject = interaction.options.getString("message");
|
||||
const GeneralColour = interaction.options.getString("color");
|
||||
const EmbedTitle = interaction.options.getString("title").replace(/\\n/g, '\n');
|
||||
const EmbedSubject = interaction.options.getString("message").replace(/\\n/g, '\n');
|
||||
const GeneralColour = interaction.options.getString("color") || supportbot.Embed.Colours.Default;
|
||||
const EmbedThumbnail = interaction.options.getString("thumbnail");
|
||||
const EmbedImage = interaction.options.getString("image");
|
||||
const EmbedFieldContent = interaction.options.getString("fieldcontent");
|
||||
const EmbedFieldTitle = interaction.options.getString("fieldtitle");
|
||||
const EmbedFields = interaction.options.getString("fields");
|
||||
const EmbedFooter = interaction.options.getString("footer")?.replace(/\\n/g, '\n');
|
||||
const EmbedFooterIcon = interaction.options.getString("footericon");
|
||||
const EmbedAuthor = interaction.options.getString("author")?.replace(/\\n/g, '\n');
|
||||
const EmbedAuthorIcon = interaction.options.getString("authoricon");
|
||||
const EmbedAuthorURL = interaction.options.getString("authorurl");
|
||||
const EmbedTimestamp = interaction.options.getBoolean("timestamp");
|
||||
const InlineFields = interaction.options.getBoolean("inline");
|
||||
|
||||
const EmbedMsg = new Discord.EmbedBuilder()
|
||||
.setTitle(EmbedTitle)
|
||||
.setDescription(EmbedSubject)
|
||||
.setColor(GeneralColour)
|
||||
.setThumbnail(EmbedThumbnail)
|
||||
.setImage(EmbedImage)
|
||||
if (EmbedFieldTitle && EmbedFieldContent) { EmbedMsg.addField(EmbedFieldTitle, EmbedFieldContent) };
|
||||
.setImage(EmbedImage);
|
||||
|
||||
if (EmbedFields) {
|
||||
const fieldsArray = EmbedFields.split(';');
|
||||
fieldsArray.forEach(field => {
|
||||
const [title, value] = field.split('|');
|
||||
if (title && value) {
|
||||
EmbedMsg.addFields({ name: title.replace(/\\n/g, '\n'), value: value.replace(/\\n/g, '\n'), inline: InlineFields || false });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (EmbedFooter) {
|
||||
EmbedMsg.setFooter({ text: EmbedFooter, iconURL: EmbedFooterIcon });
|
||||
}
|
||||
|
||||
if (EmbedAuthor) {
|
||||
EmbedMsg.setAuthor({ name: EmbedAuthor, iconURL: EmbedAuthorIcon, url: EmbedAuthorURL });
|
||||
}
|
||||
|
||||
if (EmbedTimestamp) {
|
||||
EmbedMsg.setTimestamp();
|
||||
}
|
||||
|
||||
interaction.reply({
|
||||
embeds: [EmbedMsg],
|
||||
|
||||
Reference in new issue
Block a user