mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-14 06:32:36 +01:00
✨ sticker events
This commit is contained in:
parent
34e2392b48
commit
a64f79afda
@ -1,4 +1,14 @@
|
|||||||
import { handleFile, Member, Snowflake, Sticker, StickerFormatType, StickerType, uploadFile } from "@fosscord/util";
|
import {
|
||||||
|
emitEvent,
|
||||||
|
GuildStickersUpdateEvent,
|
||||||
|
handleFile,
|
||||||
|
Member,
|
||||||
|
Snowflake,
|
||||||
|
Sticker,
|
||||||
|
StickerFormatType,
|
||||||
|
StickerType,
|
||||||
|
uploadFile
|
||||||
|
} from "@fosscord/util";
|
||||||
import { Router, Request, Response } from "express";
|
import { Router, Request, Response } from "express";
|
||||||
import { route } from "@fosscord/api";
|
import { route } from "@fosscord/api";
|
||||||
import multer from "multer";
|
import multer from "multer";
|
||||||
@ -44,6 +54,8 @@ router.post(
|
|||||||
uploadFile(`/stickers/${id}`, req.file)
|
uploadFile(`/stickers/${id}`, req.file)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
await sendStickerUpdateEvent(guild_id);
|
||||||
|
|
||||||
res.json(sticker);
|
res.json(sticker);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -94,14 +106,28 @@ router.patch(
|
|||||||
const body = req.body as ModifyGuildStickerSchema;
|
const body = req.body as ModifyGuildStickerSchema;
|
||||||
|
|
||||||
const sticker = await new Sticker({ ...body, guild_id, id: sticker_id }).save();
|
const sticker = await new Sticker({ ...body, guild_id, id: sticker_id }).save();
|
||||||
|
await sendStickerUpdateEvent(guild_id);
|
||||||
|
|
||||||
return res.json(sticker);
|
return res.json(sticker);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
async function sendStickerUpdateEvent(guild_id: string) {
|
||||||
|
return emitEvent({
|
||||||
|
event: "GUILD_STICKERS_UPDATE",
|
||||||
|
guild_id: guild_id,
|
||||||
|
data: {
|
||||||
|
guild_id: guild_id,
|
||||||
|
stickers: await Sticker.find({ guild_id: guild_id })
|
||||||
|
}
|
||||||
|
} as GuildStickersUpdateEvent);
|
||||||
|
}
|
||||||
|
|
||||||
router.delete("/:sticker_id", route({ permission: "MANAGE_EMOJIS_AND_STICKERS" }), async (req: Request, res: Response) => {
|
router.delete("/:sticker_id", route({ permission: "MANAGE_EMOJIS_AND_STICKERS" }), async (req: Request, res: Response) => {
|
||||||
const { guild_id, sticker_id } = req.params;
|
const { guild_id, sticker_id } = req.params;
|
||||||
|
|
||||||
await Sticker.delete({ guild_id, id: sticker_id });
|
await Sticker.delete({ guild_id, id: sticker_id });
|
||||||
|
await sendStickerUpdateEvent(guild_id);
|
||||||
|
|
||||||
return res.sendStatus(204);
|
return res.sendStatus(204);
|
||||||
});
|
});
|
||||||
|
@ -12,6 +12,7 @@ import { Interaction } from "./Interaction";
|
|||||||
import { ConnectedAccount } from "../entities/ConnectedAccount";
|
import { ConnectedAccount } from "../entities/ConnectedAccount";
|
||||||
import { Relationship, RelationshipType } from "../entities/Relationship";
|
import { Relationship, RelationshipType } from "../entities/Relationship";
|
||||||
import { Presence } from "./Presence";
|
import { Presence } from "./Presence";
|
||||||
|
import { Sticker } from "..";
|
||||||
|
|
||||||
export interface Event {
|
export interface Event {
|
||||||
guild_id?: string;
|
guild_id?: string;
|
||||||
@ -193,6 +194,14 @@ export interface GuildEmojisUpdateEvent extends Event {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface GuildStickersUpdateEvent extends Event {
|
||||||
|
event: "GUILD_STICKERS_UPDATE";
|
||||||
|
data: {
|
||||||
|
guild_id: string;
|
||||||
|
stickers: Sticker[];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export interface GuildIntegrationUpdateEvent extends Event {
|
export interface GuildIntegrationUpdateEvent extends Event {
|
||||||
event: "GUILD_INTEGRATIONS_UPDATE";
|
event: "GUILD_INTEGRATIONS_UPDATE";
|
||||||
data: {
|
data: {
|
||||||
@ -553,6 +562,7 @@ export type EVENT =
|
|||||||
| "GUILD_BAN_ADD"
|
| "GUILD_BAN_ADD"
|
||||||
| "GUILD_BAN_REMOVE"
|
| "GUILD_BAN_REMOVE"
|
||||||
| "GUILD_EMOJIS_UPDATE"
|
| "GUILD_EMOJIS_UPDATE"
|
||||||
|
| "GUILD_STICKERS_UPDATE"
|
||||||
| "GUILD_INTEGRATIONS_UPDATE"
|
| "GUILD_INTEGRATIONS_UPDATE"
|
||||||
| "GUILD_MEMBER_ADD"
|
| "GUILD_MEMBER_ADD"
|
||||||
| "GUILD_MEMBER_REMOVE"
|
| "GUILD_MEMBER_REMOVE"
|
||||||
|
Loading…
Reference in New Issue
Block a user