mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-08 11:52:55 +01:00
Merge pull request #1185 from CyberL1/feat/message-pinned-message
feat: message pinned message
This commit is contained in:
commit
1b9d75524a
@ -23,7 +23,9 @@ import {
|
|||||||
DiscordApiErrors,
|
DiscordApiErrors,
|
||||||
emitEvent,
|
emitEvent,
|
||||||
Message,
|
Message,
|
||||||
|
MessageCreateEvent,
|
||||||
MessageUpdateEvent,
|
MessageUpdateEvent,
|
||||||
|
User,
|
||||||
} from "@spacebar/util";
|
} from "@spacebar/util";
|
||||||
import { Request, Response, Router } from "express";
|
import { Request, Response, Router } from "express";
|
||||||
|
|
||||||
@ -61,6 +63,30 @@ router.put(
|
|||||||
|
|
||||||
message.pinned = true;
|
message.pinned = true;
|
||||||
|
|
||||||
|
const author = await User.getPublicUser(req.user_id);
|
||||||
|
|
||||||
|
const systemPinMessage = Message.create({
|
||||||
|
timestamp: new Date(),
|
||||||
|
type: 6,
|
||||||
|
guild_id: message.guild_id,
|
||||||
|
channel_id: message.channel_id,
|
||||||
|
author,
|
||||||
|
message_reference: {
|
||||||
|
message_id: message.id,
|
||||||
|
channel_id: message.channel_id,
|
||||||
|
guild_id: message.guild_id,
|
||||||
|
},
|
||||||
|
reactions: [],
|
||||||
|
attachments: [],
|
||||||
|
embeds: [],
|
||||||
|
sticker_items: [],
|
||||||
|
edited_timestamp: undefined,
|
||||||
|
mentions: [],
|
||||||
|
mention_channels: [],
|
||||||
|
mention_roles: [],
|
||||||
|
mention_everyone: false,
|
||||||
|
});
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
message.save(),
|
message.save(),
|
||||||
emitEvent({
|
emitEvent({
|
||||||
@ -77,6 +103,12 @@ router.put(
|
|||||||
last_pin_timestamp: undefined,
|
last_pin_timestamp: undefined,
|
||||||
},
|
},
|
||||||
} as ChannelPinsUpdateEvent),
|
} as ChannelPinsUpdateEvent),
|
||||||
|
systemPinMessage.save(),
|
||||||
|
emitEvent({
|
||||||
|
event: "MESSAGE_CREATE",
|
||||||
|
channel_id: message.channel_id,
|
||||||
|
data: systemPinMessage,
|
||||||
|
} as MessageCreateEvent),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
res.sendStatus(204);
|
res.sendStatus(204);
|
||||||
|
Loading…
Reference in New Issue
Block a user