mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-02 21:16:09 +00:00
feat: BaseGuild.iconUrl
This commit is contained in:
parent
cc7a5848eb
commit
58b98719b4
@ -1,8 +1,12 @@
|
||||
import type { Model } from "../Base.ts";
|
||||
import type { Session } from "../../session/Session.ts";
|
||||
import type { DiscordGuild, GuildFeatures } from "../../vendor/external.ts";
|
||||
import type { DiscordGuild } from "../../vendor/external.ts";
|
||||
import type { ImageFormat, ImageSize } from "../../util/shared/images.ts";
|
||||
import { formatImageUrl } from "../../util/shared/images.ts";
|
||||
import { iconBigintToHash, iconHashToBigInt } from "../../util/hash.ts";
|
||||
import { GuildFeatures } from "../../vendor/external.ts";
|
||||
import { Snowflake } from "../../util/Snowflake.ts";
|
||||
import { iconHashToBigInt } from "../../util/hash.ts";
|
||||
import * as Routes from "../../util/Routes.ts";
|
||||
|
||||
/**
|
||||
* Class for {@link Guild} and {@link AnonymousGuild}
|
||||
@ -33,6 +37,24 @@ export abstract class BaseGuild implements Model {
|
||||
return new Date(this.createdTimestamp);
|
||||
}
|
||||
|
||||
get partnered() {
|
||||
return this.features.includes(GuildFeatures.Partnered);
|
||||
}
|
||||
|
||||
get verified() {
|
||||
return this.features.includes(GuildFeatures.Verified);
|
||||
}
|
||||
|
||||
iconUrl(options: { size?: ImageSize; format?: ImageFormat } = { size: 128 }) {
|
||||
if (this.iconHash) {
|
||||
return formatImageUrl(
|
||||
Routes.GUILD_BANNER(this.id, iconBigintToHash(this.iconHash)),
|
||||
options.size,
|
||||
options.format,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
toString() {
|
||||
return this.name;
|
||||
}
|
||||
|
@ -23,3 +23,7 @@ export function GUILD_BANNER(guildId: Snowflake, icon: string) {
|
||||
export function GUILD_SPLASH(guildId: Snowflake, icon: string) {
|
||||
return `${Endpoints.CDN_URL}/splashes/${guildId}/${icon}`;
|
||||
}
|
||||
|
||||
export function GUILD_ICON(guildId: Snowflake, icon: string) {
|
||||
return `${Endpoints.CDN_URL}/icons/${guildId}/${icon}`;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user