SupportBot-7.2-Release

This commit is contained in:
ItzEmerald committed 2021-10-24 22:41:46 +01:00
1 parent 85667ddfad
commit d4f95e752b
22 files changed
+926 -620

No files matched your search

+11 -14
View File
@@ -4,31 +4,28 @@
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/YourAddonConfig.yml
// const exampleaddon = yaml.load(fs.readFileSync('./Addons/Settings/YourAddonConig.yml', 'utf8')); // const exampleaddon = yaml.load(fs.readFileSync('./Addons/Settings/YourAddonConfig.yml', 'utf8'));
const Command = require("../Structures/Command.js"); 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],
}) });
},
}
}); });
+50 -30
View File
@@ -1,12 +1,12 @@
// SupportBot | Emerald Services // SupportBot | Emerald Services
// Info Command // Ticket Add Command
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:\`/${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] });
} }
},
}
}); });
+50 -30
View File
@@ -1,12 +1,12 @@
// SupportBot | Emerald Services // SupportBot | Emerald Services
// Info Command // Ticket Remove Command
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:\`/${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)));
}); });
}
} }
},
}); });
+78
View File
@@ -0,0 +1,78 @@
// SupportBot | Emerald Services
// Embed Command
const fs = require("fs");
const Discord = require("discord.js");
const yaml = require("js-yaml");
const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8"));
const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8"));
const Command = require("../Structures/Command.js");
module.exports = new Command({
name: cmdconfig.EmbedCommand,
description: cmdconfig.EmbedCommandDesc,
slashCommandOptions: [
{
name: "title",
description: "Embed Title",
type: "STRING",
},
{
name: "message",
description: "Embed Message",
type: "STRING",
},
],
permission: "SEND_MESSAGES",
async run(interaction) {
let SupportStaff =
interaction.guild.roles.cache.find(
(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()
.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(Admins.id)
) {
const EmbedTitle = interaction.options.getString("title")
const EmbedSubject = interaction.options.getString("message")
const EmbedMsg = new Discord.MessageEmbed()
.setTitle(EmbedTitle)
.setDescription(EmbedSubject)
interaction.reply({
embeds: [EmbedMsg],
});
} else {
return interaction.reply({ embeds: [NoPerms] });
}
},
});
+56 -38
View File
@@ -1,15 +1,14 @@
// SupportBot | Emerald Services // SupportBot | Emerald Services
// Close Ticket Command // Help Command
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');
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 +19,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 += `**/${cmdconfig.HelpCommand}** ${cmdconfig.HelpCommandDesc}\n`;
botCommands += `**${supportbot.Prefix}${cmdconfig.InfoCommand}** ${cmdconfig.InfoCommandDesc}\n`; botCommands += `**/${cmdconfig.InfoCommand}** ${cmdconfig.InfoCommandDesc}\n`;
botCommands += `**${supportbot.Prefix}${cmdconfig.PingCommand}** ${cmdconfig.PingCommandDesc}\n` botCommands += `**/${cmdconfig.PingCommand}** ${cmdconfig.PingCommandDesc}\n`;
let ticketCommands = ""; let ticketCommands = "";
ticketCommands += `**${supportbot.Prefix}${cmdconfig.OpenTicket}** ${cmdconfig.OpenTicketDesc}\n`; ticketCommands += `**/${cmdconfig.OpenTicket}** ${cmdconfig.OpenTicketDesc}\n`;
ticketCommands += `**${supportbot.Prefix}${cmdconfig.CloseTicket}** ${cmdconfig.CloseTicketDesc}\n` ticketCommands += `**/${cmdconfig.CloseTicket}** ${cmdconfig.CloseTicketDesc}\n`;
let staffCommands = ""; let staffCommands = "";
staffCommands += `**${supportbot.Prefix}${cmdconfig.TicketAdd}** ${cmdconfig.TicketAddDesc}\n` staffCommands += `**/${cmdconfig.TicketAdd}** ${cmdconfig.TicketAddDesc}\n`;
staffCommands += `**${supportbot.Prefix}${cmdconfig.TicketRemove}** ${cmdconfig.TicketRemoveDesc}\n` staffCommands += `**/${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],
}) });
},
}
}); });
+4 -2
View File
@@ -14,13 +14,14 @@
# Commamnd Name Configuration # Commamnd Name Configuration
# ------------------------------- # -------------------------------
TicketAdd: "ticketadd" TicketAdd: "add"
TicketRemove: "ticketremove" TicketRemove: "remove"
OpenTicket: "ticket" OpenTicket: "ticket"
CloseTicket: "close" CloseTicket: "close"
InfoCommand: "info" InfoCommand: "info"
PingCommand: "ping" PingCommand: "ping"
HelpCommand: "help" HelpCommand: "help"
EmbedCommand: "embed"
# --------------------------------------- # ---------------------------------------
# Commamnd Description Configuration # Commamnd Description Configuration
@@ -33,5 +34,6 @@ CloseTicketDesc: "Close your support ticket."
InfoCommandDesc: "Get information about the brand." InfoCommandDesc: "Get information about the brand."
PingCommandDesc: "Pong!" PingCommandDesc: "Pong!"
HelpCommandDesc: "Get a list of all the commands." HelpCommandDesc: "Get a list of all the commands."
EmbedCommandDesc: "Send a message as an embed."
+2 -2
View File
@@ -17,14 +17,14 @@ SupportBot_Version: "7.2 pre-3"
# ------------------------- # -------------------------
Name: "SupportBot" Name: "SupportBot"
Prefix: "!" Prefix: "!" # Everything uses the new Slash (/) Commands feature!
Token: "BOT_TOKEN" Token: "BOT_TOKEN"
# ------------------------- # -------------------------
# Activity Configuration # Activity Configuration
# ------------------------- # -------------------------
BotActivity: "Need Help? -ticket" BotActivity: "Need Help? /ticket"
StreamingURL: "https://www.twitch.tv/YOUR_TWITCH_NAME" StreamingURL: "https://www.twitch.tv/YOUR_TWITCH_NAME"
# Set The ActivityType to "STREAMING" for a streaming status! # Set The ActivityType to "STREAMING" for a streaming status!
+1 -1
View File
@@ -1 +1 @@
TicketPanelID: '896035054235574362' TicketPanelID: ''
+13 -10
View File
@@ -4,26 +4,30 @@
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 panelconfig = yaml.load(fs.readFileSync('./Data/ticket-panel.yml', 'utf8')); const panelconfig = yaml.load(
fs.readFileSync("./Data/ticket-panel.yml", "utf8")
);
const Event = require("../Structures/Event.js"); const Event = require("../Structures/Event.js");
module.exports = new Event("messageReactionAdd", async (client) => { module.exports = new Event("messageReactionAdd", async (client) => {
let message = { let message = {
guild: reaction.message.channel.guild, guild: reaction.message.channel.guild,
author: user, author: user,
content: "N/A", content: "N/A",
channel: reaction.message.channel channel: reaction.message.channel,
} };
if (panelconfig.TicketPanel) { if (panelconfig.TicketPanel) {
if (reaction.message.id === panelconfig.TicketPanelID) { if (reaction.message.id === panelconfig.TicketPanelID) {
if (reaction.emoji.name == panelconfig.ButtonEmoji || reaction.emoji.id == panelconfig.ButtonEmoji) { if (
await reaction.users.remove(user.id) reaction.emoji.name == panelconfig.ButtonEmoji ||
reaction.emoji.id == panelconfig.ButtonEmoji
) {
await reaction.users.remove(user.id);
try { try {
const cmd = client.commands.get(cmdconfig.OpenTicket); const cmd = client.commands.get(cmdconfig.OpenTicket);
@@ -36,5 +40,4 @@ module.exports = new Event("messageReactionAdd", async (client) => {
} }
} }
} }
}); });
+37 -41
View File
@@ -8,93 +8,89 @@ const Command = require("./Command.js");
const Event = require("./Event.js"); const Event = require("./Event.js");
const intents = new Discord.Intents(32767); const intents = new Discord.Intents(32767);
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"));
class Client extends Discord.Client { class Client extends Discord.Client {
constructor() { constructor() {
super({ intents }); super({ intents });
this.commands = new Discord.Collection(); this.commands = new Discord.Collection();
this.prefix = supportbot.Prefix;
} }
start(token) { start(token) {
const commandFiles = fs.readdirSync("./Commands") const commandFiles = fs
.filter(file => file.endsWith(".js")); .readdirSync("./Commands")
.filter((file) => file.endsWith(".js"));
const commands = commandFiles.map(file => require(`../Commands/${file}`)); const commands = commandFiles.map((file) => require(`../Commands/${file}`));
console.log(`\u001b[34;1m`, '▬▬▬▬▬▬▬ Commands ▬▬▬▬▬▬▬') console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Commands ▬▬▬▬▬▬▬");
commands.forEach(cmd => { commands.forEach((cmd) => {
console.log(`\u001b[31;1m`, `${cmd.name}`, `\u001b[32;1m`, 'Loaded'); console.log(`\u001b[31;1m`, `${cmd.name}`, `\u001b[32;1m`, "Loaded");
this.commands.set(cmd.name, cmd); this.commands.set(cmd.name, cmd);
}); });
console.log(`\u001b[34;1m`, '▬▬▬▬▬▬▬ Commands ▬▬▬▬▬▬▬') console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Commands ▬▬▬▬▬▬▬");
// Addons // Addons
const addonFiles = fs.readdirSync("./Addons") const addonFiles = fs
.filter(file => file.endsWith(".js")); .readdirSync("./Addons")
.filter((file) => file.endsWith(".js"));
const addons = addonFiles.map(file => require(`../Addons/${file}`)); const addons = addonFiles.map((file) => require(`../Addons/${file}`));
console.log(' ') console.log(" ");
console.log(`\u001b[34;1m`, '▬▬▬▬▬▬▬ Addons ▬▬▬▬▬▬▬') console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Addons ▬▬▬▬▬▬▬");
addons.forEach(addon => { addons.forEach((addon) => {
console.log(`\u001b[31;1m`, `${addon.name}`, `\u001b[32;1m`, 'Loaded'); console.log(`\u001b[31;1m`, `${addon.name}`, `\u001b[32;1m`, "Loaded");
this.commands.set(addon.name, addon); this.commands.set(addon.name, addon);
}); });
console.log(`\u001b[34;1m`, '▬▬▬▬▬▬▬ Addons ▬▬▬▬▬▬▬') console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Addons ▬▬▬▬▬▬▬");
console.log(' ') console.log(" ");
// Slash Commands // Slash Commands
const slashCommands = commands const slashCommands = commands.map((cmd) => ({
.filter(cmd => ["BOTH", "SLASH"].includes(cmd.type))
.map(cmd => ({
name: cmd.name.toLowerCase(), name: cmd.name.toLowerCase(),
description: cmd.description, description: cmd.description,
permissions: [], permissions: [],
options: cmd.slashCommandOptions, options: cmd.slashCommandOptions,
defaultPermission: true defaultPermission: true,
})); }));
this.removeAllListeners(); this.removeAllListeners();
this.on("ready", async () => { this.on("ready", async () => {
const cmds = await this.application.commands.set(slashCommands); const cmds = await this.application?.commands.set(slashCommands);
console.log(' ') console.log(" ");
console.log(`\u001b[34;1m`, '▬▬▬▬▬▬▬ Slash Command ▬▬▬▬▬▬▬'), console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Slash Command ▬▬▬▬▬▬▬"),
console.log(' ') console.log(" ");
cmds.forEach(cmd => cmds.forEach((cmd) =>
console.log(`Slash Command ${cmd.name} registered`), console.log(`Slash Command ${cmd.name} registered`)
) );
});
}) console.log(" ");
console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Events ▬▬▬▬▬▬▬");
console.log(' ')
console.log(`\u001b[34;1m`, '▬▬▬▬▬▬▬ Events ▬▬▬▬▬▬▬')
fs.readdirSync("./Events") fs.readdirSync("./Events")
.filter(file => file.endsWith(".js")) .filter((file) => file.endsWith(".js"))
.forEach(file => { .forEach((file) => {
const event = require(`../Events/${file}`); const event = require(`../Events/${file}`);
console.log(`\u001b[31;1m`, `${event.event}`, `\u001b[32;1m`, 'Loaded'); console.log(`\u001b[31;1m`, `${event.event}`, `\u001b[32;1m`, "Loaded");
this.on(event.event, event.run.bind(null, this)); this.on(event.event, event.run.bind(null, this));
}); });
console.log(`\u001b[34;1m`, '▬▬▬▬▬▬▬ Events ▬▬▬▬▬▬▬') console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Events ▬▬▬▬▬▬▬");
console.log(' ') console.log(" ");
this.login(token); this.login(token);
} }
+3 -4
View File
@@ -5,17 +5,16 @@ 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"));
function RunFunction(message, args, client) {} function RunFunction(interaction) {}
class Command { class Command {
constructor(options) { constructor(options) {
this.name = options.name; this.name = options.name;
this.description = options.description; this.description = options.description;
this.permission = options.permission; this.permission = options.permission;
this.type = ["BOTH", "SLASH", "TEXT"].includes(options.type) ? options.type : "TEXT";
this.slashCommandOptions = options.slashCommandOptions || []; this.slashCommandOptions = options.slashCommandOptions || [];
this.run = options.run; this.run = options.run;
} }
+2 -3
View File
@@ -5,13 +5,12 @@ 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"));
function RunFunction(client, ...eventArgs) {} function RunFunction(client, ...eventArgs) {}
class Event { class Event {
constructor(event, runFunction) { constructor(event, runFunction) {
this.event = event; this.event = event;
this.run = runFunction; this.run = runFunction;
+37 -23
View File
@@ -8,14 +8,13 @@ const Command = require("./Command.js");
const Client = require("./Client.js"); const Client = require("./Client.js");
const Event = require("./Event.js"); const Event = require("./Event.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"));
class TicketNumberID { class TicketNumberID {
static pad(guildId) { static pad(guildId) {
let n = this.get(guildId) + ''; let n = this.get(guildId) + "";
let z = '0'; let z = "0";
let width = 4; let width = 4;
setTimeout(() => { setTimeout(() => {
this.set(guildId, this.get(guildId) + 1); this.set(guildId, this.get(guildId) + 1);
@@ -24,50 +23,65 @@ class TicketNumberID {
} }
static get(guildId) { static get(guildId) {
let ticketnumberID = JSON.parse(
let ticketnumberID = JSON.parse(fs.readFileSync("./Data/TicketData.json", "utf8")); fs.readFileSync("./Data/TicketData.json", "utf8")
);
if (!ticketnumberID[guildId]) { if (!ticketnumberID[guildId]) {
ticketnumberID[guildId] = { ticketnumberID[guildId] = {
id: 0 id: 0,
} };
fs.writeFileSync("./Data/TicketData.json", JSON.stringify(ticketnumberID, null, 4), err => { fs.writeFileSync(
"./Data/TicketData.json",
JSON.stringify(ticketnumberID, null, 4),
(err) => {
if (err) console.log(err); if (err) console.log(err);
}); }
);
return 0; return 0;
} else { } else {
return ticketnumberID[guildId].id; return ticketnumberID[guildId].id;
} }
} }
static set(guildId, value) { static set(guildId, value) {
let ticketnumberID = JSON.parse(fs.readFileSync("./Data/TicketData.json", "utf8")); let ticketnumberID = JSON.parse(
fs.readFileSync("./Data/TicketData.json", "utf8")
);
ticketnumberID[guildId] = { ticketnumberID[guildId] = {
id: value id: value,
} };
fs.writeFileSync("./Data/TicketData.json", JSON.stringify(ticketnumberID, null, 4), err => { fs.writeFileSync(
"./Data/TicketData.json",
JSON.stringify(ticketnumberID, null, 4),
(err) => {
if (err) console.log(err); if (err) console.log(err);
}); }
);
return value; return value;
} }
static reset(guildId) { static reset(guildId) {
let ticketnumberID = JSON.parse(fs.readFileSync("./Data/TicketData.json", "utf8")); let ticketnumberID = JSON.parse(
fs.readFileSync("./Data/TicketData.json", "utf8")
);
ticketnumberID[guildId] = { ticketnumberID[guildId] = {
id: 0 id: 0,
} };
fs.writeFileSync("./Data/TicketData.json", JSON.stringify(ticketnumberID, null, 4), err => { fs.writeFileSync(
"./Data/TicketData.json",
JSON.stringify(ticketnumberID, null, 4),
(err) => {
if (err) console.log(err); if (err) console.log(err);
}); }
);
return 0; return 0;
} }
+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] });
}
},
});
+101 -87
View File
@@ -4,163 +4,177 @@
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 Event = require("../Structures/Event.js"); const Event = require("../Structures/Event.js");
module.exports = new Event("interactionCreate", (client, interaction) => { module.exports = new Event("interactionCreate", (client, interaction) => {
if (interaction.isCommand()) {
if (interaction.isCommand()) return; const command = client.commands.find(
(cmd) => cmd.name.toLowerCase() == interaction.commandName
const command = client.commands.find(cmd => cmd.name.toLowerCase() == interaction.commandName); );
if (interaction.user.bot || !interaction.isCommand() || !interaction.guild) if (interaction.user.bot || !interaction.isCommand() || !interaction.guild)
return; return;
const args = [
interaction.commandName,
...client.commands
.find(cmd => cmd.name.toLowerCase() == interaction.commandName)
.slashCommandOptions.map(v => `${interaction.options.get(v.name).value}`)
];
const NotValid = new Discord.MessageEmbed() const NotValid = new Discord.MessageEmbed()
.setDescription(`:x: \`Invalid Command\` `) .setDescription(`:x: \`Invalid Command\` `)
.setColor(supportbot.ErrorColour) .setColor(supportbot.ErrorColour);
if (!command) return interaction.reply({ if (!command)
embeds: [NotValid] return interaction.reply({
embeds: [NotValid],
}); });
const permission = interaction.member.permissions.has(command.permission); const permission = interaction.member.permissions.has(command.permission);
const ValidPerms = new Discord.MessageEmbed() const ValidPerms = new Discord.MessageEmbed()
.setDescription(":x: \`Invalid Permissions\` Do you have the correct permissions to execute this command?") .setDescription(
.setColor(supportbot.ErrorColour) ":x: `Invalid Permissions` Do you have the correct permissions to execute this command?"
)
.setColor(supportbot.ErrorColour);
if (!permission) if (!permission)
return interaction.reply({ return interaction.reply({
embeds: [ValidPerms] embeds: [ValidPerms],
}); });
interaction.user = interaction.user;
command.run(interaction, args, client); command.run(interaction);
if(interaction.isButton()) {
if(interaction.customId === 'openticket') {
interaction.message.fetch()
interaction.deferUpdate()
let message = {
guild: client.guilds.cache.get(interaction.message.guildId),
author: client.users.cache.get(interaction.user.id),
content: "N/A",
channel: client.channels.cache.get(interaction.message.channelId)
} }
if (interaction.isButton()) {
if (interaction.customId === "openticket") {
try { try {
const cmd = client.commands.get(cmdconfig.OpenTicket); const cmd = client.commands.get(cmdconfig.OpenTicket);
if (!cmd) return; if (!cmd) return;
cmd.run(message, message.content) cmd.run(interaction);
} } catch (error) {
catch (error){ console.error(error);
console.error(error)
} }
} }
if(interaction.customId === 'ticketclose') { if (interaction.customId === "ticketclose") {
if (interaction.channel.name.startsWith(`${supportbot.TicketChannel}-`)) { if (interaction.channel.name.startsWith(`${supportbot.TicketChannel}-`)) {
interaction.message.fetch() interaction.message.fetch();
interaction.deferUpdate() interaction.deferUpdate();
const DeleteTicketEmbed = new Discord.MessageEmbed() const DeleteTicketEmbed = new Discord.MessageEmbed()
.setDescription(supportbot.TicketDeleteMessage) .setDescription(supportbot.TicketDeleteMessage)
.setColor(supportbot.EmbedColour) .setColor(supportbot.EmbedColour);
interaction.channel.send({embeds: [DeleteTicketEmbed]}) interaction.channel.send({ embeds: [DeleteTicketEmbed] });
let logChannel = interaction.guild.channels.cache.find(channel => channel.name === supportbot.TranscriptLog) || interaction.guild.channels.cache.find(channel => channel.id === supportbot.TranscriptLog) 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 user = interaction.user;
let name = interaction.channel.name; let name = interaction.channel.name;
let ticketChannel = interaction.channel let ticketChannel = interaction.channel;
let reason = "No Reason Provided." let reason = "No Reason Provided.";
interaction.channel.send({content: `**${supportbot.ClosingTicket}**`}) interaction.channel
.send({ content: `**${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", user.username) .addField("Closed By", user.username)
.addField("Reason", reason) .addField("Reason", reason);
interaction.channel.messages.fetch({limit: 100}).then(msgs => { interaction.channel.messages.fetch({ limit: 100 }).then((msgs) => {
let html = '' let html = "";
msgs = msgs.sort( ( a, b ) => a.createdTimestamp - b.createdTimestamp ); msgs = msgs.sort(
html += `<strong>Server Name:</strong> ${interaction.guild.name}<br>` (a, b) => a.createdTimestamp - b.createdTimestamp
html += `<strong>Ticket:</strong> ${ticketChannel.name}<br>` );
html += `<strong>Message:</strong> ${msgs.size} Messages<br><br><br>` html += `<strong>Server Name:</strong> ${interaction.guild.name}<br>`;
html += `<strong>Ticket:</strong> ${ticketChannel.name}<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>`;
html += `-----<br><br>`; html += `-----<br><br>`;
} }
}) });
const TranscriptSavedEmbed = new Discord.MessageEmbed() const TranscriptSavedEmbed = new Discord.MessageEmbed()
.setDescription(supportbot.TranscriptSavedMessage) .setDescription(supportbot.TranscriptSavedMessage)
.setColor(supportbot.SuccessColour) .setColor(supportbot.SuccessColour);
interaction.channel.send({embeds: [TranscriptSavedEmbed]}) interaction.channel.send({ embeds: [TranscriptSavedEmbed] });
let file = new Discord.MessageAttachment( Buffer.from( html ), `${name}.html` ) let file = new Discord.MessageAttachment(
logChannel.send({embeds: [logEmbed], files: [file]}) Buffer.from(html),
`${name}.html`
);
logChannel.send({ embeds: [logEmbed], files: [file] });
setTimeout(() => interaction.channel.delete(), supportbot.TicketDeleteTime) setTimeout(
() => interaction.channel.delete(),
}) supportbot.TicketDeleteTime
}) );
});
});
} }
} }
if(interaction.customId === 'ticketlock') { if (interaction.customId === "ticketlock") {
if (interaction.channel.name.startsWith(`${supportbot.TicketChannel}`)) { if (interaction.channel.name.startsWith(`${supportbot.TicketChannel}`)) {
interaction.message.fetch() interaction.message.fetch();
interaction.deferUpdate() interaction.deferUpdate();
let Admin = interaction.guild.roles.cache.find(AdminUser => AdminUser.name === supportbot.Admin) || interaction.guild.roles.cache.find(AdminUser => AdminUser.id === supportbot.Admin) let Admin =
let all = interaction.channel.permissionOverwrites.cache interaction.guild.roles.cache.find(
(AdminUser) => AdminUser.name === supportbot.Admin
) ||
interaction.guild.roles.cache.find(
(AdminUser) => AdminUser.id === supportbot.Admin
);
let all = interaction.channel.permissionOverwrites.cache;
let parent = interaction.guild.channels.cache.find(c => c.name === `${supportbot.LockTicketCategory}`) || interaction.guild.channels.cache.find(c => c.id === `${supportbot.LockTicketCategory}`) let parent =
interaction.guild.channels.cache.find(
(c) => c.name === `${supportbot.LockTicketCategory}`
) ||
interaction.guild.channels.cache.find(
(c) => c.id === `${supportbot.LockTicketCategory}`
);
if (parent) { if (parent) {
interaction.channel.setParent(parent.id) interaction.channel.setParent(parent.id);
} }
all.forEach(perm => { all.forEach((perm) => {
interaction.channel.permissionOverwrites.delete(perm.id) interaction.channel.permissionOverwrites.delete(perm.id);
});
}) interaction.channel.permissionOverwrites.create(Admin.id, {
interaction.channel.permissionOverwrites.create(Admin.id, {VIEW_CHANNEL: true}) VIEW_CHANNEL: true,
});
interaction.channel.permissionOverwrites.create(interaction.guild.id, {VIEW_CHANNEL: false})
interaction.channel.permissionOverwrites.create(interaction.guild.id, {
VIEW_CHANNEL: false,
});
const ticketDeleteButton = new Discord.MessageButton() const ticketDeleteButton = new Discord.MessageButton()
.setCustomId('ticketclose') .setCustomId("ticketclose")
.setLabel('Close') .setLabel("Close")
.setStyle(supportbot.TicketDeleteColour) .setStyle(supportbot.TicketDeleteColour)
.setEmoji(supportbot.TicketDeleteEmoji) .setEmoji(supportbot.TicketDeleteEmoji);
const row = new Discord.MessageActionRow() const row = new Discord.MessageActionRow().addComponents(
.addComponents(ticketDeleteButton) ticketDeleteButton
);
const ArchiveEmbed = new Discord.MessageEmbed() const ArchiveEmbed = new Discord.MessageEmbed()
.setTitle("Archived") .setTitle("Archived")
.setDescription(`Archived ${interaction.channel.name}`) .setDescription(`Archived ${interaction.channel.name}`)
.setColor(`${supportbot.SuccessColour}`) .setColor(`${supportbot.SuccessColour}`);
interaction.channel.send({embeds: [ArchiveEmbed]}) interaction.channel.send({ embeds: [ArchiveEmbed] });
interaction.message.edit({components: [row]}) interaction.message.edit({ components: [row] });
} }
} }
} }
}); });
-50
View File
@@ -1,50 +0,0 @@
// SupportBot | Emerald Services
// Message Create Event
const fs = require("fs");
const Discord = require("discord.js");
const yaml = require('js-yaml');
const supportbot = yaml.load(fs.readFileSync('./Data/supportbot.yml', 'utf8'));
const Event = require("../Structures/Event.js");
module.exports = new Event("messageCreate", (client, message) => {
if (message.author.bot) return;
if (!message.content.startsWith(client.prefix)) return;
const args = message.content.substring(client.prefix.length).split(/ +/);
const command = client.commands.find(cmd => cmd.name == args[0]);
const NotValid = new Discord.MessageEmbed()
.setDescription(`:x: \`${args[0]}\` is an Invalid Command `)
.setColor(supportbot.ErrorColour)
if (!command) return message.reply({
embeds: [NotValid]
});
const OnlySlashCmd = new Discord.MessageEmbed()
.setDescription(`:warning: That command is only useable as a \`Slash Command\` `)
.setColor(supportbot.WarnColour)
if (!["BOTH", "TEXT"].includes(command.type))
return message.reply({
embeds: [OnlySlashCmd]
})
const permission = message.member.permissions.has(command.permission, true);
const ValidPerms = new Discord.MessageEmbed()
.setDescription(":x: Do you have the \`${command.permission}\` permissions to execute this command?")
.setColor(supportbot.ErrorColour)
if (!permission)
return message.reply(
`You do not have the permission \`${command.permission}\` to run this command!`
);
command.run(message, args, client);
});
+82 -49
View File
@@ -4,90 +4,123 @@
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 panelconfig = yaml.load(fs.readFileSync('./Data/ticket-panel.yml', 'utf8')); const panelconfig = yaml.load(
fs.readFileSync("./Data/ticket-panel.yml", "utf8")
);
const Event = require("../Structures/Event.js"); const Event = require("../Structures/Event.js");
module.exports = new Event("ready", client => { module.exports = new Event("ready", (client) => {
client.user.setActivity(supportbot.BotActivity, { client.user.setActivity(supportbot.BotActivity, {
type: supportbot.ActivityType, type: supportbot.ActivityType,
url: supportbot.StreamingURL url: supportbot.StreamingURL,
}); });
console.log(`\u001b[32m`, `┏━━━┓╋╋╋╋╋╋╋╋╋╋╋╋╋┏┓┏━━┓╋╋╋┏┓`) console.log(`\u001b[32m`, `┏━━━┓╋╋╋╋╋╋╋╋╋╋╋╋╋┏┓┏━━┓╋╋╋┏┓`);
console.log(`\u001b[32m`, `┃┏━┓┃╋╋╋╋╋╋╋╋╋╋╋╋┏┛┗┫┏┓┃╋╋┏┛┗┓`) console.log(`\u001b[32m`, `┃┏━┓┃╋╋╋╋╋╋╋╋╋╋╋╋┏┛┗┫┏┓┃╋╋┏┛┗┓`);
console.log(`\u001b[32m`, `┃┗━━┳┓┏┳━━┳━━┳━━┳┻┓┏┫┗┛┗┳━┻┓┏┛`) console.log(`\u001b[32m`, `┃┗━━┳┓┏┳━━┳━━┳━━┳┻┓┏┫┗┛┗┳━┻┓┏┛`);
console.log(`\u001b[32m`, `┗━━┓┃┃┃┃┏┓┃┏┓┃┏┓┃┏┫┃┃┏━┓┃┏┓┃┃`) console.log(`\u001b[32m`, `┗━━┓┃┃┃┃┏┓┃┏┓┃┏┓┃┏┫┃┃┏━┓┃┏┓┃┃`);
console.log(`\u001b[32m`, `┃┗━┛┃┗┛┃┗┛┃┗┛┃┗┛┃┃┃┗┫┗━┛┃┗┛┃┗┓`) console.log(`\u001b[32m`, `┃┗━┛┃┗┛┃┗┛┃┗┛┃┗┛┃┃┃┗┫┗━┛┃┗┛┃┗┓`);
console.log(`\u001b[32m`, `┗━━━┻━━┫┏━┫┏━┻━━┻┛┗━┻━━━┻━━┻━┛`) console.log(`\u001b[32m`, `┗━━━┻━━┫┏━┫┏━┻━━┻┛┗━┻━━━┻━━┻━┛`);
console.log(`\u001b[32m`, `┗╋╋╋╋╋╋╋┃┃╋┃┃`) console.log(`\u001b[32m`, `┗╋╋╋╋╋╋╋┃┃╋┃┃`);
console.log(`\u001b[32m`, `╋╋╋╋╋╋╋┗┛╋┗┛`) console.log(`\u001b[32m`, `╋╋╋╋╋╋╋┗┛╋┗┛`);
console.log(` `) console.log(` `);
console.log(`\u001b[31m`, `――――――――――――――――――――――――――――――――――――――――――――`) console.log(`\u001b[31m`, `――――――――――――――――――――――――――――――――――――――――――――`);
console.log(` `) console.log(` `);
console.log(`\u001b[33m`, `${supportbot.Name} v${supportbot.SupportBot_Version}`, `\u001b[36m`, `Connected to Discord`) console.log(
console.log(`\u001b[33m`, `Resources:`, `\u001b[36m`, `https://emeraldsrv.dev/resources`) `\u001b[33m`,
console.log(`\u001b[33m`, `Documentation:`, `\u001b[36m`, `https://supportbot.emeraldsrv.dev`) `${supportbot.Name} v${supportbot.SupportBot_Version}`,
console.log(`\u001b[33m`, `Discord:`, `\u001b[36m`, `https://emeraldsrv.dev/discord`) `\u001b[36m`,
console.log(`\u001b[33m`, `Hosting:`, `\u001b[36m`, `https://emeraldsrv.dev/hosting`) `Connected to Discord`
console.log(` `) );
console.log(`\u001b[37m`, `SupportBot proudly created by Emerald Services`) console.log(
console.log(` `) `\u001b[33m`,
console.log(`\u001b[31m`, `――――――――――――――――――――――――――――――――――――――――――――`) `Resources:`,
`\u001b[36m`,
`https://emeraldsrv.dev/resources`
);
console.log(
`\u001b[33m`,
`Documentation:`,
`\u001b[36m`,
`https://supportbot.emeraldsrv.dev`
);
console.log(
`\u001b[33m`,
`Discord:`,
`\u001b[36m`,
`https://emeraldsrv.dev/discord`
);
console.log(
`\u001b[33m`,
`Hosting:`,
`\u001b[36m`,
`https://emeraldsrv.dev/hosting`
);
console.log(` `);
console.log(`\u001b[37m`, `SupportBot proudly created by Emerald Services`);
console.log(` `);
console.log(`\u001b[31m`, `――――――――――――――――――――――――――――――――――――――――――――`);
if (panelconfig.TicketPanel) { if (panelconfig.TicketPanel) {
let chan1 = client.channels.cache.find(channel => channel.name === panelconfig.Channel) let chan1 = client.channels.cache.find(
(channel) => channel.name === panelconfig.Channel
);
if (!chan1) { if (!chan1) {
console.log('\u001b[33m', "[WARN] Ticket reaction panel is not setup, You can do so via the configuration file!") console.log(
"\u001b[33m",
"[WARN] Ticket reaction panel is not setup, You can do so via the configuration file!"
);
return false; return false;
} }
const panelid = yaml.load(fs.readFileSync('./Data/ticket-panel-id.yml', 'utf8')); const panelid = yaml.load(
fs.readFileSync("./Data/ticket-panel-id.yml", "utf8")
);
chan1.messages.fetch(panelid.TicketPanelID).catch(async r => { chan1.messages.fetch(panelid.TicketPanelID).catch(async (r) => {
let embed = new Discord.MessageEmbed() let embed = new Discord.MessageEmbed()
.setTitle(`${panelconfig.PanelTitle}`) .setTitle(`${panelconfig.PanelTitle}`)
.setColor(supportbot.SuccessColour) .setColor(supportbot.SuccessColour)
.setFooter(supportbot.EmbedFooter); .setFooter(supportbot.EmbedFooter);
if (panelconfig.TicketPanel_Description) { if (panelconfig.TicketPanel_Description) {
embed.setDescription(panelconfig.PanelMessage) embed.setDescription(panelconfig.PanelMessage);
} }
if (panelconfig.TicketPanel_Thumbnail) { if (panelconfig.TicketPanel_Thumbnail) {
embed.setThumbnail(panelconfig.PanelThumbnail) embed.setThumbnail(panelconfig.PanelThumbnail);
} }
if (panelconfig.TicketPanel_Image) { if (panelconfig.TicketPanel_Image) {
embed.setImage(panelconfig.PanelImage) embed.setImage(panelconfig.PanelImage);
} }
let button = new Discord.MessageButton() let button = new Discord.MessageButton()
.setLabel(panelconfig.ButtonLabel) .setLabel(panelconfig.ButtonLabel)
.setCustomId('openticket') .setCustomId("openticket")
.setStyle(panelconfig.ButtonColour) .setStyle(panelconfig.ButtonColour);
let row = new Discord.MessageActionRow() let row = new Discord.MessageActionRow().addComponents(button);
.addComponents(button)
await chan1
await chan1.send({ .send({
embeds: [embed], embeds: [embed],
components: [row] components: [row],
}).then(r => { })
.then((r) => {
let data = { let data = {
"TicketPanelID": `${r.id}` TicketPanelID: `${r.id}`,
} };
let yamlStr = yaml.dump(data); let yamlStr = yaml.dump(data);
fs.writeFileSync('./Data/ticket-panel-id.yml', yamlStr, 'utf8'); fs.writeFileSync("./Data/ticket-panel-id.yml", yamlStr, "utf8");
}).catch(e => {
console.log("Raw"+e)
}) })
}) .catch((e) => {
} console.log("Raw" + e);
});
});
}
}); });
+2 -4
View File
@@ -13,12 +13,10 @@
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 Client = require("./Structures/Client.js"); const Client = require("./Structures/Client.js");
const client = new Client({}); const client = new Client({});
client.start(supportbot.Token); client.start(supportbot.Token);
+7 -7
View File
@@ -1,21 +1,21 @@
{ {
"name": "supportbot", "name": "supportbot",
"version": "7.2.0", "version": "7.2.0",
"description": "an advanced discord ticket bot", "description": "SupportBot is an open-sourced support system for discord. It's completely free to use with high amounts of customization to match your own brand.",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "start": "npm i && node index.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/1tzemerald/GlennBot.git" "url": "git+https://github.com/1tzemerald/SupportBot.git"
}, },
"author": "", "author": "Emerald Services",
"license": "ISC", "license": "MIT",
"bugs": { "bugs": {
"url": "https://github.com/1tzemerald/GlennBot/issues" "url": "https://github.com/1tzemerald/SupportBot/issues"
}, },
"homepage": "https://github.com/1tzemerald/GlennBot#readme", "homepage": "https://github.com/1tzemerald/SupportBot#readme",
"dependencies": { "dependencies": {
"discord.js": "^13.2.0", "discord.js": "^13.2.0",
"js-yaml": "^4.1.0" "js-yaml": "^4.1.0"