mirror of
https://github.com/spacebarchat/server.git
synced 2026-05-24 21:15:28 +00:00
Add sticker limit
This commit is contained in:
@@ -27,6 +27,8 @@ import {
|
||||
StickerType,
|
||||
emitEvent,
|
||||
uploadFile,
|
||||
Config,
|
||||
DiscordApiErrors,
|
||||
} from "@spacebar/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { HTTPError } from "lambert-server";
|
||||
@@ -87,6 +89,16 @@ router.post(
|
||||
const body = req.body as ModifyGuildStickerSchema;
|
||||
const id = Snowflake.generate();
|
||||
|
||||
const sticker_count = await Sticker.count({
|
||||
where: { guild_id: guild_id },
|
||||
});
|
||||
const { maxStickers } = Config.get().limits.guild;
|
||||
|
||||
if (sticker_count >= maxStickers)
|
||||
throw DiscordApiErrors.MAXIMUM_STICKERS.withParams(
|
||||
maxStickers,
|
||||
);
|
||||
|
||||
const [sticker] = await Promise.all([
|
||||
Sticker.create({
|
||||
...body,
|
||||
|
||||
Reference in New Issue
Block a user