Compare commits

..
3 Commits
Author SHA1 Message Date
ItzEmerald 85667ddfad 7.2 pre-3 2021-10-21 19:28:23 +01:00
ItzEmerald 45c3315fd0 Update .DS_Store 2021-10-07 20:46:20 +01:00
ItzEmerald c5f550dd00 Pre-2 2021-10-07 20:46:18 +01:00
27 changed files with 674 additions and 42 deletions

No files matched your search

Vendored
BIN
View File
Binary file not shown.
+34
View File
@@ -0,0 +1,34 @@
// SupportBot | Emerald Services
// Example (default) Addon
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'));
// Your Addon Config file! Saved in /Addons/Settings/YourAddonConig.yml
// const exampleaddon = yaml.load(fs.readFileSync('./Addons/Settings/YourAddonConig.yml', 'utf8'));
const Command = require("../Structures/Command.js");
module.exports = new Command({
name: "hello",
description: "hello",
type: "BOTH",
slashCommandOptions: [],
permission: "SEND_MESSAGES",
async run(message, args, client) {
const Embed = new Discord.MessageEmbed()
.setDescription("Hello World!")
.setColor(supportbot.InfoColour)
message.channel.send({
embeds: [Embed]
})
}
});
+75
View File
@@ -0,0 +1,75 @@
// SupportBot | Emerald Services
// Info 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");
async function asyncForEach(array, callback) {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array);
}
}
module.exports = new Command({
name: cmdconfig.TicketAdd,
description: cmdconfig.TicketAddDesc,
type: "BOTH",
slashCommandOptions: [],
permission: "SEND_MESSAGES",
async run(message, args, client) {
let SupportStaff = message.guild.roles.cache.find(SupportTeam => SupportTeam.name === supportbot.Staff) || message.guild.roles.cache.find(SupportTeam => SupportTeam.id === supportbot.Staff)
let Admins = message.guild.roles.cache.find(AdminUser => AdminUser.name === supportbot.Admin) || message.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 (message.member.roles.cache.has(SupportStaff.id) || message.member.roles.cache.has(Admins.id)) {
if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) {
const Exists = new Discord.MessageEmbed()
.setTitle("No Ticket Found!")
.setDescription(`${supportbot.NoValidTicket}`)
.setColor(supportbot.WarningColour);
message.channel.send({ embeds: [Exists] });
return;
}
let uMember = message.mentions.users.first();
const UserNotExist = new Discord.MessageEmbed()
.setTitle("User Not Found!")
.setDescription(`${supportbot.UserNotFound}\n\nTry Again:\`${supportbot.Prefix}${cmdconfig.TicketAdd} <user#0000>\``)
.setColor(supportbot.ErrorColour)
if (!uMember) return message.channel.send({ embeds: [UserNotExist] });
message.channel.permissionOverwrites.edit(uMember, {
VIEW_CHANNEL: true,
READ_MESSAGE_HISTORY: true,
SEND_MESSAGES: true,
});
const Complete = new Discord.MessageEmbed()
.setTitle("User Added!")
.setDescription(supportbot.AddedUser.replace(/%user%/g, uMember.id))
.setTimestamp()
.setColor(supportbot.EmbedColour)
message.channel.send({ embeds: [Complete] });
} else {
return message.channel.send({ embeds: [NoPerms] });
}
}
});
+75
View File
@@ -0,0 +1,75 @@
// SupportBot | Emerald Services
// Info 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");
async function asyncForEach(array, callback) {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array);
}
}
module.exports = new Command({
name: cmdconfig.TicketRemove,
description: cmdconfig.TicketRemoveDesc,
type: "BOTH",
slashCommandOptions: [],
permission: "SEND_MESSAGES",
async run(message, args, client) {
let SupportStaff = message.guild.roles.cache.find(SupportTeam => SupportTeam.name === supportbot.Staff) || message.guild.roles.cache.find(SupportTeam => SupportTeam.id === supportbot.Staff)
let Admins = message.guild.roles.cache.find(AdminUser => AdminUser.name === supportbot.Admin) || message.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 (message.member.roles.cache.has(SupportStaff.id) || message.member.roles.cache.has(Admins.id)) {
if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) {
const Exists = new Discord.MessageEmbed()
.setTitle("No Ticket Found!")
.setDescription(`${supportbot.NoValidTicket}`)
.setColor(supportbot.WarningColour);
message.channel.send({ embeds: [Exists] });
return;
}
let uMember = message.mentions.users.first();
const UserNotExist = new Discord.MessageEmbed()
.setTitle("User Not Found!")
.setDescription(`${supportbot.UserNotFound}\n\nTry Again:\`${supportbot.Prefix}${cmdconfig.TicketRemove} <user#0000>\``)
.setColor(supportbot.ErrorColour)
if (!uMember) return message.channel.send({ embeds: [UserNotExist] });
message.channel.permissionOverwrites.edit(uMember, {
VIEW_CHANNEL: false,
READ_MESSAGE_HISTORY: false,
SEND_MESSAGES: false,
});
const Complete = new Discord.MessageEmbed()
.setTitle("User Removed!")
.setDescription(supportbot.RemovedUser.replace(/%user%/g, uMember.id))
.setTimestamp()
.setColor(supportbot.EmbedColour)
message.channel.send({ embeds: [Complete] });
} else {
return message.channel.send({ embeds: [NoPerms] });
}
}
});
+3 -2
View File
@@ -6,6 +6,7 @@ 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");
const TicketNumberID = require('../Structures/TicketID.js');
@@ -17,8 +18,8 @@ async function asyncForEach(array, callback) {
}
module.exports = new Command({
name: "close",
description: "Close a support ticket",
name: cmdconfig.CloseTicket,
description: cmdconfig.CloseTicketDesc,
type: "BOTH",
slashCommandOptions: [],
permission: "SEND_MESSAGES",
+86
View File
@@ -0,0 +1,86 @@
// SupportBot | Emerald Services
// Close Ticket 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");
const TicketNumberID = require('../Structures/TicketID.js');
async function asyncForEach(array, callback) {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array);
}
}
module.exports = new Command({
name: cmdconfig.HelpCommand,
description: cmdconfig.HelpCommandDesc,
type: "BOTH",
slashCommandOptions: [],
permission: "SEND_MESSAGES",
async run(message, args, client) {
let SupportStaff = message.guild.roles.cache.find(adminRole => adminRole.name === supportbot.Staff) || message.guild.roles.cache.find(staffRole => staffRole.id === supportbot.Staff);
let AdminStaff = message.guild.roles.cache.find(adminRole => adminRole.name === supportbot.Admin) || message.guild.roles.cache.find(adminRole => adminRole.id === supportbot.Admin);
if (supportbot.HelpMenu) {
let botCommands = "";
botCommands += `**${supportbot.Prefix}${cmdconfig.HelpCommand}** ${cmdconfig.HelpCommandDesc}\n`;
botCommands += `**${supportbot.Prefix}${cmdconfig.InfoCommand}** ${cmdconfig.InfoCommandDesc}\n`;
botCommands += `**${supportbot.Prefix}${cmdconfig.PingCommand}** ${cmdconfig.PingCommandDesc}\n`
let ticketCommands = "";
ticketCommands += `**${supportbot.Prefix}${cmdconfig.OpenTicket}** ${cmdconfig.OpenTicketDesc}\n`;
ticketCommands += `**${supportbot.Prefix}${cmdconfig.CloseTicket}** ${cmdconfig.CloseTicketDesc}\n`
let staffCommands = "";
staffCommands += `**${supportbot.Prefix}${cmdconfig.TicketAdd}** ${cmdconfig.TicketAddDesc}\n`
staffCommands += `**${supportbot.Prefix}${cmdconfig.TicketRemove}** ${cmdconfig.TicketRemoveDesc}\n`
const HelpEmbed1 = new Discord.MessageEmbed()
.setTitle(supportbot.Name)
.setThumbnail(message.author.displayAvatarURL())
.addFields(
{ name: '🖥️ General Commands\n', value: `${botCommands}\n`, inline: false },
{ name: '🎫 Support Commands\n', value: `${ticketCommands}\n`, inline: false },
)
.setColor(supportbot.EmbedColour)
.setFooter(supportbot.EmbedFooter, message.author.displayAvatarURL());
if (message.member.roles.cache.has(SupportStaff.id)) {
HelpEmbed1.addFields(
{ name: '🔐 Staff Commands\n', value: `${staffCommands}\n`, inline: false },
)
} else {
if ((message.member.roles.cache.has(AdminStaff.id))) {
HelpEmbed1.addFields(
{ name: '🔐 Staff Commands\n', value: `${staffCommands}\n`, inline: false },
)
}
}
if (supportbot.SendHelpPage === "dm") {
message.author.send({
embeds: [HelpEmbed1]
});
}
if (supportbot.SendHelpPage === "channel") {
message.channel.send({
embeds: [HelpEmbed1]
});
}
}
}
});
+3 -2
View File
@@ -6,12 +6,13 @@ 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: "info",
description: "Displays information about your server!",
name: cmdconfig.InfoCommand,
description: cmdconfig.InfoCommandDesc,
type: "BOTH",
slashCommandOptions: [],
permission: "SEND_MESSAGES",
+1 -5
View File
@@ -1,5 +1 @@
{
"854057237495676938": {
"id": 8
}
}
{}
+37
View File
@@ -0,0 +1,37 @@
# ___ _ ___ _
# / __> _ _ ___ ___ ___ _ _ _| |_ | . > ___ _| |_
# \__ \| | || . \| . \/ . \| '_> | | | . \/ . \ | |
# <___/`___|| _/| _/\___/|_| |_| |___/\___/ |_|
# |_| |_|
#
# SupportBot created by Emerald Services
# Installed with MIT License
#
# Discord Support: https:#emeraldsrv.dev/discord
# Community Resources: https:#emeraldsrv.dev/resources
# -------------------------------
# Commamnd Name Configuration
# -------------------------------
TicketAdd: "ticketadd"
TicketRemove: "ticketremove"
OpenTicket: "ticket"
CloseTicket: "close"
InfoCommand: "info"
PingCommand: "ping"
HelpCommand: "help"
# ---------------------------------------
# Commamnd Description Configuration
# ---------------------------------------
TicketAddDesc: "Add a user to a support ticket."
TicketRemoveDesc: "Remove a user from a support ticket."
OpenTicketDesc: "Open a new support ticket."
CloseTicketDesc: "Close your support ticket."
InfoCommandDesc: "Get information about the brand."
PingCommandDesc: "Pong!"
HelpCommandDesc: "Get a list of all the commands."
+19 -19
View File
@@ -10,6 +10,8 @@
# Discord Support: https:#emeraldsrv.dev/discord
# Community Resources: https:#emeraldsrv.dev/resources
SupportBot_Version: "7.2 pre-3"
# -------------------------
# General Configuration
# -------------------------
@@ -52,6 +54,13 @@ InfoButtonText: "Visit Site"
InfoURL: "https://emeraldsrv.dev"
InfoColour: "#f74343"
# -------------------------
# Help Configuration
# -------------------------
HelpMenu: true # Do not change!
SendHelpPage: "channel" # Set to channel or dm
# -------------------------
# Role Configuration
# -------------------------
@@ -63,6 +72,7 @@ LockdownRole: "@everyone"
Staff: "Support Team"
Admin: "Project Developer"
TicketBlackListRole: "Blacklisted"
# -------------------------
# Tickets Configuration
# -------------------------
@@ -85,25 +95,6 @@ AllowTicketMentions: true
# Set to true to allow the ticket to mention the author and the support team.
# Set to false to dis-allow mentions within tickets.
# --- Panel Config ---
# --- Start ---
ReactionChannel: "create-ticket"
ReactionEmoji: "📩"
# For cusomt emojis: <:emoji_name:EMOJI_ID>
ReactionTickets: true
ReactionMessage: "React with %reaction_emoji% to create a Support Ticket!"
ReactionPanel_Description: true
ReactionDescription: "Create a support ticket to contact a member of staff."
ReactionPanel_Thumbnail: true
ReactionThumbnail: "https://hotemoji.com/images/dl/5/ticket-emoji-by-twitter.png"
ReactionPanel_Image: true
ReactionImage: "https://wallpapercave.com/wp/wp4462546.jpg"
# --- Creation Config ---
# --- Start ---
@@ -187,3 +178,12 @@ ClosingTicket: ":warning: You have requested to close your support ticket."
ClosingConfirmation_Word: "confirm"
CloseConfirmation: false
# ---------------------------
# Error / Warning Messages
# ---------------------------
IncorrectPerms: ":x: **Err!** You do not have the correct permissions to use this command."
InvalidChannel: ":x: **Err!** Channel not found. Please create it!"
UserNotFound: ":x: **Err!** This user doesn't exist, Are they in this server?"
NoValidTicket: ":warning: You cannot execute this command here."
TicketExists: ":warning: This ticket cannot be opened, It already exists!"
+1
View File
@@ -0,0 +1 @@
TicketPanelID: '896035054235574362'
+42
View File
@@ -0,0 +1,42 @@
# ___ _ ___ _
# / __> _ _ ___ ___ ___ _ _ _| |_ | . > ___ _| |_
# \__ \| | || . \| . \/ . \| '_> | | | . \/ . \ | |
# <___/`___|| _/| _/\___/|_| |_| |___/\___/ |_|
# |_| |_|
#
# SupportBot created by Emerald Services
# Installed with MIT License
#
# Discord Support: https:#emeraldsrv.dev/discord
# Community Resources: https:#emeraldsrv.dev/resources
# -------------------------------
# Ticket Panel Configuration
# -------------------------------
TicketPanel: true
# ----------------------------------------
# Ticket Panel Message Configuration
# ----------------------------------------
Channel: "create-ticket"
ButtonEmoji: "📩"
ButtonLabel: "Open Ticket"
ButtonColour: "SUCCESS"
# Colour Options:
# -> PRIMARY - Blurple
# -> SECONDARY - Grey
# -> SUCCESS - Green
# -> DANGER - Red
PanelTitle: "Need Help? Create a Support Ticket."
TicketPanel_Description: true
TicketPanel_Thumbnail: false
TicketPanel_Image: false
PanelMessage: "Click the button to open a new support ticket."
PanelThumbnail: "https://i.imgur.com/ieeZejl.png"
PanelImage: "https://i.imgur.com/5NkcmDq.png"
+40
View File
@@ -0,0 +1,40 @@
// SupportBot | Emerald Services
// Ready 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 cmdconfig = yaml.load(fs.readFileSync('./Data/commands.yml', 'utf8'));
const panelconfig = yaml.load(fs.readFileSync('./Data/ticket-panel.yml', 'utf8'));
const Event = require("../Structures/Event.js");
module.exports = new Event("messageReactionAdd", async (client) => {
let message = {
guild: reaction.message.channel.guild,
author: user,
content: "N/A",
channel: reaction.message.channel
}
if (panelconfig.TicketPanel) {
if (reaction.message.id === panelconfig.TicketPanelID) {
if (reaction.emoji.name == panelconfig.ButtonEmoji || reaction.emoji.id == panelconfig.ButtonEmoji) {
await reaction.users.remove(user.id)
try {
const cmd = client.commands.get(cmdconfig.OpenTicket);
if(!cmd) return;
cmd.run(message, message.content);
} catch (error) {
console.error(error);
}
}
}
}
});
+24
View File
@@ -0,0 +1,24 @@
// SupportBot | Emerald Services
// Addon Structure
const fs = require("fs");
const Discord = require("discord.js");
const yaml = require('js-yaml');
const supportbot = yaml.load(fs.readFileSync('./Data/supportbot.yml', 'utf8'));
function RunFunction(message, args, client) {}
class Addon {
constructor(options) {
this.name = options.name;
this.description = options.description;
this.permission = options.permission;
this.type = ["BOTH", "SLASH", "TEXT"].includes(options.type) ? options.type : "TEXT";
this.slashCommandOptions = options.slashCommandOptions || [];
this.run = options.run;
}
}
module.exports = Addon;
+42 -6
View File
@@ -26,11 +26,35 @@ class Client extends Discord.Client {
const commands = commandFiles.map(file => require(`../Commands/${file}`));
console.log(`\u001b[34;1m`, '▬▬▬▬▬▬▬ Commands ▬▬▬▬▬▬▬')
commands.forEach(cmd => {
console.log(`Command ${cmd.name} loaded`);
console.log(`\u001b[31;1m`, `${cmd.name}`, `\u001b[32;1m`, 'Loaded');
this.commands.set(cmd.name, cmd);
});
console.log(`\u001b[34;1m`, '▬▬▬▬▬▬▬ Commands ▬▬▬▬▬▬▬')
// Addons
const addonFiles = fs.readdirSync("./Addons")
.filter(file => file.endsWith(".js"));
const addons = addonFiles.map(file => require(`../Addons/${file}`));
console.log(' ')
console.log(`\u001b[34;1m`, '▬▬▬▬▬▬▬ Addons ▬▬▬▬▬▬▬')
addons.forEach(addon => {
console.log(`\u001b[31;1m`, `${addon.name}`, `\u001b[32;1m`, 'Loaded');
this.commands.set(addon.name, addon);
});
console.log(`\u001b[34;1m`, '▬▬▬▬▬▬▬ Addons ▬▬▬▬▬▬▬')
console.log(' ')
// Slash Commands
const slashCommands = commands
.filter(cmd => ["BOTH", "SLASH"].includes(cmd.type))
.map(cmd => ({
@@ -46,20 +70,32 @@ class Client extends Discord.Client {
this.on("ready", async () => {
const cmds = await this.application.commands.set(slashCommands);
cmds.forEach(cmd => console.log(`Slash Command ${cmd.name} registered`));
console.log(' ')
console.log(`\u001b[34;1m`, '▬▬▬▬▬▬▬ Slash Command ▬▬▬▬▬▬▬'),
console.log(' ')
cmds.forEach(cmd =>
console.log(`Slash Command ${cmd.name} registered`),
)
})
console.log(' ')
console.log(`\u001b[34;1m`, '▬▬▬▬▬▬▬ Events ▬▬▬▬▬▬▬')
fs.readdirSync("./Events")
.filter(file => file.endsWith(".js"))
.forEach(file => {
/**
* @type {Event}
*/
const event = require(`../Events/${file}`);
console.log(`Event ${event.event} loaded`);
console.log(`\u001b[31;1m`, `${event.event}`, `\u001b[32;1m`, 'Loaded');
this.on(event.event, event.run.bind(null, this));
});
console.log(`\u001b[34;1m`, '▬▬▬▬▬▬▬ Events ▬▬▬▬▬▬▬')
console.log(' ')
this.login(token);
}
}
+3 -2
View File
@@ -6,12 +6,13 @@ 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: "ping",
description: "Shows the ping of the bot!",
name: cmdconfig.PingCommand,
description: cmdconfig.PingCommandDesc,
type: "BOTH",
slashCommandOptions: [],
permission: "SEND_MESSAGES",
+3 -2
View File
@@ -6,6 +6,7 @@ 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");
const TicketNumberID = require('../Structures/TicketID.js');
@@ -17,8 +18,8 @@ async function asyncForEach(array, callback) {
}
module.exports = new Command({
name: "ticket",
description: "Creates a support ticket",
name: cmdconfig.OpenTicket,
description: cmdconfig.OpenTicketDesc,
type: "BOTH",
slashCommandOptions: [],
permission: "SEND_MESSAGES",
+123 -2
View File
@@ -6,10 +6,16 @@ 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 Event = require("../Structures/Event.js");
module.exports = new Event("interactionCreate", (client, interaction) => {
if (interaction.isCommand()) return;
const command = client.commands.find(cmd => cmd.name.toLowerCase() == interaction.commandName);
if (interaction.user.bot || !interaction.isCommand() || !interaction.guild)
return;
@@ -20,8 +26,6 @@ module.exports = new Event("interactionCreate", (client, interaction) => {
.slashCommandOptions.map(v => `${interaction.options.get(v.name).value}`)
];
const command = client.commands.find(cmd => cmd.name.toLowerCase() == interaction.commandName);
const NotValid = new Discord.MessageEmbed()
.setDescription(`:x: \`Invalid Command\` `)
.setColor(supportbot.ErrorColour)
@@ -42,4 +46,121 @@ module.exports = new Event("interactionCreate", (client, interaction) => {
});
command.run(interaction, args, client);
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)
}
try {
const cmd = client.commands.get(cmdconfig.OpenTicket);
if(!cmd) return;
cmd.run(message, message.content)
}
catch (error){
console.error(error)
}
}
if(interaction.customId === 'ticketclose') {
if(interaction.channel.name.startsWith(`${supportbot.TicketChannel}-`)) {
interaction.message.fetch()
interaction.deferUpdate()
const DeleteTicketEmbed = new Discord.MessageEmbed()
.setDescription(supportbot.TicketDeleteMessage)
.setColor(supportbot.EmbedColour)
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 user = interaction.user
let name = interaction.channel.name;
let ticketChannel = interaction.channel
let reason = "No Reason Provided."
interaction.channel.send({content: `**${supportbot.ClosingTicket}**`})
.then(() => {
const logEmbed = new Discord.MessageEmbed()
.setTitle(supportbot.TranscriptTitle)
.setColor(supportbot.EmbedColour)
.setFooter(supportbot.EmbedFooter)
.addField("Closed By", user.username)
.addField("Reason", reason)
interaction.channel.messages.fetch({limit: 100}).then(msgs => {
let html = ''
msgs = msgs.sort( ( a, b ) => a.createdTimestamp - b.createdTimestamp );
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 => {
if(msg.content) {
html += `<strong>User:</strong> ${msg.author.tag}<br>`;
html += `<strong>Message:</strong> ${msg.content}<br>`;
html += `-----<br><br>`;
}
})
const TranscriptSavedEmbed = new Discord.MessageEmbed()
.setDescription(supportbot.TranscriptSavedMessage)
.setColor(supportbot.SuccessColour)
interaction.channel.send({embeds: [TranscriptSavedEmbed]})
let file = new Discord.MessageAttachment( Buffer.from( html ), `${name}.html` )
logChannel.send({embeds: [logEmbed], files: [file]})
setTimeout(() => interaction.channel.delete(), supportbot.TicketDeleteTime)
})
})
}
}
if(interaction.customId === 'ticketlock') {
if(interaction.channel.name.startsWith(`${supportbot.TicketChannel}`)) {
interaction.message.fetch()
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 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}`)
if(parent) {
interaction.channel.setParent(parent.id)
}
all.forEach(perm => {
interaction.channel.permissionOverwrites.delete(perm.id)
})
interaction.channel.permissionOverwrites.create(Admin.id, {VIEW_CHANNEL: true})
interaction.channel.permissionOverwrites.create(interaction.guild.id, {VIEW_CHANNEL: false})
const ticketDeleteButton = new Discord.MessageButton()
.setCustomId('ticketclose')
.setLabel('Close')
.setStyle(supportbot.TicketDeleteColour)
.setEmoji(supportbot.TicketDeleteEmoji)
const row = new Discord.MessageActionRow()
.addComponents(ticketDeleteButton)
const ArchiveEmbed = new Discord.MessageEmbed()
.setTitle("Archived")
.setDescription(`Archived ${interaction.channel.name}`)
.setColor(`${supportbot.SuccessColour}`)
interaction.channel.send({embeds: [ArchiveEmbed]})
interaction.message.edit({components: [row]})
}
}
}
});
+62 -1
View File
@@ -6,10 +6,16 @@ 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 panelconfig = yaml.load(fs.readFileSync('./Data/ticket-panel.yml', 'utf8'));
const Event = require("../Structures/Event.js");
module.exports = new Event("ready", client => {
client.user.setActivity(supportbot.BotActivity, {
type: supportbot.ActivityType,
url: supportbot.StreamingURL
});
console.log(`\u001b[32m`, `┏━━━┓╋╋╋╋╋╋╋╋╋╋╋╋╋┏┓┏━━┓╋╋╋┏┓`)
console.log(`\u001b[32m`, `┃┏━┓┃╋╋╋╋╋╋╋╋╋╋╋╋┏┛┗┫┏┓┃╋╋┏┛┗┓`)
console.log(`\u001b[32m`, `┃┗━━┳┓┏┳━━┳━━┳━━┳┻┓┏┫┗┛┗┳━┻┓┏┛`)
@@ -21,7 +27,8 @@ module.exports = new Event("ready", client => {
console.log(` `)
console.log(`\u001b[31m`, `――――――――――――――――――――――――――――――――――――――――――――`)
console.log(` `)
console.log(`\u001b[33m`, `${supportbot.Bot_Name} v${supportbot.SupportBot_Version}`, `\u001b[36m`, `Connected to Discord`)
console.log(`\u001b[33m`, `${supportbot.Name} v${supportbot.SupportBot_Version}`, `\u001b[36m`, `Connected to Discord`)
console.log(`\u001b[33m`, `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`)
@@ -29,4 +36,58 @@ module.exports = new Event("ready", client => {
console.log(`\u001b[37m`, `SupportBot proudly created by Emerald Services`)
console.log(` `)
console.log(`\u001b[31m`, `――――――――――――――――――――――――――――――――――――――――――――`)
if (panelconfig.TicketPanel) {
let chan1 = client.channels.cache.find(channel => channel.name === panelconfig.Channel)
if (!chan1) {
console.log('\u001b[33m', "[WARN] Ticket reaction panel is not setup, You can do so via the configuration file!")
return false;
}
const panelid = yaml.load(fs.readFileSync('./Data/ticket-panel-id.yml', 'utf8'));
chan1.messages.fetch(panelid.TicketPanelID).catch(async r => {
let embed = new Discord.MessageEmbed()
.setTitle(`${panelconfig.PanelTitle}`)
.setColor(supportbot.SuccessColour)
.setFooter(supportbot.EmbedFooter);
if (panelconfig.TicketPanel_Description) {
embed.setDescription(panelconfig.PanelMessage)
}
if (panelconfig.TicketPanel_Thumbnail) {
embed.setThumbnail(panelconfig.PanelThumbnail)
}
if (panelconfig.TicketPanel_Image) {
embed.setImage(panelconfig.PanelImage)
}
let button = new Discord.MessageButton()
.setLabel(panelconfig.ButtonLabel)
.setCustomId('openticket')
.setStyle(panelconfig.ButtonColour)
let row = new Discord.MessageActionRow()
.addComponents(button)
await chan1.send({
embeds: [embed],
components: [row]
}).then(r => {
let data = {
"TicketPanelID": `${r.id}`
}
let yamlStr = yaml.dump(data);
fs.writeFileSync('./Data/ticket-panel-id.yml', yamlStr, 'utf8');
}).catch(e => {
console.log("Raw"+e)
})
})
}
});
Generated Vendored
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -17,7 +17,7 @@
},
"homepage": "https://github.com/1tzemerald/GlennBot#readme",
"dependencies": {
"discord.js": "^13.1.0",
"discord.js": "^13.2.0",
"js-yaml": "^4.1.0"
}
}