sticker impl

This commit is contained in:
MathMan05
2026-03-03 20:33:47 -06:00
committed by Rory&
parent 43f2b8de58
commit a8ba2d6553
2 changed files with 55 additions and 1 deletions

View File

@@ -33,7 +33,22 @@ router.get(
async (req: Request, res: Response) => {
const { sticker_id } = req.params as { [key: string]: string };
res.json(await Sticker.find({ where: { id: sticker_id } }));
res.json(await Sticker.findOne({ where: { id: sticker_id } }));
},
);
router.get(
"/guild",
route({
responses: {
200: {
body: "Sticker",
},
},
}),
async (req: Request, res: Response) => {
const { sticker_id } = req.params as { [key: string]: string };
const sticker = await Sticker.findOne({ where: { id: sticker_id }, relations: { guild: true } });
res.json(await sticker?.guild?.ToGuildSource());
},
);

View File

@@ -304,6 +304,45 @@ export class Guild extends BaseClass {
@Column()
discovery_excluded: boolean = false;
async ToGuildSource() {
if (!this.features.includes("DISCOVERABLE")) {
return null;
}
return {
id: this.id,
name: this.name,
icon: this.icon,
description: this.description,
banner: this.banner,
splash: this.splash,
discovery_splash: this.discovery_splash,
features: this.features,
vanity_url_code: null,
preferred_locale: this.preferred_locale || "en",
premium_subscription_count: this.premium_subscription_count,
approximate_member_count: await Member.countBy({
guild_id: this.id,
}),
approximate_presence_count: await Member.countBy({
guild_id: this.id,
user: {
sessions: {
status: "online",
},
},
}),
emojis: this.emojis ?? undefined,
emoji_count: this.emojis ? this.emojis.length : undefined,
stickers: this.stickers ?? undefined,
sticker_count: this.stickers ? this.stickers.length : undefined,
auto_removed: false,
primary_category_id: this.primary_category_id,
keywords: [],
is_published: false,
reasons_to_join: [],
};
}
static async createGuild(body: {
name?: string;
icon?: string | null;