mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-11-10 06:43:08 +02:00
Ticket creation error handling
This commit is contained in:
parent
10f449fc2d
commit
c9609a41b5
@ -25,7 +25,6 @@ module.exports = class BlacklistCommand extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async execute(message, args) {
|
async execute(message, args) {
|
||||||
|
|
||||||
let settings = await message.guild.settings;
|
let settings = await message.guild.settings;
|
||||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||||
|
|
||||||
@ -101,6 +100,5 @@ module.exports = class BlacklistCommand extends Command {
|
|||||||
|
|
||||||
settings.blacklist = new_blacklist;
|
settings.blacklist = new_blacklist;
|
||||||
await settings.save();
|
await settings.save();
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
@ -25,9 +25,7 @@ module.exports = class CloseCommand extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async execute(message, args) {
|
async execute(message, args) {
|
||||||
|
|
||||||
let settings = await message.guild.settings;
|
let settings = await message.guild.settings;
|
||||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
@ -28,7 +28,6 @@ module.exports = class NewCommand extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async execute(message, args) {
|
async execute(message, args) {
|
||||||
|
|
||||||
let settings = await message.guild.settings;
|
let settings = await message.guild.settings;
|
||||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||||
|
|
||||||
@ -76,6 +75,7 @@ module.exports = class NewCommand extends Command {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
try {
|
||||||
let t_row = await this.client.tickets.create(message.guild.id, message.author.id, cat_row.id, args);
|
let t_row = await this.client.tickets.create(message.guild.id, message.author.id, cat_row.id, args);
|
||||||
response = await editOrSend(response,
|
response = await editOrSend(response,
|
||||||
new MessageEmbed()
|
new MessageEmbed()
|
||||||
@ -85,6 +85,16 @@ module.exports = class NewCommand extends Command {
|
|||||||
.setDescription(i18n('commands.new.response.created.description', `<#${t_row.id}>`))
|
.setDescription(i18n('commands.new.response.created.description', `<#${t_row.id}>`))
|
||||||
.setFooter(footer(settings.footer, i18n('message_will_be_deleted_in', 15)), message.guild.iconURL())
|
.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 () => {
|
setTimeout(async () => {
|
||||||
@ -169,6 +179,5 @@ module.exports = class NewCommand extends Command {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -55,7 +55,6 @@ module.exports = class PanelCommand extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async execute(message, args) {
|
async execute(message, args) {
|
||||||
|
|
||||||
const arg_title = this.args[0].name;
|
const arg_title = this.args[0].name;
|
||||||
const arg_description = this.args[1].name;
|
const arg_description = this.args[1].name;
|
||||||
const arg_emoji = this.args[2].name;
|
const arg_emoji = this.args[2].name;
|
||||||
@ -66,6 +65,7 @@ module.exports = class PanelCommand extends Command {
|
|||||||
|
|
||||||
console.log(args)
|
console.log(args)
|
||||||
message.channel.send(Object.keys(args).map(arg => `${arg}: \`${args[arg]}\``).join('\n'))
|
message.channel.send(Object.keys(args).map(arg => `${arg}: \`${args[arg]}\``).join('\n'))
|
||||||
|
console.log(args.category)
|
||||||
|
|
||||||
if (!args[arg_emoji]) {
|
if (!args[arg_emoji]) {
|
||||||
// reaction-less panel
|
// reaction-less panel
|
||||||
@ -80,6 +80,5 @@ module.exports = class PanelCommand extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
@ -17,7 +17,6 @@ module.exports = class SettingsCommand extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async execute(message) {
|
async execute(message) {
|
||||||
|
|
||||||
let settings = await message.guild.settings;
|
let settings = await message.guild.settings;
|
||||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||||
|
|
||||||
|
@ -23,9 +23,7 @@ module.exports = class TransferCommand extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async execute(message, args) {
|
async execute(message, args) {
|
||||||
|
|
||||||
let settings = await message.guild.settings;
|
let settings = await message.guild.settings;
|
||||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
@ -169,7 +169,7 @@
|
|||||||
"emoji": {
|
"emoji": {
|
||||||
"alias": "e",
|
"alias": "e",
|
||||||
"description": "A **unicode** emoji character (escaped emoji)",
|
"description": "A **unicode** emoji character (escaped emoji)",
|
||||||
"example": "\\:ticket:",
|
"example": "🎫",
|
||||||
"name": "emoji"
|
"name": "emoji"
|
||||||
},
|
},
|
||||||
"title": {
|
"title": {
|
||||||
|
@ -157,6 +157,11 @@ module.exports = class TicketManager extends EventEmitter {
|
|||||||
if (!cat_row)
|
if (!cat_row)
|
||||||
throw new Error('Ticket category does not exist');
|
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({
|
let number = (await this.client.db.models.Ticket.count({
|
||||||
where: {
|
where: {
|
||||||
guild: guild_id
|
guild: guild_id
|
||||||
|
Loading…
Reference in New Issue
Block a user