diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2023-08-10 20:34:23 +1000 |
---|---|---|
committer | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2023-08-10 20:37:07 +1000 |
commit | 326bf08df071111d30af258eb1eb043e4b9433a0 (patch) | |
tree | bb70b6d08b54c97321a2b3bc851134da1d9825d8 /src/util/entities/Channel.ts | |
parent | Allow enabling welcome screen and check if welcome screen channels exist with... (diff) | |
download | server-326bf08df071111d30af258eb1eb043e4b9433a0.tar.xz |
Implement community "create one for me"
Diffstat (limited to '')
-rw-r--r-- | src/util/entities/Channel.ts | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/util/entities/Channel.ts b/src/util/entities/Channel.ts index 38627c39..19952bc2 100644 --- a/src/util/entities/Channel.ts +++ b/src/util/entities/Channel.ts @@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */ +import { HTTPError } from "lambert-server"; import { Column, Entity, @@ -24,26 +25,25 @@ import { OneToMany, RelationId, } from "typeorm"; -import { BaseClass } from "./BaseClass"; -import { Guild } from "./Guild"; -import { PublicUserProjection, User } from "./User"; -import { HTTPError } from "lambert-server"; +import { DmChannelDTO } from "../dtos"; +import { ChannelCreateEvent, ChannelRecipientRemoveEvent } from "../interfaces"; import { + InvisibleCharacters, + Snowflake, containsAll, emitEvent, getPermission, - Snowflake, trimSpecial, - InvisibleCharacters, } from "../util"; -import { ChannelCreateEvent, ChannelRecipientRemoveEvent } from "../interfaces"; -import { Recipient } from "./Recipient"; +import { BaseClass } from "./BaseClass"; +import { Guild } from "./Guild"; +import { Invite } from "./Invite"; import { Message } from "./Message"; import { ReadState } from "./ReadState"; -import { Invite } from "./Invite"; +import { Recipient } from "./Recipient"; +import { PublicUserProjection, User } from "./User"; import { VoiceState } from "./VoiceState"; import { Webhook } from "./Webhook"; -import { DmChannelDTO } from "../dtos"; export enum ChannelType { GUILD_TEXT = 0, // a text channel within a guild @@ -302,8 +302,10 @@ export class Channel extends BaseClass { : channel.position) || 0, }; + const ret = Channel.create(channel); + await Promise.all([ - Channel.create(channel).save(), + ret.save(), !opts?.skipEventEmit ? emitEvent({ event: "CHANNEL_CREATE", @@ -313,7 +315,7 @@ export class Channel extends BaseClass { : Promise.resolve(), ]); - return channel; + return ret; } static async createDMChannel( |