Updated for slash commands

This commit is contained in:
Noah committed 2021-10-23 20:04:02 -05:00
1 parent 654064d7c5
commit 33e4d97be5
8 files changed
+550 -329

No files matched your search

+9 -12
View File
@@ -4,9 +4,9 @@
const fs = require("fs"); const fs = require("fs");
const Discord = require("discord.js"); const Discord = require("discord.js");
const yaml = require('js-yaml'); const yaml = require("js-yaml");
const supportbot = yaml.load(fs.readFileSync('./Data/supportbot.yml', 'utf8')); const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8"));
const cmdconfig = yaml.load(fs.readFileSync('./Data/commands.yml', 'utf8')); const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8"));
// Your Addon Config file! Saved in /Addons/Settings/YourAddonConig.yml // Your Addon Config file! Saved in /Addons/Settings/YourAddonConig.yml
// const exampleaddon = yaml.load(fs.readFileSync('./Addons/Settings/YourAddonConig.yml', 'utf8')); // const exampleaddon = yaml.load(fs.readFileSync('./Addons/Settings/YourAddonConig.yml', 'utf8'));
@@ -16,19 +16,16 @@ const Command = require("../Structures/Command.js");
module.exports = new Command({ module.exports = new Command({
name: "hello", name: "hello",
description: "hello", description: "hello",
type: "BOTH",
slashCommandOptions: [], slashCommandOptions: [],
permission: "SEND_MESSAGES", permission: "SEND_MESSAGES",
async run(message, args, client) { async run(interaction) {
const Embed = new Discord.MessageEmbed() const Embed = new Discord.MessageEmbed()
.setDescription("Hello World!") .setDescription("Hello World!")
.setColor(supportbot.InfoColour) .setColor(supportbot.InfoColour);
message.channel.send({ interaction.reply({
embeds: [Embed] embeds: [Embed],
}) });
},
}
}); });
+49 -29
View File
@@ -4,9 +4,9 @@
const fs = require("fs"); const fs = require("fs");
const Discord = require("discord.js"); const Discord = require("discord.js");
const yaml = require('js-yaml'); const yaml = require("js-yaml");
const supportbot = yaml.load(fs.readFileSync('./Data/supportbot.yml', 'utf8')); const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8"));
const cmdconfig = yaml.load(fs.readFileSync('./Data/commands.yml', 'utf8')); const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8"));
const Command = require("../Structures/Command.js"); const Command = require("../Structures/Command.js");
@@ -19,40 +19,64 @@ async function asyncForEach(array, callback) {
module.exports = new Command({ module.exports = new Command({
name: cmdconfig.TicketAdd, name: cmdconfig.TicketAdd,
description: cmdconfig.TicketAddDesc, description: cmdconfig.TicketAddDesc,
type: "BOTH", slashCommandOptions: [
slashCommandOptions: [], {
name: "user",
description: "User to add",
type: "USER",
required: true,
},
],
permission: "SEND_MESSAGES", permission: "SEND_MESSAGES",
async run(message, args, client) { async run(interaction) {
let SupportStaff =
let SupportStaff = message.guild.roles.cache.find(SupportTeam => SupportTeam.name === supportbot.Staff) || message.guild.roles.cache.find(SupportTeam => SupportTeam.id === supportbot.Staff) interaction.guild.roles.cache.find(
let Admins = message.guild.roles.cache.find(AdminUser => AdminUser.name === supportbot.Admin) || message.guild.roles.cache.find(AdminUser => AdminUser.id === supportbot.Admin) (SupportTeam) => SupportTeam.name === supportbot.Staff
) ||
interaction.guild.roles.cache.find(
(SupportTeam) => SupportTeam.id === supportbot.Staff
);
let Admins =
interaction.guild.roles.cache.find(
(AdminUser) => AdminUser.name === supportbot.Admin
) ||
interaction.guild.roles.cache.find(
(AdminUser) => AdminUser.id === supportbot.Admin
);
const NoPerms = new Discord.MessageEmbed() const NoPerms = new Discord.MessageEmbed()
.setTitle("Invalid Permissions!") .setTitle("Invalid Permissions!")
.setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\` or \`${supportbot.Admin}\``) .setDescription(
.setColor(supportbot.WarningColour) `${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\` or \`${supportbot.Admin}\``
)
.setColor(supportbot.WarningColour);
if (message.member.roles.cache.has(SupportStaff.id) || message.member.roles.cache.has(Admins.id)) { if (
if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) { interaction.member.roles.cache.has(SupportStaff.id) ||
interaction.member.roles.cache.has(Admins.id)
) {
if (
!interaction.channel.name.startsWith(`${supportbot.TicketChannel}-`)
) {
const Exists = new Discord.MessageEmbed() const Exists = new Discord.MessageEmbed()
.setTitle("No Ticket Found!") .setTitle("No Ticket Found!")
.setDescription(`${supportbot.NoValidTicket}`) .setDescription(`${supportbot.NoValidTicket}`)
.setColor(supportbot.WarningColour); .setColor(supportbot.WarningColour);
message.channel.send({ embeds: [Exists] }); return interaction.reply({ embeds: [Exists] });
return;
} }
let uMember = message.mentions.users.first(); let uMember = interaction.options.getUser("user");
const UserNotExist = new Discord.MessageEmbed() const UserNotExist = new Discord.MessageEmbed()
.setTitle("User Not Found!") .setTitle("User Not Found!")
.setDescription(`${supportbot.UserNotFound}\n\nTry Again:\`${supportbot.Prefix}${cmdconfig.TicketAdd} <user#0000>\``) .setDescription(
.setColor(supportbot.ErrorColour) `${supportbot.UserNotFound}\n\nTry Again:\`${supportbot.Prefix}${cmdconfig.TicketAdd} <user#0000>\``
)
.setColor(supportbot.ErrorColour);
if (!uMember) return message.channel.send({ embeds: [UserNotExist] }); if (!uMember) return interaction.reply({ embeds: [UserNotExist] });
message.channel.permissionOverwrites.edit(uMember, { interaction.channel.permissionOverwrites.edit(uMember, {
VIEW_CHANNEL: true, VIEW_CHANNEL: true,
READ_MESSAGE_HISTORY: true, READ_MESSAGE_HISTORY: true,
SEND_MESSAGES: true, SEND_MESSAGES: true,
@@ -62,14 +86,10 @@ module.exports = new Command({
.setTitle("User Added!") .setTitle("User Added!")
.setDescription(supportbot.AddedUser.replace(/%user%/g, uMember.id)) .setDescription(supportbot.AddedUser.replace(/%user%/g, uMember.id))
.setTimestamp() .setTimestamp()
.setColor(supportbot.EmbedColour) .setColor(supportbot.EmbedColour);
message.channel.send({ embeds: [Complete] }); interaction.reply({ embeds: [Complete] });
} else { } else {
return interaction.reply({ embeds: [NoPerms] });
return message.channel.send({ embeds: [NoPerms] });
} }
},
}
}); });
+49 -29
View File
@@ -4,9 +4,9 @@
const fs = require("fs"); const fs = require("fs");
const Discord = require("discord.js"); const Discord = require("discord.js");
const yaml = require('js-yaml'); const yaml = require("js-yaml");
const supportbot = yaml.load(fs.readFileSync('./Data/supportbot.yml', 'utf8')); const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8"));
const cmdconfig = yaml.load(fs.readFileSync('./Data/commands.yml', 'utf8')); const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8"));
const Command = require("../Structures/Command.js"); const Command = require("../Structures/Command.js");
@@ -19,40 +19,64 @@ async function asyncForEach(array, callback) {
module.exports = new Command({ module.exports = new Command({
name: cmdconfig.TicketRemove, name: cmdconfig.TicketRemove,
description: cmdconfig.TicketRemoveDesc, description: cmdconfig.TicketRemoveDesc,
type: "BOTH", slashCommandOptions: [
slashCommandOptions: [], {
name: "user",
description: "User to remove",
type: "USER",
required: true,
},
],
permission: "SEND_MESSAGES", permission: "SEND_MESSAGES",
async run(message, args, client) { async run(interaction) {
let SupportStaff =
let SupportStaff = message.guild.roles.cache.find(SupportTeam => SupportTeam.name === supportbot.Staff) || message.guild.roles.cache.find(SupportTeam => SupportTeam.id === supportbot.Staff) interaction.guild.roles.cache.find(
let Admins = message.guild.roles.cache.find(AdminUser => AdminUser.name === supportbot.Admin) || message.guild.roles.cache.find(AdminUser => AdminUser.id === supportbot.Admin) (SupportTeam) => SupportTeam.name === supportbot.Staff
) ||
interaction.guild.roles.cache.find(
(SupportTeam) => SupportTeam.id === supportbot.Staff
);
let Admins =
interaction.guild.roles.cache.find(
(AdminUser) => AdminUser.name === supportbot.Admin
) ||
interaction.guild.roles.cache.find(
(AdminUser) => AdminUser.id === supportbot.Admin
);
const NoPerms = new Discord.MessageEmbed() const NoPerms = new Discord.MessageEmbed()
.setTitle("Invalid Permissions!") .setTitle("Invalid Permissions!")
.setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\` or \`${supportbot.Admin}\``) .setDescription(
.setColor(supportbot.WarningColour) `${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\` or \`${supportbot.Admin}\``
)
.setColor(supportbot.WarningColour);
if (message.member.roles.cache.has(SupportStaff.id) || message.member.roles.cache.has(Admins.id)) { if (
if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) { interaction.member.roles.cache.has(SupportStaff.id) ||
interaction.member.roles.cache.has(Admins.id)
) {
if (
!interaction.channel.name.startsWith(`${supportbot.TicketChannel}-`)
) {
const Exists = new Discord.MessageEmbed() const Exists = new Discord.MessageEmbed()
.setTitle("No Ticket Found!") .setTitle("No Ticket Found!")
.setDescription(`${supportbot.NoValidTicket}`) .setDescription(`${supportbot.NoValidTicket}`)
.setColor(supportbot.WarningColour); .setColor(supportbot.WarningColour);
message.channel.send({ embeds: [Exists] }); return interaction.reply({ embeds: [Exists] });
return;
} }
let uMember = message.mentions.users.first(); let uMember = interaction.options.getUser("user");
const UserNotExist = new Discord.MessageEmbed() const UserNotExist = new Discord.MessageEmbed()
.setTitle("User Not Found!") .setTitle("User Not Found!")
.setDescription(`${supportbot.UserNotFound}\n\nTry Again:\`${supportbot.Prefix}${cmdconfig.TicketRemove} <user#0000>\``) .setDescription(
.setColor(supportbot.ErrorColour) `${supportbot.UserNotFound}\n\nTry Again:\`${supportbot.Prefix}${cmdconfig.TicketRemove} <user#0000>\``
)
.setColor(supportbot.ErrorColour);
if (!uMember) return message.channel.send({ embeds: [UserNotExist] }); if (!uMember) return interaction.reply({ embeds: [UserNotExist] });
message.channel.permissionOverwrites.edit(uMember, { interaction.channel.permissionOverwrites.edit(uMember, {
VIEW_CHANNEL: false, VIEW_CHANNEL: false,
READ_MESSAGE_HISTORY: false, READ_MESSAGE_HISTORY: false,
SEND_MESSAGES: false, SEND_MESSAGES: false,
@@ -62,14 +86,10 @@ module.exports = new Command({
.setTitle("User Removed!") .setTitle("User Removed!")
.setDescription(supportbot.RemovedUser.replace(/%user%/g, uMember.id)) .setDescription(supportbot.RemovedUser.replace(/%user%/g, uMember.id))
.setTimestamp() .setTimestamp()
.setColor(supportbot.EmbedColour) .setColor(supportbot.EmbedColour);
message.channel.send({ embeds: [Complete] }); interaction.reply({ embeds: [Complete] });
} else { } else {
return interaction.reply({ embeds: [NoPerms] });
return message.channel.send({ embeds: [NoPerms] });
} }
},
}
}); });
+138 -85
View File
@@ -4,12 +4,12 @@
const fs = require("fs"); const fs = require("fs");
const Discord = require("discord.js"); const Discord = require("discord.js");
const yaml = require('js-yaml'); const yaml = require("js-yaml");
const supportbot = yaml.load(fs.readFileSync('./Data/supportbot.yml', 'utf8')); const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8"));
const cmdconfig = yaml.load(fs.readFileSync('./Data/commands.yml', 'utf8')); const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8"));
const Command = require("../Structures/Command.js"); const Command = require("../Structures/Command.js");
const TicketNumberID = require('../Structures/TicketID.js'); const TicketNumberID = require("../Structures/TicketID.js");
async function asyncForEach(array, callback) { async function asyncForEach(array, callback) {
for (let index = 0; index < array.length; index++) { for (let index = 0; index < array.length; index++) {
@@ -20,63 +20,86 @@ async function asyncForEach(array, callback) {
module.exports = new Command({ module.exports = new Command({
name: cmdconfig.CloseTicket, name: cmdconfig.CloseTicket,
description: cmdconfig.CloseTicketDesc, description: cmdconfig.CloseTicketDesc,
type: "BOTH", slashCommandOptions: [
slashCommandOptions: [], {
name: "reason",
description: "Ticket Close Reason",
type: "STRING",
},
],
permission: "SEND_MESSAGES", permission: "SEND_MESSAGES",
async run(message, args, client) { async run(interaction) {
if (!interaction.channel.name.startsWith(`${supportbot.TicketChannel}-`)) {
if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) {
const Exists = new Discord.MessageEmbed() const Exists = new Discord.MessageEmbed()
.setTitle("No Ticket Found!") .setTitle("No Ticket Found!")
.setDescription(`${supportbot.NoValidTicket}`) .setDescription(`${supportbot.NoValidTicket}`)
.setColor(supportbot.WarningColour); .setColor(supportbot.WarningColour);
message.channel.send({ embed: Exists }); return interaction.reply({ embed: Exists });
return;
} }
if (supportbot.CloseConfirmation) { if (supportbot.CloseConfirmation) {
const CloseTicketRequest = new Discord.MessageEmbed() const CloseTicketRequest = new Discord.MessageEmbed()
.setTitle(`**${supportbot.ClosingTicket}**`) .setTitle(`**${supportbot.ClosingTicket}**`)
.setDescription(`Please confirm by repeating the following word.. \`${supportbot.ClosingConfirmation_Word}\` `) .setDescription(
`Please confirm by repeating the following word.. \`${supportbot.ClosingConfirmation_Word}\` `
)
.setColor(supportbot.EmbedColour); .setColor(supportbot.EmbedColour);
message.channel.send(CloseTicketRequest).then(m => { interaction
message.channel.awaitMessages( response => response.content.toLowerCase() === supportbot.ClosingConfirmation_Word, { .reply(CloseTicketRequest)
.then((m) => {
interaction.channel
.awaitMessages(
(response) =>
response.content.toLowerCase() ===
supportbot.ClosingConfirmation_Word,
{
max: 1, max: 1,
time: 20000, time: 20000,
errors: [ 'time' ], errors: ["time"],
}
)
.then((collected) => {
let logChannel =
interaction.guild.channels.cache.find(
(channel) => channel.name === supportbot.TranscriptLog
) ||
interaction.guild.channels.cache.find(
(channel) => channel.id === supportbot.TranscriptLog
);
let user = interaction.user;
let reason =
interaction.options.getString("reason") ||
"No Reason Provided.";
let name = interaction.channel.name;
let ticketChannel = interaction.channel;
}).then( collected => { interaction
let logChannel = message.guild.channels.cache.find(channel => channel.name === supportbot.TranscriptLog) || message.guild.channels.cache.find(channel => channel.id === supportbot.TranscriptLog) .reply(`**${supportbot.ClosingTicket}**`)
let user = message.author;
let reason = args.join(" ") || "No Reason Provided.";
let name = message.channel.name;
let ticketChannel = message.channel;
message.channel.send(`**${supportbot.ClosingTicket}**`)
.then(() => { .then(() => {
const logEmbed = new Discord.MessageEmbed() const logEmbed = new Discord.MessageEmbed()
.setTitle(supportbot.TranscriptTitle) .setTitle(supportbot.TranscriptTitle)
.setColor(supportbot.EmbedColour) .setColor(supportbot.EmbedColour)
.setFooter(supportbot.EmbedFooter) .setFooter(supportbot.EmbedFooter)
.addField("Closed By", message.author.tag) .addField("Closed By", interaction.user.tag)
.addField("Reason", reason); .addField("Reason", reason);
message.channel.messages.fetch({ limit: 100 }).then( msgs => { interaction.channel.interactions
let html = ''; .fetch({ limit: 100 })
.then((msgs) => {
let html = "";
msgs = msgs.sort( ( a, b ) => a.createdTimestamp - b.createdTimestamp ); msgs = msgs.sort(
html += `<strong>Server Name:</strong> ${message.guild.name}<br>`; (a, b) => a.createdTimestamp - b.createdTimestamp
);
html += `<strong>Server Name:</strong> ${interaction.guild.name}<br>`;
html += `<strong>Ticket:</strong> ${ticketChannel.name}<br>`; html += `<strong>Ticket:</strong> ${ticketChannel.name}<br>`;
html += `<strong>Message:</strong> ${msgs.size} Messages<br><br><br>`; html += `<strong>Message:</strong> ${msgs.size} Messages<br><br><br>`;
msgs.forEach( msg => { msgs.forEach((msg) => {
if (msg.content) { if (msg.content) {
html += `<strong>User:</strong> ${msg.author.tag}<br>`; html += `<strong>User:</strong> ${msg.author.tag}<br>`;
html += `<strong>Message:</strong> ${msg.content}<br>`; html += `<strong>Message:</strong> ${msg.content}<br>`;
@@ -84,62 +107,84 @@ module.exports = new Command({
} }
}); });
logChannel.send({embeds: [logEmbed]}).catch(err => { logChannel.send({ embeds: [logEmbed] }).catch((err) => {
message.reply(err) interaction.reply(err);
}) });
let file = new Discord.MessageAttachment(
Buffer.from(html),
`${name}.html`
);
logChannel
.send({ embeds: [logEmbed], files: [file] })
.catch((err) => {
interaction.reply(err);
});
let file = new Discord.MessageAttachment( Buffer.from( html ), `${name}.html` ) interaction.channel.delete().catch((error) => {
logChannel.send({embeds: [logEmbed], files: [file]}).catch(err => { if (
message.reply(err) error.code !==
}) Discord.Constants.APIErrors.UNKNOWN_CHANNEL
) {
message.channel.delete().catch(error => { console.error(
if (error.code !== Discord.Constants.APIErrors.UNKNOWN_CHANNEL) { "Failed to delete the interaction:",
console.error('Failed to delete the message:', error); error
);
} }
}); });
})
})
})
}).catch( () => {
interaction.m.edit({content: 'The request to close the ticket has timed out.'}).then(m2 => setTimeout(() => channel.delete(3000)) );
}); });
});
});
})
.catch(() => {
interaction
.followUp({
content: "The request to close the ticket has timed out.",
})
.then((m2) => setTimeout(() => interaction.channel.delete(3000)));
});
} }
if (!supportbot.CloseConfirmation) { if (!supportbot.CloseConfirmation) {
let logChannel =
interaction.guild.channels.cache.find(
(channel) => channel.name === supportbot.TranscriptLog
) ||
interaction.guild.channels.cache.find(
(channel) => channel.id === supportbot.TranscriptLog
);
let user = interaction.user;
let reason =
(await interaction.options.getString("reason")) ||
"No Reason Provided.";
let logChannel = message.guild.channels.cache.find(channel => channel.name === supportbot.TranscriptLog) || message.guild.channels.cache.find(channel => channel.id === supportbot.TranscriptLog) let name = interaction.channel.name;
let user = message.author; let ticketChannel = interaction.channel;
let reason = args.join(" ") || "No Reason Provided.";
let name = message.channel.name; interaction
let ticketChannel = message.channel; .reply(`**${supportbot.ClosingTicket}**`)
message.channel.send(`**${supportbot.ClosingTicket}**`)
.then(() => { .then(() => {
const logEmbed = new Discord.MessageEmbed() const logEmbed = new Discord.MessageEmbed()
.setTitle(supportbot.TranscriptTitle) .setTitle(supportbot.TranscriptTitle)
.setColor(supportbot.EmbedColour) .setColor(supportbot.EmbedColour)
.setFooter(supportbot.EmbedFooter) .setFooter(supportbot.EmbedFooter)
.addField("Closed By", message.author.tag) .addField("Closed By", interaction.user.tag)
.addField("Reason", reason); .addField("Reason", reason);
message.channel.messages.fetch({ limit: 100 }).then( msgs => { interaction.channel.interactions
let html = ''; .fetch({ limit: 100 })
.then((msgs) => {
let html = "";
msgs = msgs.sort( ( a, b ) => a.createdTimestamp - b.createdTimestamp ); msgs = msgs.sort(
html += `<strong>Server Name:</strong> ${message.guild.name}<br>`; (a, b) => a.createdTimestamp - b.createdTimestamp
);
html += `<strong>Server Name:</strong> ${interaction.guild.name}<br>`;
html += `<strong>Ticket:</strong> ${ticketChannel.name}<br>`; html += `<strong>Ticket:</strong> ${ticketChannel.name}<br>`;
html += `<strong>Message:</strong> ${msgs.size} Messages<br><br><br>`; html += `<strong>Message:</strong> ${msgs.size} Messages<br><br><br>`;
msgs.forEach( msg => { msgs.forEach((msg) => {
if (msg.content) { if (msg.content) {
html += `<strong>User:</strong> ${msg.author.tag}<br>`; html += `<strong>User:</strong> ${msg.author.tag}<br>`;
html += `<strong>Message:</strong> ${msg.content}<br>`; html += `<strong>Message:</strong> ${msg.content}<br>`;
@@ -147,28 +192,36 @@ module.exports = new Command({
} }
}); });
logChannel.send({embeds: [logEmbed]}).catch(err => { logChannel.send({ embeds: [logEmbed] }).catch((err) => {
message.reply(err) interaction.reply(err);
})
let file = new Discord.MessageAttachment( Buffer.from( html ), `${name}.html` )
logChannel.send({embeds: [logEmbed], files: [file]}).catch(err => {
message.reply(err)
})
message.channel.delete().catch(error => {
if (error.code !== Discord.Constants.APIErrors.UNKNOWN_CHANNEL) {
console.error('Failed to delete the message:', error);
}
}); });
let file = new Discord.MessageAttachment(
Buffer.from(html),
`${name}.html`
);
logChannel
.send({ embeds: [logEmbed], files: [file] })
.catch((err) => {
interaction.reply(err);
});
interaction.channel.delete().catch((error) => {
if (
error.code !== Discord.Constants.APIErrors.UNKNOWN_CHANNEL
) {
console.error("Failed to delete the interaction:", error);
}
});
});
}) })
.catch(() => {
}).catch( () => { interaction
interaction.m.edit({content: 'The request to close the ticket has timed out.'}).then(m2 => setTimeout(() => channel.delete(3000)) ); .followUp({
content: "The request to close the ticket has timed out.",
})
.then((m2) => setTimeout(() => interaction.channel.delete(3000)));
}); });
}
} }
},
}); });
+53 -34
View File
@@ -4,12 +4,12 @@
const fs = require("fs"); const fs = require("fs");
const Discord = require("discord.js"); const Discord = require("discord.js");
const yaml = require('js-yaml'); const yaml = require("js-yaml");
const supportbot = yaml.load(fs.readFileSync('./Data/supportbot.yml', 'utf8')); const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8"));
const cmdconfig = yaml.load(fs.readFileSync('./Data/commands.yml', 'utf8')); const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8"));
const Command = require("../Structures/Command.js"); const Command = require("../Structures/Command.js");
const TicketNumberID = require('../Structures/TicketID.js'); const TicketNumberID = require("../Structures/TicketID.js");
async function asyncForEach(array, callback) { async function asyncForEach(array, callback) {
for (let index = 0; index < array.length; index++) { for (let index = 0; index < array.length; index++) {
@@ -20,67 +20,86 @@ async function asyncForEach(array, callback) {
module.exports = new Command({ module.exports = new Command({
name: cmdconfig.HelpCommand, name: cmdconfig.HelpCommand,
description: cmdconfig.HelpCommandDesc, description: cmdconfig.HelpCommandDesc,
type: "BOTH",
slashCommandOptions: [], slashCommandOptions: [],
permission: "SEND_MESSAGES", permission: "SEND_MESSAGES",
async run(message, args, client) { async run(interaction) {
let SupportStaff =
let SupportStaff = message.guild.roles.cache.find(adminRole => adminRole.name === supportbot.Staff) || message.guild.roles.cache.find(staffRole => staffRole.id === supportbot.Staff); interaction.guild.roles.cache.find(
let AdminStaff = message.guild.roles.cache.find(adminRole => adminRole.name === supportbot.Admin) || message.guild.roles.cache.find(adminRole => adminRole.id === supportbot.Admin); (adminRole) => adminRole.name === supportbot.Staff
) ||
interaction.guild.roles.cache.find(
(staffRole) => staffRole.id === supportbot.Staff
);
let AdminStaff =
interaction.guild.roles.cache.find(
(adminRole) => adminRole.name === supportbot.Admin
) ||
interaction.guild.roles.cache.find(
(adminRole) => adminRole.id === supportbot.Admin
);
if (supportbot.HelpMenu) { if (supportbot.HelpMenu) {
let botCommands = ""; let botCommands = "";
botCommands += `**${supportbot.Prefix}${cmdconfig.HelpCommand}** ${cmdconfig.HelpCommandDesc}\n`; botCommands += `**${supportbot.Prefix}${cmdconfig.HelpCommand}** ${cmdconfig.HelpCommandDesc}\n`;
botCommands += `**${supportbot.Prefix}${cmdconfig.InfoCommand}** ${cmdconfig.InfoCommandDesc}\n`; botCommands += `**${supportbot.Prefix}${cmdconfig.InfoCommand}** ${cmdconfig.InfoCommandDesc}\n`;
botCommands += `**${supportbot.Prefix}${cmdconfig.PingCommand}** ${cmdconfig.PingCommandDesc}\n` botCommands += `**${supportbot.Prefix}${cmdconfig.PingCommand}** ${cmdconfig.PingCommandDesc}\n`;
let ticketCommands = ""; let ticketCommands = "";
ticketCommands += `**${supportbot.Prefix}${cmdconfig.OpenTicket}** ${cmdconfig.OpenTicketDesc}\n`; ticketCommands += `**${supportbot.Prefix}${cmdconfig.OpenTicket}** ${cmdconfig.OpenTicketDesc}\n`;
ticketCommands += `**${supportbot.Prefix}${cmdconfig.CloseTicket}** ${cmdconfig.CloseTicketDesc}\n` ticketCommands += `**${supportbot.Prefix}${cmdconfig.CloseTicket}** ${cmdconfig.CloseTicketDesc}\n`;
let staffCommands = ""; let staffCommands = "";
staffCommands += `**${supportbot.Prefix}${cmdconfig.TicketAdd}** ${cmdconfig.TicketAddDesc}\n` staffCommands += `**${supportbot.Prefix}${cmdconfig.TicketAdd}** ${cmdconfig.TicketAddDesc}\n`;
staffCommands += `**${supportbot.Prefix}${cmdconfig.TicketRemove}** ${cmdconfig.TicketRemoveDesc}\n` staffCommands += `**${supportbot.Prefix}${cmdconfig.TicketRemove}** ${cmdconfig.TicketRemoveDesc}\n`;
const HelpEmbed1 = new Discord.MessageEmbed() const HelpEmbed1 = new Discord.MessageEmbed()
.setTitle(supportbot.Name) .setTitle(supportbot.Name + " Commands")
.setThumbnail(message.author.displayAvatarURL()) .setThumbnail(interaction.user.displayAvatarURL())
.addFields( .addFields(
{ name: '🖥️ General Commands\n', value: `${botCommands}\n`, inline: false }, {
{ name: '🎫 Support Commands\n', value: `${ticketCommands}\n`, inline: false }, name: "🖥️ General Commands\n",
value: `${botCommands}\n`,
inline: false,
},
{
name: "🎫 Support Commands\n",
value: `${ticketCommands}\n`,
inline: false,
}
) )
.setColor(supportbot.EmbedColour) .setColor(supportbot.EmbedColour)
.setFooter(supportbot.EmbedFooter, message.author.displayAvatarURL()); .setFooter(supportbot.EmbedFooter, interaction.user.displayAvatarURL());
if (message.member.roles.cache.has(SupportStaff.id)) { if (interaction.member.roles.cache.has(SupportStaff.id)) {
HelpEmbed1.addFields( HelpEmbed1.addFields({
{ name: '🔐 Staff Commands\n', value: `${staffCommands}\n`, inline: false }, name: "🔐 Staff Commands\n",
) value: `${staffCommands}\n`,
inline: false,
});
} else { } else {
if ((message.member.roles.cache.has(AdminStaff.id))) { if (interaction.member.roles.cache.has(AdminStaff.id)) {
HelpEmbed1.addFields( HelpEmbed1.addFields({
{ name: '🔐 Staff Commands\n', value: `${staffCommands}\n`, inline: false }, name: "🔐 Staff Commands\n",
) value: `${staffCommands}\n`,
inline: false,
});
} }
} }
if (supportbot.SendHelpPage === "dm") { if (supportbot.SendHelpPage === "dm") {
message.author.send({ interaction.user.reply({
embeds: [HelpEmbed1] embeds: [HelpEmbed1],
}); });
} }
if (supportbot.SendHelpPage === "channel") { if (supportbot.SendHelpPage === "channel") {
message.channel.send({ interaction.reply({
embeds: [HelpEmbed1] embeds: [HelpEmbed1],
}); });
} }
}
} }
},
}); });
+12 -16
View File
@@ -4,39 +4,35 @@
const fs = require("fs"); const fs = require("fs");
const Discord = require("discord.js"); const Discord = require("discord.js");
const yaml = require('js-yaml'); const yaml = require("js-yaml");
const supportbot = yaml.load(fs.readFileSync('./Data/supportbot.yml', 'utf8')); const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8"));
const cmdconfig = yaml.load(fs.readFileSync('./Data/commands.yml', 'utf8')); const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8"));
const Command = require("../Structures/Command.js"); const Command = require("../Structures/Command.js");
module.exports = new Command({ module.exports = new Command({
name: cmdconfig.InfoCommand, name: cmdconfig.InfoCommand,
description: cmdconfig.InfoCommandDesc, description: cmdconfig.InfoCommandDesc,
type: "BOTH",
slashCommandOptions: [], slashCommandOptions: [],
permission: "SEND_MESSAGES", permission: "SEND_MESSAGES",
async run(message, args, client) { async run(interaction) {
const InfoButton = new Discord.MessageButton() const InfoButton = new Discord.MessageButton()
.setLabel(supportbot.InfoButtonText) .setLabel(supportbot.InfoButtonText)
.setURL(supportbot.InfoURL) .setURL(supportbot.InfoURL)
.setStyle('LINK') .setStyle("LINK");
const inforow = new Discord.MessageActionRow() const inforow = new Discord.MessageActionRow().addComponents(InfoButton);
.addComponents(InfoButton)
const InfoEmbed = new Discord.MessageEmbed() const InfoEmbed = new Discord.MessageEmbed()
.setURL(supportbot.InfoURL) .setURL(supportbot.InfoURL)
.setTitle(supportbot.InfoTitle) .setTitle(supportbot.InfoTitle)
.setDescription(supportbot.AboutMe) .setDescription(supportbot.AboutMe)
.setColor(supportbot.InfoColour) .setColor(supportbot.InfoColour);
interaction.reply({
message.channel.send({ embeds: [InfoEmbed],
embeds: [InfoEmbed], components: [inforow] components: [inforow],
}) });
},
}
}); });
+11 -11
View File
@@ -4,27 +4,27 @@
const fs = require("fs"); const fs = require("fs");
const Discord = require("discord.js"); const Discord = require("discord.js");
const yaml = require('js-yaml'); const yaml = require("js-yaml");
const supportbot = yaml.load(fs.readFileSync('./Data/supportbot.yml', 'utf8')); const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8"));
const cmdconfig = yaml.load(fs.readFileSync('./Data/commands.yml', 'utf8')); const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8"));
const Command = require("../Structures/Command.js"); const Command = require("../Structures/Command.js");
module.exports = new Command({ module.exports = new Command({
name: cmdconfig.PingCommand, name: cmdconfig.PingCommand,
description: cmdconfig.PingCommandDesc, description: cmdconfig.PingCommandDesc,
type: "BOTH",
slashCommandOptions: [], slashCommandOptions: [],
permission: "SEND_MESSAGES", permission: "SEND_MESSAGES",
async run(message, args, client) { async run(interaction) {
const PingEmbed = new Discord.MessageEmbed() const PingEmbed = new Discord.MessageEmbed()
.setDescription(`:ping_pong: **Ping:** \`${client.ws.ping} ms\``) .setDescription(
.setColor(supportbot.EmbedColour) `:ping_pong: **Ping:** \`${interaction.client.ws.ping} ms\``
)
.setColor(supportbot.EmbedColour);
message.channel.send({ interaction.reply({
embeds: [PingEmbed] embeds: [PingEmbed],
}); });
} },
}); });
+229 -113
View File
@@ -4,12 +4,12 @@
const fs = require("fs"); const fs = require("fs");
const Discord = require("discord.js"); const Discord = require("discord.js");
const yaml = require('js-yaml'); const yaml = require("js-yaml");
const supportbot = yaml.load(fs.readFileSync('./Data/supportbot.yml', 'utf8')); const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8"));
const cmdconfig = yaml.load(fs.readFileSync('./Data/commands.yml', 'utf8')); const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8"));
const Command = require("../Structures/Command.js"); const Command = require("../Structures/Command.js");
const TicketNumberID = require('../Structures/TicketID.js'); const TicketNumberID = require("../Structures/TicketID.js");
async function asyncForEach(array, callback) { async function asyncForEach(array, callback) {
for (let index = 0; index < array.length; index++) { for (let index = 0; index < array.length; index++) {
@@ -20,226 +20,342 @@ async function asyncForEach(array, callback) {
module.exports = new Command({ module.exports = new Command({
name: cmdconfig.OpenTicket, name: cmdconfig.OpenTicket,
description: cmdconfig.OpenTicketDesc, description: cmdconfig.OpenTicketDesc,
type: "BOTH", slashCommandOptions: [
slashCommandOptions: [], {
name: "reason",
description: "Ticket Reason",
type: "STRING",
},
],
permission: "SEND_MESSAGES", permission: "SEND_MESSAGES",
async run(message, args, client) { async run(interaction) {
let reactionUser = interaction.guild.members.cache.get(interaction.user.id);
let reactionUser = message.guild.members.cache.get(message.author.id) if (
reactionUser.roles.cache.find(
if (reactionUser.roles.cache.find(role => role.name === supportbot.TicketBlackListRole) || reactionUser.roles.cache.find(role => role.id === supportbot.TicketBlackListRole)) { (role) => role.name === supportbot.TicketBlackListRole
return message.channel.send({content:`<@${message.author.id}> ${supportbot.TicketBlackListMessage}`}).then(msg => { ) ||
setTimeout(() => msg.delete(), 3500) reactionUser.roles.cache.find(
(role) => role.id === supportbot.TicketBlackListRole
)
) {
return interaction
.reply({
content: `<@${interaction.user.id}> ${supportbot.TicketBlackListMessage}`,
}) })
.then((msg) => {
setTimeout(() => msg.delete(), 3500);
});
} }
// Ticket ID // Ticket ID
let ticketNumberID = TicketNumberID.pad(message.guild.id); let ticketNumberID = TicketNumberID.pad(interaction.guild.id);
// Ticket Subject // Ticket Subject
const TicketSubject = args || supportbot.NoTicketSubject; const TicketSubject =
interaction.options?.getString("reason") || supportbot.NoTicketSubject;
const TicketExists = new Discord.MessageEmbed() const TicketExists = new Discord.MessageEmbed()
.setTitle("Ticket Exists!") .setTitle("Ticket Exists!")
.setDescription(`${supportbot.TicketExists}`) .setDescription(`${supportbot.TicketExists}`)
.setColor(supportbot.WarningColour) .setColor(supportbot.WarningColour);
if (message.guild.channels.cache.find(ticketChannel => ticketChannel.name === `${supportbot.TicketChannel}-${ticketNumberID}`)) { if (
return message.channel.send({ embeds: [TicketExists] }); interaction.guild.channels.cache.find(
(ticketChannel) =>
ticketChannel.name === `${supportbot.TicketChannel}-${ticketNumberID}`
)
) {
return interaction.reply({ embeds: [TicketExists] });
} }
const Staff = message.guild.roles.cache.find(SupportTeam => SupportTeam.name === supportbot.Staff) || message.guild.roles.cache.find(SupportTeam => SupportTeam.id === supportbot.Staff) const Staff =
const Admins = message.guild.roles.cache.find(AdminUser => AdminUser.name === supportbot.Admin) || message.guild.roles.cache.find(AdminUser => AdminUser.id === supportbot.Admin) interaction.guild.roles.cache.find(
const DeptRole1 = message.guild.roles.cache.find(DepartmentRole => DepartmentRole.name === `${supportbot.DepartmentRole_1}`) || message.guild.roles.cache.find(DepartmentRole => DepartmentRole.id === `${supportbot.DepartmentRole_1}`) (SupportTeam) => SupportTeam.name === supportbot.Staff
const DeptRole2 = message.guild.roles.cache.find(DepartmentRole => DepartmentRole.name === `${supportbot.DepartmentRole_2}`) || message.guild.roles.cache.find(DepartmentRole => DepartmentRole.id === `${supportbot.DepartmentRole_2}`) ) ||
const DeptRole3 = message.guild.roles.cache.find(DepartmentRole => DepartmentRole.name === `${supportbot.DepartmentRole_3}`) || message.guild.roles.cache.find(DepartmentRole => DepartmentRole.id === `${supportbot.DepartmentRole_3}`) interaction.guild.roles.cache.find(
const Author = message.author (SupportTeam) => SupportTeam.id === supportbot.Staff
const Everyone = message.guild.id );
const ticketChannel = await message.guild.channels.create(`${supportbot.TicketChannel}-${ticketNumberID}`, { const Admins =
interaction.guild.roles.cache.find(
(AdminUser) => AdminUser.name === supportbot.Admin
) ||
interaction.guild.roles.cache.find(
(AdminUser) => AdminUser.id === supportbot.Admin
);
const DeptRole1 =
interaction.guild.roles.cache.find(
(DepartmentRole) =>
DepartmentRole.name === `${supportbot.DepartmentRole_1}`
) ||
interaction.guild.roles.cache.find(
(DepartmentRole) =>
DepartmentRole.id === `${supportbot.DepartmentRole_1}`
);
const DeptRole2 =
interaction.guild.roles.cache.find(
(DepartmentRole) =>
DepartmentRole.name === `${supportbot.DepartmentRole_2}`
) ||
interaction.guild.roles.cache.find(
(DepartmentRole) =>
DepartmentRole.id === `${supportbot.DepartmentRole_2}`
);
const DeptRole3 =
interaction.guild.roles.cache.find(
(DepartmentRole) =>
DepartmentRole.name === `${supportbot.DepartmentRole_3}`
) ||
interaction.guild.roles.cache.find(
(DepartmentRole) =>
DepartmentRole.id === `${supportbot.DepartmentRole_3}`
);
const Author = interaction.user;
const Everyone = interaction.guild.id;
const ticketChannel = await interaction.guild.channels.create(
`${supportbot.TicketChannel}-${ticketNumberID}`,
{
type: "GUILD_TEXT", type: "GUILD_TEXT",
}) }
);
if (message.channel.name === supportbot.ReactionChannel || message.channel.id === supportbot.ReactionChannel) { if (
interaction.channel.name === supportbot.ReactionChannel ||
interaction.channel.id === supportbot.ReactionChannel
) {
const CreatedTicket = new Discord.MessageEmbed() const CreatedTicket = new Discord.MessageEmbed()
.setDescription(supportbot.TicketCreatedAlert.replace(/%ticketauthor%/g, message.author.id).replace(/%ticketid%/g, ticketChannel.id).replace(/%ticketusername%/g, message.author.username)) .setDescription(
.setColor(supportbot.EmbedColour) supportbot.TicketCreatedAlert.replace(
message.channel.send({embeds: [CreatedTicket]}).then(msg => { /%ticketauthor%/g,
setTimeout(() => msg.delete(), 5000) interaction.user.id
}) )
.replace(/%ticketid%/g, ticketChannel.id)
.replace(/%ticketusername%/g, interaction.user.username)
)
.setColor(supportbot.EmbedColour);
interaction.reply({ embeds: [CreatedTicket], ephemeral: true });
} else { } else {
const CreatedTicket = new Discord.MessageEmbed() const CreatedTicket = new Discord.MessageEmbed()
.setDescription(supportbot.TicketCreatedAlert.replace(/%ticketauthor%/g, message.author.id).replace(/%ticketid%/g, ticketChannel.id).replace(/%ticketusername%/g, message.author.username)) .setDescription(
.setColor(supportbot.EmbedColour) supportbot.TicketCreatedAlert.replace(
message.channel.send({embeds: [CreatedTicket]}).then(msg => setTimeout(() => msg.delete(), 5000)); /%ticketauthor%/g,
interaction.user.id
)
.replace(/%ticketid%/g, ticketChannel.id)
.replace(/%ticketusername%/g, interaction.user.username)
)
.setColor(supportbot.EmbedColour);
interaction.reply({ embeds: [CreatedTicket], ephemeral: true });
} }
let AllowArr = [Staff, Staff, Admins, Author] let AllowArr = [Staff, Staff, Admins, Author];
await asyncForEach(AllowArr, (index) => { await asyncForEach(AllowArr, (index) => {
ticketChannel.permissionOverwrites.create(index, {VIEW_CHANNEL: true}) ticketChannel.permissionOverwrites.create(index, { VIEW_CHANNEL: true });
}) });
let DenyArr = [Everyone] let DenyArr = [Everyone];
await asyncForEach(DenyArr, (index) => { await asyncForEach(DenyArr, (index) => {
ticketChannel.permissionOverwrites.create(index, {VIEW_CHANNEL: false}) ticketChannel.permissionOverwrites.create(index, { VIEW_CHANNEL: false });
}) });
let TicketCategory = message.guild.channels.cache.find(category => category.name === supportbot.TicketCategory) || message.guild.channels.cache.find(category => category.id === supportbot.TicketCategory) let TicketCategory =
interaction.guild.channels.cache.find(
(category) => category.name === supportbot.TicketCategory
) ||
interaction.guild.channels.cache.find(
(category) => category.id === supportbot.TicketCategory
);
if (TicketCategory) { if (TicketCategory) {
ticketChannel.setParent(TicketCategory.id) ticketChannel.setParent(TicketCategory.id);
} }
if (supportbot.AllowTicketMentions) { if (supportbot.AllowTicketMentions) {
ticketChannel.send({content:`${message.author}`}) ticketChannel.send({ content: `${interaction.user}` });
} }
const TicketMessage = new Discord.MessageEmbed() const TicketMessage = new Discord.MessageEmbed()
.setTitle(supportbot.Ticket_Title.replace(/%ticketauthor%/g, message.author.id).replace(/%ticketid%/g, ticketChannel.id).replace(/%ticketusername%/g, message.author.username)) .setTitle(
.setDescription(supportbot.TicketMessage.replace(/%ticketauthor%/g, message.author.id).replace(/%ticketid%/g, ticketChannel.id).replace(/%ticketusername%/g, message.author.username)) supportbot.Ticket_Title.replace(/%ticketauthor%/g, interaction.user.id)
.setColor(supportbot.EmbedColour) .replace(/%ticketid%/g, ticketChannel.id)
.replace(/%ticketusername%/g, interaction.user.username)
)
.setDescription(
supportbot.TicketMessage.replace(/%ticketauthor%/g, interaction.user.id)
.replace(/%ticketid%/g, ticketChannel.id)
.replace(/%ticketusername%/g, interaction.user.username)
)
.setColor(supportbot.EmbedColour);
if (supportbot.TicketSubject === "embed") { if (supportbot.TicketSubject === "embed") {
if (TicketSubject != "No Reason Provided.") {
if (TicketSubject != 'No Reason Provided.') { TicketMessage.addFields({ name: "Reason", value: TicketSubject });
TicketMessage.addFields({ name: 'Reason', value: TicketSubject })
} }
} }
if (supportbot.TicketSubject === "description") { if (supportbot.TicketSubject === "description") {
if (TicketSubject != "No Reason Provided.") {
if (TicketSubject != 'No Reason Provided.') { ticketChannel.setTopic(
ticketChannel.setTopic(`Reason: ${TicketSubject} - User ID: ${message.author.id} - Ticket: ${ticketChannel.name}`) `Reason: ${TicketSubject} - User ID: ${interaction.user.id} - Ticket: ${ticketChannel.name}`
);
} }
} }
if (supportbot.TicketDepartments) { if (supportbot.TicketDepartments) {
TicketMessage.addFields({ name: 'Departments', value: ` **${supportbot.DepartmentTitle_1}**\n **${supportbot.DepartmentTitle_2}**\n **${supportbot.DepartmentTitle_3}**` }) TicketMessage.addFields({
name: "Departments",
value: ` **${supportbot.DepartmentTitle_1}**\n **${supportbot.DepartmentTitle_2}**\n **${supportbot.DepartmentTitle_3}**`,
});
} }
const CloseButton = new Discord.MessageButton() const CloseButton = new Discord.MessageButton()
.setCustomId('ticketclose') .setCustomId("ticketclose")
.setLabel('Close') .setLabel("Close")
.setStyle(supportbot.TicketCloseColour) .setStyle(supportbot.TicketCloseColour)
.setEmoji(supportbot.TicketCloseEmoji) .setEmoji(supportbot.TicketCloseEmoji);
const LockButton = new Discord.MessageButton() const LockButton = new Discord.MessageButton()
.setCustomId('ticketlock') .setCustomId("ticketlock")
.setLabel('Lock') .setLabel("Lock")
.setStyle(supportbot.TicketLockColour) .setStyle(supportbot.TicketLockColour)
.setEmoji(supportbot.TicketLockEmoji) .setEmoji(supportbot.TicketLockEmoji);
const row2 = new Discord.MessageActionRow() const row2 = new Discord.MessageActionRow().addComponents(
.addComponents(CloseButton, LockButton) CloseButton,
LockButton
);
if (supportbot.TicketDepartments) { if (supportbot.TicketDepartments) {
let DenyArr = [DeptRole1, DeptRole2, DeptRole3];
let DenyArr = [DeptRole1, DeptRole2, DeptRole3]
await asyncForEach(DenyArr, (index) => { await asyncForEach(DenyArr, (index) => {
ticketChannel.permissionOverwrites.create(index, {VIEW_CHANNEL: false}) ticketChannel.permissionOverwrites.create(index, {
}) VIEW_CHANNEL: false,
});
});
const Department1Button = new Discord.MessageButton() const Department1Button = new Discord.MessageButton()
.setCustomId('Department1') .setCustomId("Department1")
.setLabel(`${supportbot.DepartmentTitle_1}`) .setLabel(`${supportbot.DepartmentTitle_1}`)
.setStyle(supportbot.TicketDept1Colour) .setStyle(supportbot.TicketDept1Colour)
.setEmoji(supportbot.TicketDept1Emoji) .setEmoji(supportbot.TicketDept1Emoji);
const Department2Button = new Discord.MessageButton() const Department2Button = new Discord.MessageButton()
.setCustomId('Department2') .setCustomId("Department2")
.setLabel(`${supportbot.DepartmentTitle_2}`) .setLabel(`${supportbot.DepartmentTitle_2}`)
.setStyle(supportbot.TicketDept2Colour) .setStyle(supportbot.TicketDept2Colour)
.setEmoji(supportbot.TicketDept2Emoji) .setEmoji(supportbot.TicketDept2Emoji);
const Department3Button = new Discord.MessageButton() const Department3Button = new Discord.MessageButton()
.setCustomId('Department3') .setCustomId("Department3")
.setLabel(`${supportbot.DepartmentTitle_3}`) .setLabel(`${supportbot.DepartmentTitle_3}`)
.setStyle(supportbot.TicketDept3Colour) .setStyle(supportbot.TicketDept3Colour)
.setEmoji(supportbot.TicketDept3Emoji) .setEmoji(supportbot.TicketDept3Emoji);
const row = new Discord.MessageActionRow() const row = new Discord.MessageActionRow().addComponents(
.addComponents(Department1Button, Department2Button, Department3Button) Department1Button,
Department2Button,
Department3Button
);
const m = await ticketChannel.send({embeds: [TicketMessage], components: [row]}) const m = await ticketChannel.send({
embeds: [TicketMessage],
components: [row],
});
const filter = i => { const filter = (i) => {
i.deferUpdate(); i.deferUpdate();
return i.user.id === message.author.id; return i.user.id === interaction.user.id;
}; };
const collector = m.createMessageComponentCollector({ filter, max: 1, componentType: 'BUTTON', time: 60000 }); const collector = m.createMessageComponentCollector({
filter,
collector.on('collect',async (i) => { max: 1,
componentType: "BUTTON",
if(i.customId === 'Department1') { time: 60000,
});
collector.on("collect", async (i) => {
if (i.customId === "Department1") {
ticketChannel.permissionOverwrites.edit(DeptRole1, { ticketChannel.permissionOverwrites.edit(DeptRole1, {
VIEW_CHANNEL: true, VIEW_CHANNEL: true,
READ_MESSAGE_HISTORY: true, READ_MESSAGE_HISTORY: true,
SEND_MESSAGES: true, SEND_MESSAGES: true,
}) });
if (!supportbot.AllowStaff) { if (!supportbot.AllowStaff) {
ticketChannel.permissionOverwrites.edit(Staff, { VIEW_CHANNEL: false, READ_MESSAGE_HISTORY: false, SEND_MESSAGES: false }) ticketChannel.permissionOverwrites.edit(Staff, {
VIEW_CHANNEL: false,
READ_MESSAGE_HISTORY: false,
SEND_MESSAGES: false,
});
} }
const Department1 = new Discord.MessageEmbed() const Department1 = new Discord.MessageEmbed()
.setDescription(`> Thank for reaching out to the **${supportbot.DepartmentTitle_1} Department**. Please provide us information regarding your query.`) .setDescription(
.setColor(supportbot.EmbedColour) `> Thank for reaching out to the **${supportbot.DepartmentTitle_1} Department**. Please provide us information regarding your query.`
)
.setColor(supportbot.EmbedColour);
ticketChannel.send({ embeds: [Department1] }); ticketChannel.send({ embeds: [Department1] });
if (supportbot.AllowTicketMentions) { if (supportbot.AllowTicketMentions) {
ticketChannel.send({content: `@here`}) ticketChannel.send({ content: `@here` });
} }
} }
i.message.edit({embeds: [TicketMessage], components: [row2]}) i.message.edit({ embeds: [TicketMessage], components: [row2] });
if(i.customId === 'Department2') {
if (i.customId === "Department2") {
ticketChannel.permissionOverwrites.edit(DeptRole2, { ticketChannel.permissionOverwrites.edit(DeptRole2, {
VIEW_CHANNEL: true, VIEW_CHANNEL: true,
READ_MESSAGE_HISTORY: true, READ_MESSAGE_HISTORY: true,
SEND_MESSAGES: true, SEND_MESSAGES: true,
}) });
if (!supportbot.AllowStaff) { if (!supportbot.AllowStaff) {
ticketChannel.permissionOverwrites.edit(Staff, { VIEW_CHANNEL: false, READ_MESSAGE_HISTORY: false, SEND_MESSAGES: false }) ticketChannel.permissionOverwrites.edit(Staff, {
VIEW_CHANNEL: false,
READ_MESSAGE_HISTORY: false,
SEND_MESSAGES: false,
});
} }
const Department2 = new Discord.MessageEmbed() const Department2 = new Discord.MessageEmbed()
.setDescription(`> Thank for reaching out to the **${supportbot.DepartmentTitle_2} Department**. Please provide us information regarding your query.`) .setDescription(
.setColor(supportbot.EmbedColour) `> Thank for reaching out to the **${supportbot.DepartmentTitle_2} Department**. Please provide us information regarding your query.`
)
.setColor(supportbot.EmbedColour);
ticketChannel.send({ embeds: [Department2] }); ticketChannel.send({ embeds: [Department2] });
if (supportbot.AllowTicketMentions) { if (supportbot.AllowTicketMentions) {
ticketChannel.send({content: `@here`}) ticketChannel.send({ content: `@here` });
} }
i.message.edit({embeds: [TicketMessage], components: [row2]}) i.message.edit({ embeds: [TicketMessage], components: [row2] });
} }
if(i.customId === 'Department3') { if (i.customId === "Department3") {
ticketChannel.permissionOverwrites.edit(DeptRole3, { ticketChannel.permissionOverwrites.edit(DeptRole3, {
VIEW_CHANNEL: true, VIEW_CHANNEL: true,
READ_MESSAGE_HISTORY: true, READ_MESSAGE_HISTORY: true,
SEND_MESSAGES: true, SEND_MESSAGES: true,
}) });
if (!supportbot.AllowStaff) { if (!supportbot.AllowStaff) {
ticketChannel.permissionOverwrites.edit(Staff, { VIEW_CHANNEL: false, READ_MESSAGE_HISTORY: false, SEND_MESSAGES: false }) ticketChannel.permissionOverwrites.edit(Staff, {
VIEW_CHANNEL: false,
READ_MESSAGE_HISTORY: false,
SEND_MESSAGES: false,
});
} }
const Department3 = new Discord.MessageEmbed() const Department3 = new Discord.MessageEmbed()
.setDescription(`> Thank for reaching out to the **${supportbot.DepartmentTitle_3} Department**. Please provide us information regarding your query.`) .setDescription(
.setColor(supportbot.EmbedColour) `> Thank for reaching out to the **${supportbot.DepartmentTitle_3} Department**. Please provide us information regarding your query.`
)
.setColor(supportbot.EmbedColour);
ticketChannel.send({ embeds: [Department3] }); ticketChannel.send({ embeds: [Department3] });
if (supportbot.AllowTicketMentions) { if (supportbot.AllowTicketMentions) {
ticketChannel.send({content: `@here`}) ticketChannel.send({ content: `@here` });
} }
i.message.edit({embeds: [TicketMessage], components: [row2]}) i.message.edit({ embeds: [TicketMessage], components: [row2] });
}
})
} else {
ticketChannel.send({embeds: [TicketMessage], components: [row2]})
}
} }
}); });
} else {
ticketChannel.send({ embeds: [TicketMessage], components: [row2] });
}
},
});