mirror of
https://github.com/spacebarchat/server.git
synced 2026-08-28 11:44:07 +00:00
Throw proper error when emoji isnt found
This commit is contained in:
@@ -74,11 +74,13 @@ router.get(
|
||||
if (!app) throw DiscordApiErrors.UNKNOWN_APPLICATION;
|
||||
if (req.user_id != app?.id && req.user_id != app?.owner_id) throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION;
|
||||
|
||||
const emoji = await Emoji.findOneOrFail({
|
||||
const emoji = await Emoji.findOne({
|
||||
where: { application_id: application_id, id: emoji_id },
|
||||
relations: { user: true },
|
||||
});
|
||||
|
||||
if (!emoji) throw DiscordApiErrors.UNKNOWN_EMOJI;
|
||||
|
||||
return res.json(emoji);
|
||||
},
|
||||
);
|
||||
@@ -160,9 +162,10 @@ router.patch(
|
||||
|
||||
if (body.name?.includes("-")) body.name = body.name?.replaceAll("-", ""); // Dashes are invalid apparently
|
||||
|
||||
await Emoji.findOneOrFail({
|
||||
const oldEmoji = await Emoji.findOne({
|
||||
where: { id: emoji_id, application_id: application_id },
|
||||
});
|
||||
if (!oldEmoji) throw DiscordApiErrors.UNKNOWN_EMOJI;
|
||||
|
||||
const emoji = await Emoji.create({
|
||||
...body,
|
||||
@@ -191,6 +194,8 @@ router.delete(
|
||||
if (!app) throw DiscordApiErrors.UNKNOWN_APPLICATION;
|
||||
if (req.user_id != app?.id && req.user_id != app?.owner_id) throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION;
|
||||
|
||||
if (!(await Emoji.existsBy({ id: emoji_id, application_id }))) throw DiscordApiErrors.UNKNOWN_EMOJI;
|
||||
|
||||
await Emoji.delete({
|
||||
id: emoji_id,
|
||||
application_id: application_id,
|
||||
|
||||
Reference in New Issue
Block a user