mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-03 05:26:07 +00:00
feat(Emoji): Add Methods (#99)
* feat(Emoji): add methods * fix: redundancy Co-authored-by: Yuzu <yuzuru@programmer.net>
This commit is contained in:
parent
4d779e6bb2
commit
835b8d3f39
@ -128,7 +128,8 @@ export function USER_DM() {
|
|||||||
return `/users/@me/channels`;
|
return `/users/@me/channels`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function GUILD_EMOJIS(guildId: Snowflake): string {
|
export function GUILD_EMOJIS(guildId: Snowflake, emojiId?: Snowflake): string {
|
||||||
|
if (emojiId) return `/guilds/${guildId}/emojis/${emojiId}`;
|
||||||
return `/guilds/${guildId}/emojis`;
|
return `/guilds/${guildId}/emojis`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
import type { Session } from '../biscuit';
|
import type { Session } from '../biscuit';
|
||||||
import type { Model } from './base';
|
import type { Model } from './base';
|
||||||
import type { Snowflake } from '../snowflakes';
|
import type { Snowflake } from '../snowflakes';
|
||||||
import type { DiscordEmoji } from '@biscuitland/api-types';
|
import { Guild, ModifyGuildEmoji} from './guilds';
|
||||||
import type { ModifyGuildEmoji } from './guilds';
|
|
||||||
import { Guild } from './guilds';
|
|
||||||
import { User } from './user';
|
import { User } from './user';
|
||||||
import { EMOJI_URL } from '@biscuitland/api-types';
|
import { EMOJI_URL, DiscordEmoji, GUILD_EMOJIS } from '@biscuitland/api-types';
|
||||||
|
|
||||||
export class Emoji implements Partial<Model> {
|
export class Emoji implements Partial<Model> {
|
||||||
constructor(session: Session, data: DiscordEmoji) {
|
constructor(session: Session, data: DiscordEmoji) {
|
||||||
@ -64,7 +62,22 @@ export class GuildEmoji extends Emoji implements Model {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fetchAuthor(): Promise<User | null> {
|
||||||
|
const emoji = await this.session.rest.get<DiscordEmoji>(GUILD_EMOJIS(this.guildId, this.id));
|
||||||
|
|
||||||
|
if (emoji.user) return new User(this.session, emoji.user);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
setName(name: string): Promise<GuildEmoji> {
|
||||||
|
return this.edit({ name });
|
||||||
|
}
|
||||||
|
|
||||||
get url(): string {
|
get url(): string {
|
||||||
return EMOJI_URL(this.id, this.animated);
|
return EMOJI_URL(this.id, this.animated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toString(): string {
|
||||||
|
return `<${this.animated ? 'a' : ''}:${this.name}:${this.id}>`
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user