DiscordTickets/commands/new.js

46 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-05-04 14:20:26 +03:00
const Discord = require('discord.js');
const config = require('../config.json');
2019-05-04 18:09:05 +03:00
const randomString = require('random-string');
2019-05-04 00:09:48 +03:00
module.exports = {
name: 'new',
description: 'Create a new ticket',
2019-05-04 01:54:28 +03:00
usage: '<brief description>',
aliases: ['ticket'],
2019-05-04 14:20:26 +03:00
example: 'new I found an error',
2019-05-04 01:54:28 +03:00
args: true,
2019-05-04 14:20:26 +03:00
cooldown: config.cooldown,
2019-05-04 18:09:05 +03:00
guildOnly: true,
2019-05-04 02:01:33 +03:00
execute(message, args) {
2019-05-04 14:23:27 +03:00
const client = message.client;
2019-05-04 00:09:48 +03:00
// command starts here
message.delete();
const ticketChannel = "channel";
2019-05-04 18:09:05 +03:00
let topic = args.join(" ");
function num(){
return randomString({
length: 4,
numeric: true,
letters: false,
special: false,
})
};
2019-05-04 00:09:48 +03:00
// 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)
2019-05-04 00:52:55 +03:00
.setFooter(`${client.guilds.get(config.guildID).name} : DiscordTickets by Eartharoid`);
2019-05-04 00:09:48 +03:00
client.channels.get(config.logChannel).send({embed})
} else {
client.channels.get(config.logChannel).send(`New ticket created by **${message.author.tag} (${message.author.id})**`);
}
// command ends here
},
};