This commit is contained in:
Eartharoid 2019-05-04 22:37:20 +01:00
parent adc1b002e7
commit 524ebaa767
3 changed files with 50 additions and 21 deletions

View File

@ -57,10 +57,8 @@ module.exports = {
if (!command) {
const notCmd = new Discord.RichEmbed()
.setAuthor(`${client.user.username}`, client.user.avatarURL)
.setColor("#E74C3C")
.setDescription(`:x: **Invalid command name** (\`${config.prefix}help\`)`)
.setFooter(`${client.guilds.get(config.guildID).name} : DiscordTickets by Eartharoid`);
return message.channel.send(notCmd)
}

View File

@ -1,7 +1,7 @@
const Discord = require('discord.js');
const config = require('../config.json');
const leeks = require('leeks.js');
const randomString = require('random-string');
// const randomString = require('random-string');
module.exports = {
name: 'new',
description: 'Create a new ticket',
@ -18,13 +18,53 @@ module.exports = {
const ticketChannel = "channel";
let topic = args.join(" ");
// let num = randomString({
// length: 4,
// numeric: true,
// letters: false,
// special: false,
// });
let id = message.author.id.toString().substr(0,4) + message.author.discriminator;
let num = randomString({
length: 4,
numeric: true,
letters: false,
special: false,
});
// if(message.guild.channels.some(channel => `ticket-${id}`)) {
if(message.guild.channels.some(includes(`ticket-${id}`))) {
const err1 = new Discord.RichEmbed()
.setColor("#E74C3C")
.setDescription(`:x: You already have a ticket open.`)
return message.channel.send(err1)
};
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.");
// 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)
})
// log
@ -39,7 +79,7 @@ module.exports = {
// } else {
// client.channels.get(config.logChannel).send(`New ticket created by **${message.author.tag} (${message.author.id})**`);
// }
console.log(leeks.colors.cyan(`${message.author.tag} created a new ticket (#ticket-${num})`))
console.log(leeks.colors.cyan(`${message.author.tag} created a new ticket (#ticket-${id})`))
// command ends here
},

View File

@ -84,12 +84,7 @@ client.once('ready', () => { // after bot has logged in
}
console.log(leeks.colors.green(`Connected to Discord API`))
console.log(leeks.colors.green(`Logged in as ${client.user.tag}`))
client.user.setPresence({
game: {
name: config.playing
},
status: 'online'
})
client.user.setPresence({game: {name: config.playing, type: config.activityType},status: config.status})
// .then(console.log)
.catch(console.error);
// console.log(leeks.colors.green(`Set playing status as `) + leeks.colors.yellow(`'${config.playing}${config.prefix}help'`));
@ -199,10 +194,8 @@ client.on('message', async message => {
// return message.channel.send(reply);
if (config.useEmbeds) {
const embed = new Discord.RichEmbed()
.setAuthor(`${client.user.username}`, client.user.avatarURL)
.setColor("#E74C3C")
.setDescription(`\n**Usage:** \`${config.prefix}${command.name} ${command.usage}\`\nType \`${config.prefix}help ${command.name}\` for more information`)
.setFooter(`${client.guilds.get(config.guildID).name} : DiscordTickets by Eartharoid`);
return message.channel.send({embed})
} else {
@ -225,10 +218,8 @@ client.on('message', async message => {
const timeLeft = (expirationTime - now) / 1000;
if (config.useEmbeds) {
const embed = new Discord.RichEmbed()
.setAuthor(`${client.user.username}`, client.user.avatarURL)
.setColor("#E74C3C")
.setDescription(`:x: **Please do not spam commands** (wait ${timeLeft.toFixed(1)}s)`)
.setFooter(`${client.guilds.get(config.guildID).name} : DiscordTickets by Eartharoid`);
return message.channel.send({embed})
} else {
return message.reply(`please do not spam commands (wait ${timeLeft.toFixed(1)}s)`);