This commit is contained in:
Eartharoid 2019-05-05 18:42:56 +01:00
parent 69dcd8b205
commit 959f79b2ca
7 changed files with 154 additions and 76 deletions

View File

@ -14,6 +14,38 @@ module.exports = {
const client = message.client;
// command starts here
message.delete();
if(!message.channel.name.startsWith('ticket-')) { // // !message.channel.name.length() == 15 &&
if(config.useEmbeds) {
const notTicket = new Discord.RichEmbed()
.setColor("#E74C3C")
.setDescription(`:x: **This command can only be used within a ticket channel**`)
return message.channel.send(notTicket);
} else {
return message.channel.send(`:x: **This command can only be used within a ticket channel**`)
}
} else {
try {
message.channel.delete()
// log
if(config.useEmbeds) {
const embed = new Discord.RichEmbed()
.setAuthor(`${client.user.username} / Ticket Log`, client.user.avatarURL)
.setTitle("Ticket Closed")
.setColor(config.colour)
.addField("Username", message.author, true)
.addField("Channel", message.channel.name, true)
.setFooter(`DiscordTickets`)
.setTimestamp();
client.channels.get(config.logChannel).send({embed})
} else {
client.channels.get(config.logChannel).send(`Ticket closed by **${message.author.tag} (${message.author.id})**`);
}
log.info(`${message.author.tag} closed a ticket (#${message.channel.name})`)
} catch(error) {
console.error(leeks.colours.red(error));
}
}

View File

@ -31,12 +31,12 @@ module.exports = {
data.push(`\nType\`${config.prefix}help [command]\` for more information about a specific command.`);
const embed = new Discord.RichEmbed()
.setAuthor(`${client.user.username} / Commands`, client.user.avatarURL)
.setTitle("Commands")
.setColor(config.colour)
.setDescription(`\nType\`${config.prefix}help [command]\` for more information about a specific command.`)
// .addField("...", `...`, true)
// .addField("...", `...`, true)
.setFooter(`${client.guilds.get(config.guildID).name} : DiscordTickets by Eartharoid`);
.setFooter(`DiscordTickets by Eartharoid`);
var cmds = [];
cmds.push(commands.map(command => embed.addField(`${config.prefix}${command.name}`, `\`${command.description}\``)));
@ -63,10 +63,10 @@ module.exports = {
}
const cmd = new Discord.RichEmbed()
.setAuthor(`${client.user.username} / Commands`, client.user.avatarURL)
.setTitle("Commands")
.setColor(config.colour)
.addField(`Command`,`\`${command.name}\``, true)
.setFooter(`${client.guilds.get(config.guildID).name} : DiscordTickets by Eartharoid`);
.setFooter(`DiscordTickets by Eartharoid`);
if (command.aliases) cmd.addField("Aliases", `\`${command.aliases.join(', ')}\``, true);
if (command.description) cmd.addField("Description", `\`${command.description}\``, true);
@ -118,6 +118,7 @@ module.exports = {
}
// command ends here
},
};

View File

@ -15,7 +15,6 @@ module.exports = {
const client = message.client;
// command starts here
message.delete();
const ticketChannel = "channel";
let topic = args.join(" ");
// let num = randomString({
@ -41,50 +40,78 @@ module.exports = {
message.guild.createChannel(`ticket-${id}`).then(async c => {
c.setParent(config.ticketsCat);
// let supportrole = message.guild.roles.find(`id`, config.supportRole)
let supportrole = message.guild.roles.get(config.supportRole)
if(!supportrole) return message.channel.send(":x: No **Support Team** role found.");
// let supportRole = message.guild.roles.find(`id`, config.supportRole)
let supportRole = message.guild.roles.get(config.supportRole)
if(!supportRole) return message.channel.send(":x: No **Support Team** role found.");
// c.overwritePermissions(message.guild.defaultRole, {
// VIEW_CHANNEL: false,
// SEND_MESSAGES: false
// })
// c.overwritePermissions(message.member, {
// VIEW_CHANNEL: true,
// SEND_MESSAGES: true
// })
// c.overwritePermissions(supportrole, {
// VIEW_CHANNEL: true,
// SEND_MESSAGES: true
// })
// c.setTopic(`${message.author} | ${topic}`);
//
// const embed2 = new Discord.RichEmbed()
// .setColor(colour)
// .setDescription(`Your ticket (${c}) has been created.`)
// .setTimestamp()
// .setFooter(`${config.footer}`, config.logo);
//
// message.channel.send(embed2)
// c.send(`<@&${config.supportRole}>\n`)
// c.send(embed3)
c.overwritePermissions(message.guild.defaultRole, {
VIEW_CHANNEL: false,
SEND_MESSAGES: false
})
c.overwritePermissions(message.member, {
VIEW_CHANNEL: true,
SEND_MESSAGES: true
})
c.overwritePermissions(supportRole, {
VIEW_CHANNEL: true,
SEND_MESSAGES: true
})
c.setTopic(`${message.author} | ${topic}`);
if(config.tagHereOnly){
await c.send(`@here, a user has created a new ticket.\n`);
} else {
await c.send(`<@&${config.supportRole}>, a user has created a new ticket.\n`);
};
if(config.ticketImage) {
await c.send(`__**Here's your ticket channel, ${message.author}**__`,{files: [`./image.png`]})
} else {
await c.send(`__**Here's your ticket channel, ${message.author}**__`)
}
const created = new Discord.RichEmbed()
.setColor(config.colour)
.setDescription(`Your ticket (${c}) has been created.\nPlease read the information sent and follow any instructions given.`)
.setTimestamp();
const welcome = new Discord.RichEmbed()
.setColor(config.colour)
.setDescription(`**Ticket topic:** \`${topic}\`\n\n${config.ticketText}`)
if(config.useEmbeds) {
message.channel.send(created)
let w = await c.send(welcome)
await w.pin();
// c.fetchMessage(c.lastMessageID).delete()
} else {
message.channel.send(`Your ticket (${c}) has been created.\nPlease read the information sent and follow any instructions given.`)
let w = await c.send(`**Ticket topic:** \`${topic}\`\n\n${config.ticketText}`)
await w.pin()
// c.fetchMessage(c.lastMessageID).delete()
}
// log
if(config.useEmbeds) {
const embed = new Discord.RichEmbed()
.setAuthor(`${client.user.username} / Ticket Log`, client.user.avatarURL)
.setTitle("New Ticket")
.setColor(config.colour)
.setDescription(`\`${topic}\``)
.addField("Username", message.author, true)
.addField("Channel", c, true)
.setFooter(`DiscordTickets`)
.setTimestamp();
client.channels.get(config.logChannel).send({embed})
} else {
client.channels.get(config.logChannel).send(`New ticket created by **${message.author.tag} (${message.author.id})**`);
}
log.info(`${message.author.tag} created a new ticket (#ticket-${id})`)
})
// log
// if(config.useEmbeds) {
// const embed = new Discord.RichEmbed()
// .setAuthor(`${client.user.username} / Ticket Log`, client.user.avatarURL)
// .setTitle("New Ticket")
// .addField("Username", message.author.tag, true)
// .addField("Channel", ticketChannel, true)
// .setFooter(`${client.guilds.get(config.guildID).name} : DiscordTickets by Eartharoid`);
// client.channels.get(config.logChannel).send({embed})
// } else {
// client.channels.get(config.logChannel).send(`New ticket created by **${message.author.tag} (${message.author.id})**`);
// }
log.info(`${message.author.tag} created a new ticket (#ticket-${id})`)
// command ends here
},

View File

@ -15,11 +15,11 @@ module.exports = {
// command starts here
message.delete();
const embed = new Discord.RichEmbed()
.setAuthor(`${client.user.username} / Pong!`, client.user.avatarURL)
.setTitle("Pong!")
.setColor(config.colour)
.setTimestamp()
.addField("API Latency", `${Math.round(message.client.ping)}ms`, true)
.setFooter(`${client.guilds.get(config.guildID).name} : DiscordTickets by Eartharoid`);
.setFooter(`DiscordTickets by Eartharoid`);
message.channel.send({embed})

View File

@ -13,6 +13,6 @@
"cooldown": 3,
"ticketImage": true,
"tagHereOnly": false,
"ticketText": "Thanks you for reaching out to our support team.\nA member of staff will come to assist you shortly. Please describe the issue in detail and explain what you have done to resolve the issue so far.\n\n*If you feel that the support you recieve is inadequate, please feel free to submit a formal complaint to a senior member of staff.*",
"ticketText": "Thank you for reaching out to our support team.\nA member of staff will come to assist you shortly. Please describe the issue in detail and explain what you have done to resolve the issue so far.\n\n*If you feel that the support you recieve is inadequate, please feel free to submit a formal complaint to a senior member of staff.*",
"debugLevel": 0
}

View File

@ -2,31 +2,36 @@ const fs = require('fs');
const leeks = require('leeks.js'); // ultra light weight alternative to chalk
const now = new Date();
let date = now.getDate();
const h = now.getHours();
const m = now.getMinutes();
const s = now.getSeconds();
let timestamp = `${h}:${('0' + m).slice(-2)}:${('0' + s).slice(-2)}`;
function time() {
const n = new Date();
const h = n.getHours();
const m = n.getMinutes();
const s = n.getSeconds();
return `${h}:${('0' + m).slice(-2)}:${('0' + s).slice(-2)}`;
}
let d = ('0' + date).slice(-2);
const files = fs.readdirSync('./logs/').filter(file => file.endsWith('.log'));
let path = `./logs/${d}-${timestamp.replace(':', '-').replace(':', '-')}.log`;
let path = `./logs/${d}-${time().replace(':', '-').replace(':', '-')}.log`;
// const log = require(path);
function init(x) {
console.log(leeks.colours.cyan(`[INFO | ${timestamp}] Setting up...`));
console.log(`[INFO | ${timestamp}] Initialising logger`);
console.log(`[INFO | ${timestamp}] Cleaning up...`);
console.log(leeks.colours.cyan(`[INFO | ${time()}] Setting up...`));
console.log(`[INFO | ${time()}] Initialising logger`);
console.log(`[INFO | ${time()}] Cleaning up...`);
for (const file of files) {
if(!file.startsWith(`${d}-`)) {
fs.unlinkSync(`./logs/${file}`)
console.log(`[INFO | ${timestamp}] Deleting ./logs/${file}`);
console.log(`[INFO | ${time()}] Deleting ./logs/${file}`);
};
};
try {
fs.appendFileSync(path, `Discord Tickets | Log File (${timestamp})\n`, function (error) {
fs.appendFileSync(path, `Discord Tickets by Eartharoid | Log File (${d}/${('0' + now.getMonth()).slice(-2)}/${now.getFullYear()}) -->\n`, function (error) {
if (error) throw error;
});
console.log(`[INFO | ${timestamp}] Creating new log file (${path})`);
console.log(`[INFO | ${time()}] Creating new log file (${path})`);
} catch(error) {
console.error(leeks.colours.red(error));
}
@ -37,52 +42,52 @@ exports.init = x => {
};
exports.basic = (m) => {
console.log(`[${timestamp}] ${m}`)
fs.writeFileSync(path, `[${timestamp}] ${m}\n`, function (error) {
console.log(`[${time()}] ${m}`)
fs.writeFileSync(path, `[${time()}] ${m}\n`, function (error) {
if (error) throw error;
});
};
exports.console = (m) => {
console.log(`[INFO | ${timestamp}] ${m}`);
console.log(`[INFO | ${time()}] ${m}`);
let data = fs.readFileSync(path);
fs.writeFileSync(path, data + `[INFO | ${timestamp}] ${m}\n`, function (error) {
fs.writeFileSync(path, data + `[INFO | ${time()}] ${m}\n`, function (error) {
if (error) throw error;
});
};
exports.info = (m) => {
console.info(leeks.colours.cyan(`[INFO | ${timestamp}] ${m}`));
console.info(leeks.colours.cyan(`[INFO | ${time()}] ${m}`));
let data = fs.readFileSync(path);
fs.writeFileSync(path, data + `[INFO | ${timestamp}] ${m}\n`, function (error) {
fs.writeFileSync(path, data + `[INFO | ${time()}] ${m}\n`, function (error) {
if (error) throw error;
});
};
exports.success = (m) => {
console.info(leeks.colours.green(`[INFO | ${timestamp}] ${m}`));
console.info(leeks.colours.green(`[INFO | ${time()}] ${m}`));
let data = fs.readFileSync(path);
fs.writeFileSync(path, data + `[INFO | ${timestamp}] ${m}\n`, function (error) {
fs.writeFileSync(path, data + `[INFO | ${time()}] ${m}\n`, function (error) {
if (error) throw error;
});
};
exports.debug = (m) => {
console.info(leeks.colours.blueBright(`[DEBUG | ${timestamp}] ${m}`));
console.info(leeks.colours.blueBright(`[DEBUG | ${time()}] ${m}`));
let data = fs.readFileSync(path);
fs.writeFileSync(path, data + `[DEBUG | ${timestamp}] ${m}\n`, function (error) {
fs.writeFileSync(path, data + `[DEBUG | ${time()}] ${m}\n`, function (error) {
if (error) throw error;
});
};
exports.warn = (m) => {
console.warn(leeks.colours.yellowBright(`[WARN | ${timestamp}] ${m}`));
console.warn(leeks.colours.yellowBright(`[WARN | ${time()}] ${m}`));
let data = fs.readFileSync(path);
fs.writeFileSync(path, data + `[WARN | ${timestamp}] ${m}\n`, function (error) {
fs.writeFileSync(path, data + `[WARN | ${time()}] ${m}\n`, function (error) {
if (error) throw error;
});
};
exports.error = (m) => {
console.error(leeks.colours.red(`[ERROR | ${timestamp}] ${m}`));
console.error(leeks.colours.red(`[ERROR | ${time()}] ${m}`));
let data = fs.readFileSync(path);
fs.writeFileSync(path, data + `[ERROR | ${timestamp}] ${m}\n`, function (error) {
fs.writeFileSync(path, data + `[ERROR | ${time()}] ${m}\n`, function (error) {
if (error) throw error;
});
};

View File

@ -96,7 +96,7 @@ client.once('ready', () => { // after bot has logged in
.setAuthor(`${client.user.username} / Ticket Log`, client.user.avatarURL)
.setColor("#2ECC71")
.setDescription(":white_check_mark: **Started succesfully**")
.setFooter(`${client.guilds.get(config.guildID).name} : DiscordTickets by Eartharoid`);
.setFooter(`DiscordTickets by Eartharoid`);
client.channels.get(config.logChannel).send(embed)
} else {
client.channels.get(config.logChannel).send(":white_check_mark: **Started succesfully**")
@ -112,7 +112,7 @@ client.once('ready', () => { // after bot has logged in
.setAuthor(`${client.user.username} / Ticket Log`, client.user.avatarURL)
.setColor("#2ECC71")
.setDescription(":white_check_mark: **Required permissions have been granted**")
.setFooter(`${client.guilds.get(config.guildID).name} : DiscordTickets by Eartharoid`);
.setFooter(`DiscordTickets by Eartharoid`);
client.channels.get(config.logChannel).send(embed)
} else {
client.channels.get(config.logChannel).send(":white_check_mark: **Started succesfully**")
@ -125,7 +125,7 @@ client.once('ready', () => { // after bot has logged in
.setAuthor(`${client.user.username} / Ticket Log`, client.user.avatarURL)
.setColor("#E74C3C")
.setDescription(":x: **Required permissions have not been granted**\nPlease give the bot the `ADMINISTRATOR` permission")
.setFooter(`${client.guilds.get(config.guildID).name} : DiscordTickets by Eartharoid`);
.setFooter(`DiscordTickets by Eartharoid`);
client.channels.get(config.logChannel).send({
embed
})
@ -149,7 +149,7 @@ client.on('message', async message => {
.setTitle("DM Logger")
.addField("Username", message.author.tag, true)
.addField("Message", message.content, true)
.setFooter(`${client.guilds.get(config.guildID).name} : DiscordTickets by Eartharoid`);
.setFooter(`DiscordTickets by Eartharoid`);
client.channels.get(config.logChannel).send(embed)
} else {
client.channels.get(config.logChannel).send(`DM received from **${message.author.tag} (${message.author.id})** : \n\n\`\`\`${message.content}\`\`\``);
@ -230,6 +230,19 @@ client.on('message', async message => {
try {
// client.commands.get(command).execute(message, args, config);
command.execute(message, args);
if(config.useEmbeds) {
const embed = new Discord.RichEmbed()
.setAuthor(`${client.user.username} / Command Log`, client.user.avatarURL)
.setTitle("Command Used")
.addField("Username", message.author, true)
.addField("Command", command.name, true)
.setFooter(`DiscordTickets`)
.setTimestamp();
client.channels.get(config.logChannel).send({embed})
} else {
client.channels.get(config.logChannel).send(`**${message.author.tag} (${message.author.id})** used the \`${command.name}\` command`);
}
log.console(`${message.author.tag} used the '${command.name}' command`)
} catch (error) {
log.error(error);
message.channel.send(`:x: **Oof!** An error occured whilst executing that command.\nThe issue has been reported.`);