mirror of
https://github.com/spacebarchat/server.git
synced 2026-03-30 22:35:40 +00:00
sticker impl
This commit is contained in:
@@ -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());
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user