mirror of
https://github.com/danbulant/discord.js
synced 2026-06-05 07:42:09 +00:00
feat(Emoji): move createdAt and createdTimestamp getters from GuildEmoji (#2872)
This commit is contained in:
parent
1ee417cd65
commit
71c04a303a
3 changed files with 24 additions and 21 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
|
const Snowflake = require('../util/Snowflake');
|
||||||
const Base = require('./Base');
|
const Base = require('./Base');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an emoji, see {@link GuildEmoji} and {@link ReactionEmoji}.
|
* Represents an emoji, see {@link GuildEmoji} and {@link ReactionEmoji}.
|
||||||
* @extends {Base}
|
* @extends {Base}
|
||||||
|
|
@ -52,6 +54,26 @@ class Emoji extends Base {
|
||||||
return this.client.rest.cdn.Emoji(this.id, this.animated ? 'gif' : 'png');
|
return this.client.rest.cdn.Emoji(this.id, this.animated ? 'gif' : 'png');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The timestamp the emoji was created at, or null if unicode
|
||||||
|
* @type {?number}
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
|
get createdTimestamp() {
|
||||||
|
if (!this.id) return null;
|
||||||
|
return Snowflake.deconstruct(this.id).timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The time the emoji was created at, or null if unicode
|
||||||
|
* @type {?Date}
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
|
get createdAt() {
|
||||||
|
if (!this.id) return null;
|
||||||
|
return new Date(this.createdTimestamp);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When concatenated with a string, this automatically returns the text required to form a graphical emoji on Discord
|
* When concatenated with a string, this automatically returns the text required to form a graphical emoji on Discord
|
||||||
* instead of the Emoji object.
|
* instead of the Emoji object.
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
const GuildEmojiRoleStore = require('../stores/GuildEmojiRoleStore');
|
const GuildEmojiRoleStore = require('../stores/GuildEmojiRoleStore');
|
||||||
const Permissions = require('../util/Permissions');
|
const Permissions = require('../util/Permissions');
|
||||||
const { Error } = require('../errors');
|
const { Error } = require('../errors');
|
||||||
const Snowflake = require('../util/Snowflake');
|
|
||||||
const Emoji = require('./Emoji');
|
const Emoji = require('./Emoji');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -65,24 +64,6 @@ class GuildEmoji extends Emoji {
|
||||||
return new GuildEmojiRoleStore(this);
|
return new GuildEmojiRoleStore(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The timestamp the emoji was created at
|
|
||||||
* @type {number}
|
|
||||||
* @readonly
|
|
||||||
*/
|
|
||||||
get createdTimestamp() {
|
|
||||||
return Snowflake.deconstruct(this.id).timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The time the emoji was created at
|
|
||||||
* @type {Date}
|
|
||||||
* @readonly
|
|
||||||
*/
|
|
||||||
get createdAt() {
|
|
||||||
return new Date(this.createdTimestamp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the author for this emoji
|
* Fetches the author for this emoji
|
||||||
* @returns {Promise<User>}
|
* @returns {Promise<User>}
|
||||||
|
|
|
||||||
4
typings/index.d.ts
vendored
4
typings/index.d.ts
vendored
|
|
@ -370,6 +370,8 @@ declare module 'discord.js' {
|
||||||
export class Emoji extends Base {
|
export class Emoji extends Base {
|
||||||
constructor(client: Client, emoji: object);
|
constructor(client: Client, emoji: object);
|
||||||
public animated: boolean;
|
public animated: boolean;
|
||||||
|
public readonly createdAt: Date;
|
||||||
|
public readonly createdTimestamp: number;
|
||||||
public readonly deletable: boolean;
|
public readonly deletable: boolean;
|
||||||
public id: Snowflake;
|
public id: Snowflake;
|
||||||
public name: string;
|
public name: string;
|
||||||
|
|
@ -544,8 +546,6 @@ declare module 'discord.js' {
|
||||||
constructor(client: Client, data: object, guild: Guild);
|
constructor(client: Client, data: object, guild: Guild);
|
||||||
private _roles: string[];
|
private _roles: string[];
|
||||||
|
|
||||||
public readonly createdAt: Date;
|
|
||||||
public readonly createdTimestamp: number;
|
|
||||||
public deleted: boolean;
|
public deleted: boolean;
|
||||||
public guild: Guild;
|
public guild: Guild;
|
||||||
public managed: boolean;
|
public managed: boolean;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue