Skip to content

Commit

Permalink
feat(api): reorderable categories in panels
Browse files Browse the repository at this point in the history
  • Loading branch information
eartharoid committed Jan 14, 2025
1 parent 0b06e18 commit 5ffd189
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/routes/api/admin/guilds/[guild]/panels.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ module.exports.post = fastify => ({
where: { id: guild.id },
});
const getMessage = client.i18n.getLocale(settings.locale);
const categories = settings.categories.filter(c => data.categories.includes(c.id));
const categories = data.categories.map(id => {
const category = settings.categories.find(c => c.id === id);
if (!category) throw new Error(`Invalid category: ${id}`);
return category;
});
if (categories.length === 0) throw new Error('No categories');
if (categories.length !== 1 && data.type === 'MESSAGE') throw new Error('Invalid number of categories for panel type');

Expand Down

0 comments on commit 5ffd189

Please sign in to comment.