Ticket creation error handling

This commit is contained in:
Isaac 2021-05-11 11:52:23 +01:00
parent 10f449fc2d
commit c9609a41b5
No known key found for this signature in database
GPG Key ID: F6812DBC6719B4E3
8 changed files with 28 additions and 22 deletions

View File

@ -25,7 +25,6 @@ module.exports = class BlacklistCommand extends Command {
}
async execute(message, args) {
let settings = await message.guild.settings;
const i18n = this.client.i18n.getLocale(settings.locale);
@ -101,6 +100,5 @@ module.exports = class BlacklistCommand extends Command {
settings.blacklist = new_blacklist;
await settings.save();
}
};

View File

@ -25,9 +25,7 @@ module.exports = class CloseCommand extends Command {
}
async execute(message, args) {
let settings = await message.guild.settings;
const i18n = this.client.i18n.getLocale(settings.locale);
}
};

View File

@ -28,7 +28,6 @@ module.exports = class NewCommand extends Command {
}
async execute(message, args) {
let settings = await message.guild.settings;
const i18n = this.client.i18n.getLocale(settings.locale);
@ -76,15 +75,26 @@ module.exports = class NewCommand extends Command {
);
}
} else {
let t_row = await this.client.tickets.create(message.guild.id, message.author.id, cat_row.id, args);
response = await editOrSend(response,
new MessageEmbed()
.setColor(settings.success_colour)
.setAuthor(message.author.username, message.author.displayAvatarURL())
.setTitle(i18n('commands.new.response.created.title'))
.setDescription(i18n('commands.new.response.created.description', `<#${t_row.id}>`))
.setFooter(footer(settings.footer, i18n('message_will_be_deleted_in', 15)), message.guild.iconURL())
);
try {
let t_row = await this.client.tickets.create(message.guild.id, message.author.id, cat_row.id, args);
response = await editOrSend(response,
new MessageEmbed()
.setColor(settings.success_colour)
.setAuthor(message.author.username, message.author.displayAvatarURL())
.setTitle(i18n('commands.new.response.created.title'))
.setDescription(i18n('commands.new.response.created.description', `<#${t_row.id}>`))
.setFooter(footer(settings.footer, i18n('message_will_be_deleted_in', 15)), message.guild.iconURL())
);
} catch (error) {
response = await editOrSend(response,
new MessageEmbed()
.setColor(settings.error_colour)
.setAuthor(message.author.username, message.author.displayAvatarURL())
.setTitle(i18n('commands.new.response.error.title'))
.setDescription(error.message)
.setFooter(footer(settings.footer, i18n('message_will_be_deleted_in', 15)), message.guild.iconURL())
);
}
}
setTimeout(async () => {
@ -169,6 +179,5 @@ module.exports = class NewCommand extends Command {
}
});
}
}
};

View File

@ -55,7 +55,6 @@ module.exports = class PanelCommand extends Command {
}
async execute(message, args) {
const arg_title = this.args[0].name;
const arg_description = this.args[1].name;
const arg_emoji = this.args[2].name;
@ -66,6 +65,7 @@ module.exports = class PanelCommand extends Command {
console.log(args)
message.channel.send(Object.keys(args).map(arg => `${arg}: \`${args[arg]}\``).join('\n'))
console.log(args.category)
if (!args[arg_emoji]) {
// reaction-less panel
@ -80,6 +80,5 @@ module.exports = class PanelCommand extends Command {
}
}
}
}
};

View File

@ -17,7 +17,6 @@ module.exports = class SettingsCommand extends Command {
}
async execute(message) {
let settings = await message.guild.settings;
const i18n = this.client.i18n.getLocale(settings.locale);

View File

@ -23,9 +23,7 @@ module.exports = class TransferCommand extends Command {
}
async execute(message, args) {
let settings = await message.guild.settings;
const i18n = this.client.i18n.getLocale(settings.locale);
}
};

View File

@ -169,7 +169,7 @@
"emoji": {
"alias": "e",
"description": "A **unicode** emoji character (escaped emoji)",
"example": "\\:ticket:",
"example": "🎫",
"name": "emoji"
},
"title": {

View File

@ -157,6 +157,11 @@ module.exports = class TicketManager extends EventEmitter {
if (!cat_row)
throw new Error('Ticket category does not exist');
let cat_channel = await this.client.channels.fetch(category_id);
if (cat_channel.children.size >= 50)
throw new Error('Ticket category has reached child channel limit (50)');
let number = (await this.client.db.models.Ticket.count({
where: {
guild: guild_id