From 524ebaa7677cd226a7f3f7f15cd4039977ed9b8c Mon Sep 17 00:00:00 2001 From: Eartharoid Date: Sat, 4 May 2019 22:37:20 +0100 Subject: [PATCH] upload --- commands/help.js | 2 -- commands/new.js | 58 ++++++++++++++++++++++++++++++++++++++++-------- index.js | 11 +-------- 3 files changed, 50 insertions(+), 21 deletions(-) diff --git a/commands/help.js b/commands/help.js index 8d23731..db19bcc 100644 --- a/commands/help.js +++ b/commands/help.js @@ -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) } diff --git a/commands/new.js b/commands/new.js index 509b4d5..3ef20b7 100644 --- a/commands/new.js +++ b/commands/new.js @@ -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', @@ -11,20 +11,60 @@ module.exports = { args: true, cooldown: config.cooldown, guildOnly: true, - execute(message, args) { + execute(message, args) { const client = message.client; // command starts here message.delete(); 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 }, diff --git a/index.js b/index.js index f95c480..3f626ad 100644 --- a/index.js +++ b/index.js @@ -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)`);