mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-12-23 08:13:09 +02:00
Fixed and tested issues pointed out by @Eartharoid
This commit is contained in:
parent
c12d5ba047
commit
d725324053
@ -22,7 +22,7 @@ module.exports = {
|
|||||||
aliases: ['ca'],
|
aliases: ['ca'],
|
||||||
example: 'closeall',
|
example: 'closeall',
|
||||||
args: false,
|
args: false,
|
||||||
disabled: !config.commands.new.enabled,
|
disabled: !config.commands.closeall.enabled,
|
||||||
async execute(client, message, args, {
|
async execute(client, message, args, {
|
||||||
config,
|
config,
|
||||||
Ticket
|
Ticket
|
||||||
@ -41,13 +41,13 @@ module.exports = {
|
|||||||
.setFooter(guild.name, guild.iconURL())
|
.setFooter(guild.name, guild.iconURL())
|
||||||
);
|
);
|
||||||
|
|
||||||
let tickets = await Ticket.findAll({
|
let tickets = await Ticket.findAndCountAll({
|
||||||
where: {
|
where: {
|
||||||
open: true,
|
open: true,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (tickets.length == 0)
|
if (tickets.count === 0)
|
||||||
return message.channel.send(
|
return message.channel.send(
|
||||||
new MessageEmbed()
|
new MessageEmbed()
|
||||||
.setColor(config.err_colour)
|
.setColor(config.err_colour)
|
||||||
@ -57,17 +57,19 @@ module.exports = {
|
|||||||
.setFooter(guild.name, guild.iconURL())
|
.setFooter(guild.name, guild.iconURL())
|
||||||
);
|
);
|
||||||
|
|
||||||
log.info(`Found ${tickets.length} open tickets`);
|
log.info(`Found ${tickets.count} open tickets`);
|
||||||
|
|
||||||
if (config.commands.close.confirmation) {
|
if (config.commands.close.confirmation) {
|
||||||
let success;
|
let success;
|
||||||
let pre = `Transcript versions may be available using the \`${config.prefix}\``;
|
let pre = config.transcripts.text.enabled || config.transcripts.web.enabled
|
||||||
|
? `You will be able to view an archived version of each ticket later with \`${config.prefix}transcript <id>\``
|
||||||
|
: '';
|
||||||
|
|
||||||
let confirm = await message.channel.send(
|
let confirm = await message.channel.send(
|
||||||
new MessageEmbed()
|
new MessageEmbed()
|
||||||
.setColor(config.colour)
|
.setColor(config.colour)
|
||||||
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
||||||
.setTitle('❔ Are you sure?')
|
.setTitle(`❔ Are you sure you want to close **${tickets.count}** tickets?`)
|
||||||
.setDescription(`${pre}\n**React with ✅ to confirm.**`)
|
.setDescription(`${pre}\n**React with ✅ to confirm.**`)
|
||||||
.setFooter(guild.name + ' | Expires in 15 seconds', guild.iconURL())
|
.setFooter(guild.name + ' | Expires in 15 seconds', guild.iconURL())
|
||||||
);
|
);
|
||||||
@ -84,8 +86,8 @@ module.exports = {
|
|||||||
new MessageEmbed()
|
new MessageEmbed()
|
||||||
.setColor(config.colour)
|
.setColor(config.colour)
|
||||||
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
||||||
.setTitle(`**\`${tickets.length}\` tickets closed**`)
|
.setTitle(`**\`${tickets.count}\` tickets closed**`)
|
||||||
.setDescription(`**\`${tickets.length}\`** tickets closed by ${message.author}`)
|
.setDescription(`**\`${tickets.count}\`** tickets closed by ${message.author}`)
|
||||||
.setFooter(guild.name, guild.iconURL())
|
.setFooter(guild.name, guild.iconURL())
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -94,7 +96,7 @@ module.exports = {
|
|||||||
new MessageEmbed()
|
new MessageEmbed()
|
||||||
.setColor(config.colour)
|
.setColor(config.colour)
|
||||||
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
||||||
.setTitle(`✅ ** \`${tickets.length}\` tickets closed**`)
|
.setTitle(`✅ ** \`${tickets.count}\` tickets closed**`)
|
||||||
.setDescription('The channels will be automatically deleted in a few seconds, once the contents have been archived.')
|
.setDescription('The channels will be automatically deleted in a few seconds, once the contents have been archived.')
|
||||||
.setFooter(guild.name, guild.iconURL())
|
.setFooter(guild.name, guild.iconURL())
|
||||||
);
|
);
|
||||||
@ -127,13 +129,12 @@ module.exports = {
|
|||||||
closeAll();
|
closeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async function closeAll() {
|
async function closeAll() {
|
||||||
|
tickets.rows.forEach(async ticket => {
|
||||||
let users = [];
|
let users = [];
|
||||||
|
|
||||||
if (config.transcripts.text.enabled || config.transcripts.web.enabled) {
|
if (config.transcripts.text.enabled || config.transcripts.web.enabled) {
|
||||||
|
|
||||||
// LOOP START
|
|
||||||
tickets.forEach(async ticket => {
|
|
||||||
let {
|
let {
|
||||||
channel,
|
channel,
|
||||||
id,
|
id,
|
||||||
@ -159,7 +160,7 @@ module.exports = {
|
|||||||
const embed = new MessageEmbed()
|
const embed = new MessageEmbed()
|
||||||
.setColor(config.colour)
|
.setColor(config.colour)
|
||||||
.setAuthor(message.author.username)
|
.setAuthor(message.author.username)
|
||||||
.setTitle(`${tickets.length} tickets`)
|
.setTitle(`Ticket ${id}`)
|
||||||
.setFooter(guild.name, guild.iconURL());
|
.setFooter(guild.name, guild.iconURL());
|
||||||
|
|
||||||
if (fs.existsSync(paths.text)) {
|
if (fs.existsSync(paths.text)) {
|
||||||
@ -201,13 +202,12 @@ module.exports = {
|
|||||||
.then(o => log.info(`Deleted channel with name: '#${o.name}' <${o.id}>`))
|
.then(o => log.info(`Deleted channel with name: '#${o.name}' <${o.id}>`))
|
||||||
.catch(e => log.error(e)))
|
.catch(e => log.error(e)))
|
||||||
.catch(e => log.error(e));
|
.catch(e => log.error(e));
|
||||||
});
|
|
||||||
|
|
||||||
if (config.logs.discord.enabled) {
|
if (config.logs.discord.enabled) {
|
||||||
let embed = new MessageEmbed()
|
let embed = new MessageEmbed()
|
||||||
.setColor(config.colour)
|
.setColor(config.colour)
|
||||||
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
||||||
.setTitle(`${tickets.length} ticket${tickets.length > 1 ? 's' : ''} closed (${config.prefix}closeall)`)
|
.setTitle(`${tickets.count} ticket${tickets.count > 1 ? 's' : ''} closed (${config.prefix}closeall)`)
|
||||||
.addField('Closed by', message.author, true)
|
.addField('Closed by', message.author, true)
|
||||||
.setFooter(guild.name, guild.iconURL())
|
.setFooter(guild.name, guild.iconURL())
|
||||||
.setTimestamp();
|
.setTimestamp();
|
||||||
@ -218,6 +218,7 @@ module.exports = {
|
|||||||
client.channels.cache.get(config.logs.discord.channel).send(embed);
|
client.channels.cache.get(config.logs.discord.channel).send(embed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user