Add sticker limit
This commit is contained in:
parent
1f68a745a5
commit
021a387679
@ -27,6 +27,8 @@ import {
|
|||||||
StickerType,
|
StickerType,
|
||||||
emitEvent,
|
emitEvent,
|
||||||
uploadFile,
|
uploadFile,
|
||||||
|
Config,
|
||||||
|
DiscordApiErrors,
|
||||||
} from "@spacebar/util";
|
} from "@spacebar/util";
|
||||||
import { Request, Response, Router } from "express";
|
import { Request, Response, Router } from "express";
|
||||||
import { HTTPError } from "lambert-server";
|
import { HTTPError } from "lambert-server";
|
||||||
@ -87,6 +89,16 @@ router.post(
|
|||||||
const body = req.body as ModifyGuildStickerSchema;
|
const body = req.body as ModifyGuildStickerSchema;
|
||||||
const id = Snowflake.generate();
|
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([
|
const [sticker] = await Promise.all([
|
||||||
Sticker.create({
|
Sticker.create({
|
||||||
...body,
|
...body,
|
||||||
|
|||||||
@ -19,6 +19,7 @@
|
|||||||
export class GuildLimits {
|
export class GuildLimits {
|
||||||
maxRoles: number = 1000;
|
maxRoles: number = 1000;
|
||||||
maxEmojis: number = 2000;
|
maxEmojis: number = 2000;
|
||||||
|
maxStickers: number = 500;
|
||||||
maxMembers: number = 25000000;
|
maxMembers: number = 25000000;
|
||||||
maxChannels: number = 65535;
|
maxChannels: number = 65535;
|
||||||
maxBulkBanUsers: number = 200;
|
maxBulkBanUsers: number = 200;
|
||||||
|
|||||||
Reference in New Issue
Block a user