This commit is contained in:
FineArchs 2024-10-11 14:55:57 +09:00
parent f965b35a2c
commit 70bb365cd1
2 changed files with 6 additions and 6 deletions

View File

@ -115,20 +115,20 @@ export class CustomEmojiService implements OnApplicationShutdown {
roleIdsThatCanBeUsedThisEmojiAsReaction?: MiRole['id'][];
}, moderator?: MiUser): Promise<
void
| "NO_SUCH_EMOJI"
| "SAME_NAME_EMOJI_EXISTS"
| 'NO_SUCH_EMOJI'
| 'SAME_NAME_EMOJI_EXISTS'
> {
const emoji = data.id
? await this.getEmojiById(data.id)
: await this.getEmojiByName(data.name!);
if (emoji === null) return "NO_SUCH_EMOJI";
if (emoji === null) return 'NO_SUCH_EMOJI';
const id = emoji.id;
// IDと絵文字名が両方指定されている場合は絵文字名の変更を行うため重複チェックが必要
const doNameUpdate = data.id && data.name && (data.name !== emoji.name);
if (doNameUpdate) {
const isDuplicate = await this.checkDuplicate(data.name!);
if (isDuplicate) return "SAME_NAME_EMOJI_EXISTS";
if (isDuplicate) return 'SAME_NAME_EMOJI_EXISTS';
}
await this.emojisRepository.update(emoji.id, {

View File

@ -96,8 +96,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
switch (error) {
case undefined: return;
case "NO_SUCH_EMOJI": throw new ApiError(meta.errors.noSuchEmoji);
case "SAME_NAME_EMOJI_EXISTS": throw new ApiError(meta.errors.sameNameEmojiExists);
case 'NO_SUCH_EMOJI': throw new ApiError(meta.errors.noSuchEmoji);
case 'SAME_NAME_EMOJI_EXISTS': throw new ApiError(meta.errors.sameNameEmojiExists);
}
});
}