This commit is contained in:
David Ralph
2020-08-03 16:39:39 +01:00
parent 606d87d24e
commit 2964d1b9a6
8 changed files with 107 additions and 154 deletions

View File

@@ -1,6 +1,7 @@
const Discord = require('discord.js');
const config = require('../config.json');
const log = require(`leekslazylogger`);
module.exports = {
name: 'add',
description: 'Add a member to a ticket channel',
@@ -14,23 +15,23 @@ module.exports = {
const client = message.client;
// command starts here
message.delete();
if(!message.channel.name.startsWith('ticket-')) {
if(config.useEmbeds) {
if (!message.channel.name.startsWith('ticket-')) {
if (config.useEmbeds) {
const notTicket = new Discord.RichEmbed()
.setColor("#E74C3C")
.setDescription(`:x: **This command can only be used within a ticket channel**`)
.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**`)
return message.channel.send(`:x: **This command can only be used within a ticket channel**`);
}
}
let user = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
if(!user) {
if(config.useEmbeds) {
if (!user) {
if (config.useEmbeds) {
const err1 = new Discord.RichEmbed()
.setColor("#E74C3C")
.setDescription(`:x: **Unknown user.** Please mention a valid user.`)
.setDescription(`:x: **Unknown user.** Please mention a valid user.`);
return message.channel.send(err1);
} else {
return message.channel.send(`:x: **Unknown user.** Please mention a valid user.`);
@@ -45,13 +46,13 @@ module.exports = {
if(config.useEmbeds) {
const added = new Discord.RichEmbed()
.setColor(config.colour)
.setDescription(`${user} has been added.`)
.setDescription(`${user} has been added.`);
message.channel.send(added);
} else {
message.channel.send(`${user} has been added.`);
}
// log
if(config.useEmbeds) {
if (config.useEmbeds) {
const embed = new Discord.RichEmbed()
.setAuthor(`${client.user.username} / Ticket Log`, client.user.avatarURL)
.setTitle("User Added")
@@ -61,15 +62,14 @@ module.exports = {
.addField("Channel", message.channel, true)
.setFooter(`DiscordTickets`)
.setTimestamp();
client.channels.get(config.logChannel).send({embed})
client.channels.get(config.logChannel).send(embed);
} else {
client.channels.get(config.logChannel).send(`User added to a ticket by **${message.author.tag} (${message.author.id})**`);
}
log.info(`${message.author.tag} added a user to a ticket (#${message.channel})`)
} catch(error) {
} catch (error) {
log.error(error);
}
// command ends here
},
};

View File

@@ -1,6 +1,7 @@
const Discord = require('discord.js');
const config = require('../config.json');
const log = require(`leekslazylogger`);
module.exports = {
name: 'close',
description: 'Close a ticket',
@@ -18,16 +19,16 @@ module.exports = {
if(config.useEmbeds) {
const notTicket = new Discord.RichEmbed()
.setColor("#E74C3C")
.setDescription(`:x: **This command can only be used within a ticket channel**`)
.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**`)
return message.channel.send(`:x: **This command can only be used within a ticket channel**`);
}
} else {
try {
message.channel.delete()
message.channel.delete();
// log
if(config.useEmbeds) {
if (config.useEmbeds) {
const embed = new Discord.RichEmbed()
.setAuthor(`${client.user.username} / Ticket Log`, client.user.avatarURL)
.setTitle("Ticket Closed")
@@ -36,20 +37,15 @@ module.exports = {
.addField("Channel", message.channel.name, true)
.setFooter(`DiscordTickets`)
.setTimestamp();
client.channels.get(config.logChannel).send({embed})
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) {
log.info(`${message.author.tag} closed a ticket (#${message.channel.name})`);
} catch (error) {
log.error(log.colour.red(error));
}
}
// command ends here
},
};

View File

@@ -7,22 +7,15 @@ module.exports = {
description: 'Displays help menu',
usage: '[command]',
aliases: ['command', 'commands'],
example: 'help new',
example: 'help new',
args: false,
cooldown: config.cooldown,
guildOnly: true,
guildOnly: true,
execute(message, args) {
const client = message.client;
// command starts here
message.delete();
const data = [];
const { commands } = message.client;
const data = [];
const { commands } = message.client;
if (config.useEmbeds) {
if (!args.length) {
@@ -31,16 +24,16 @@ module.exports = {
data.push(`\nType \`${config.prefix}help [command]\` for more information about a specific command.`);
const embed = new Discord.RichEmbed()
.setTitle("Commands")
.setColor(config.colour)
.setDescription(`\nType \`${config.prefix}help [command]\` for more information about a specific command.`)
// .addField("...", `...`, true)
// .addField("...", `...`, true)
.setFooter(`DiscordTickets by Eartharoid`);
.setTitle("Commands")
.setColor(config.colour)
.setDescription(`\nType \`${config.prefix}help [command]\` for more information about a specific command.`)
// .addField("...", `...`, true)
// .addField("...", `...`, true)
.setFooter(`DiscordTickets by Eartharoid`);
var cmds = [];
cmds.push(commands.map(command => embed.addField(`${config.prefix}${command.name}`, `\`${command.description}\``)));
message.channel.send(embed)
let cmds = [];
cmds.push(commands.map(command => embed.addField(`${config.prefix}${command.name}`, `\`${command.description}\``)));
message.channel.send(embed)
.then(() => {
if (message.channel.type === 'dm') return;
// message.channel.send(`A list of commands has been sent to you.`);
@@ -57,28 +50,25 @@ module.exports = {
if (!command) {
const notCmd = new Discord.RichEmbed()
.setColor("#E74C3C")
.setDescription(`:x: **Invalid command name** (\`${config.prefix}help\`)`)
return message.channel.send(notCmd)
.setColor("#E74C3C")
.setDescription(`:x: **Invalid command name** (\`${config.prefix}help\`)`);
return message.channel.send(notCmd);
}
const cmd = new Discord.RichEmbed()
.setColor(config.colour)
.addField(`Command`,`\`${command.name}\``, true)
.setFooter(`DiscordTickets by Eartharoid`);
.setColor(config.colour)
.addField(`Command`,`\`${command.name}\``, true)
.setFooter(`DiscordTickets by Eartharoid`);
if (command.aliases) cmd.addField("Aliases", `\`${command.aliases.join(', ')}\``, true);
if (command.description) cmd.addField("Description", `\`${command.description}\``, false);
if (command.usage) cmd.addField("Usage", `\`${config.prefix}${command.name} ${command.usage}\``, false)
if (command.example) cmd.addField("Example", `\`${config.prefix}${command.example}\``, false);
message.channel.send(cmd)
message.channel.send(cmd);
}
} else {
// message.channel.send(`**Prefix =** \`${config.prefix}\`\n**Bot Version =** \`${version}\``)
if (!args.length) {
data.push('__**Commands**__');
data.push(commands.map(command => `**${config.prefix}${command.name}** : \`${command.description}\``).join('\n'));
@@ -100,9 +90,7 @@ module.exports = {
const name = args[0].toLowerCase();
const command = commands.get(name) || commands.find(c => c.aliases && c.aliases.includes(name));
if (!command) {
return message.reply(':x: **Invalid command**');
}
if (!command) return message.reply(':x: **Invalid command**');
data.push(`**Command:** \`${command.name}\``);
@@ -113,11 +101,8 @@ module.exports = {
data.push(`**Cooldown:** \`${command.cooldown || 3} second(s)\``);
message.channel.send(data, { split: true });
message.channel.send(data, { split: true });
}
// command ends here
},
};

View File

@@ -2,6 +2,7 @@ const Discord = require('discord.js');
const config = require('../config.json');
const log = require(`leekslazylogger`);
// const randomString = require('random-string');
module.exports = {
name: 'new',
description: 'Create a new ticket',
@@ -30,12 +31,11 @@ module.exports = {
if (config.useEmbeds) {
const err1 = new Discord.RichEmbed()
.setColor("#E74C3C")
.setDescription(`:x: You already have an open ticket.`)
return message.channel.send(err1)
.setDescription(`:x: You already have an open ticket.`);
return message.channel.send(err1);
} else {
message.channel.send(`:x: You already have an open ticket.`)
message.channel.send(`:x: You already have an open ticket.`);
}
};
message.guild.createChannel(`ticket-${id}`, {
@@ -46,7 +46,6 @@ module.exports = {
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
@@ -80,20 +79,18 @@ module.exports = {
.setTimestamp();
const welcome = new Discord.RichEmbed()
.setColor(config.colour)
.setDescription(`**Ticket topic:** \`${topic}\`\n\n${config.ticketText}`)
.setDescription(`**Ticket topic:** \`${topic}\`\n\n${config.ticketText}`);
if (config.useEmbeds) {
message.channel.send(created)
let w = await c.send(welcome)
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()
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) {
@@ -106,19 +103,12 @@ module.exports = {
.addField("Channel", c, true)
.setFooter(`DiscordTickets`)
.setTimestamp();
client.channels.get(config.logChannel).send({
embed
})
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.info(`${message.author.tag} created a new ticket (#ticket-${id})`);
});
// command ends here
},
};
};

View File

@@ -1,6 +1,6 @@
const Discord = require('discord.js');
const config = require('../config.json');
const log = require(`leekslazylogger`);
module.exports = {
name: 'ping',
description: 'Calculate latency',
@@ -11,7 +11,6 @@ module.exports = {
cooldown: config.cooldown,
guildOnly: true,
execute(message, args) {
const client = message.client;
// command starts here
message.delete();
const embed = new Discord.RichEmbed()
@@ -19,11 +18,7 @@ module.exports = {
.setColor(config.colour)
.setTimestamp()
.addField("API Latency", `${Math.round(message.client.ping)}ms`, true)
message.channel.send({embed})
message.channel.send(embed);
// command ends here
},
};
};

View File

@@ -1,6 +1,7 @@
const Discord = require('discord.js');
const config = require('../config.json');
const log = require(`leekslazylogger`);
module.exports = {
name: 'remove',
description: 'Remove a member from a ticket',
@@ -14,8 +15,8 @@ module.exports = {
const client = message.client;
// command starts here
message.delete();
if(!message.channel.name.startsWith('ticket-')) {
if(config.useEmbeds) {
if (!message.channel.name.startsWith('ticket-')) {
if (config.useEmbeds) {
const notTicket = new Discord.RichEmbed()
.setColor("#E74C3C")
.setDescription(`:x: **This command can only be used within a ticket channel**`)
@@ -26,8 +27,8 @@ module.exports = {
}
let user = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
if(!user) {
if(config.useEmbeds) {
if (!user) {
if (config.useEmbeds) {
const err1 = new Discord.RichEmbed()
.setColor("#E74C3C")
.setDescription(`:x: **Unknown user.** Please mention a valid user.`)
@@ -41,7 +42,7 @@ module.exports = {
SEND_MESSAGES: false,
READ_MESSAGES: false
});
if(config.useEmbeds) {
if (config.useEmbeds) {
const removed = new Discord.RichEmbed()
.setColor(config.colour)
.setDescription(`${user} has been removed.`)
@@ -50,7 +51,7 @@ module.exports = {
message.channel.send(`${user} has been removed.`);
}
// log
if(config.useEmbeds) {
if (config.useEmbeds) {
const embed = new Discord.RichEmbed()
.setAuthor(`${client.user.username} / Ticket Log`, client.user.avatarURL)
.setTitle("User Removed")
@@ -60,7 +61,8 @@ module.exports = {
.addField("Channel", message.channel, true)
.setFooter(`DiscordTickets`)
.setTimestamp();
client.channels.get(config.logChannel).send({embed})
client.channels.get(config.logChannel).send(embed);
} else {
client.channels.get(config.logChannel).send(`User removed to a ticket by **${message.author.tag} (${message.author.id})**`);
}