egirlskey/src/server/api/endpoints/admin/emoji/remove.ts
syuilo 2756f553c6
Improve error handling of API (#4345)
* wip

* wip

* wip

* Update attached_notes.ts

* wip

* Refactor

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Update call.ts

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* ✌️

* Fix
2019-02-22 11:46:58 +09:00

31 lines
567 B
TypeScript

import $ from 'cafy';
import Emoji from '../../../../../models/emoji';
import define from '../../../define';
import ID from '../../../../../misc/cafy-id';
export const meta = {
desc: {
'ja-JP': 'カスタム絵文字を削除します。'
},
requireCredential: true,
requireModerator: true,
params: {
id: {
validator: $.type(ID)
}
}
};
export default define(meta, async (ps) => {
const emoji = await Emoji.findOne({
_id: ps.id
});
if (emoji == null) throw new Error('emoji not found');
await Emoji.remove({ _id: emoji._id });
return;
});