diff --git a/src/channels/channels.service.ts b/src/channels/channels.service.ts index 169225e..48d2456 100644 --- a/src/channels/channels.service.ts +++ b/src/channels/channels.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@nestjs/common'; +import { BadRequestException, Injectable } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { Repository } from 'typeorm'; import { Channel } from '../entities/channel.entity'; @@ -26,9 +26,14 @@ export class ChannelsService { } create(input: Partial) { + const guildId = String(input.guildId ?? '').trim(); + const name = String(input.name ?? '').trim(); + if (!guildId) throw new BadRequestException('guildId is required'); + if (!name) throw new BadRequestException('name is required'); + const channel = this.channelRepo.create({ - guildId: String(input.guildId ?? ''), - name: String(input.name ?? ''), + guildId, + name, kind: input.kind === 'announcement' ? 'announcement' : 'text', isPrivate: Boolean(input.isPrivate), lastSeq: 0,