mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 20:13:30 +01:00
@@ -53,4 +53,23 @@ class BaseGuildEmoji extends Emoji {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a URL for the emoji.
|
||||||
|
* @method imageURL
|
||||||
|
* @memberof BaseGuildEmoji
|
||||||
|
* @instance
|
||||||
|
* @param {BaseImageURLOptions} [options] Options for the image URL
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a URL for the emoji.
|
||||||
|
* @name url
|
||||||
|
* @memberof BaseGuildEmoji
|
||||||
|
* @instance
|
||||||
|
* @type {string}
|
||||||
|
* @readonly
|
||||||
|
* @deprecated Use {@link BaseGuildEmoji#imageURL} instead.
|
||||||
|
*/
|
||||||
|
|
||||||
module.exports = BaseGuildEmoji;
|
module.exports = BaseGuildEmoji;
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const process = require('node:process');
|
||||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||||
const Base = require('./Base');
|
const Base = require('./Base');
|
||||||
|
|
||||||
|
let deprecationEmittedForURL = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an emoji, see {@link GuildEmoji} and {@link ReactionEmoji}.
|
* Represents an emoji, see {@link GuildEmoji} and {@link ReactionEmoji}.
|
||||||
* @extends {Base}
|
* @extends {Base}
|
||||||
@@ -40,12 +43,27 @@ class Emoji extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The URL to the emoji file if it's a custom emoji
|
* Returns a URL for the emoji or `null` if this is not a custom emoji.
|
||||||
|
* @param {BaseImageURLOptions} [options] Options for the image URL
|
||||||
|
* @returns {?string}
|
||||||
|
*/
|
||||||
|
imageURL(options) {
|
||||||
|
return this.id && this.client.rest.cdn.emoji(this.id, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a URL for the emoji or `null` if this is not a custom emoji.
|
||||||
* @type {?string}
|
* @type {?string}
|
||||||
* @readonly
|
* @readonly
|
||||||
|
* @deprecated Use {@link Emoji#imageURL} instead.
|
||||||
*/
|
*/
|
||||||
get url() {
|
get url() {
|
||||||
return this.id && this.client.rest.cdn.emoji(this.id, this.animated ? 'gif' : 'png');
|
if (!deprecationEmittedForURL) {
|
||||||
|
process.emitWarning('The Emoji#url getter is deprecated. Use Emoji#imageURL() instead.', 'DeprecationWarning');
|
||||||
|
deprecationEmittedForURL = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.imageURL({ extension: this.animated ? 'gif' : 'png' });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
4
packages/discord.js/typings/index.d.ts
vendored
4
packages/discord.js/typings/index.d.ts
vendored
@@ -627,6 +627,8 @@ export abstract class BaseGuild extends Base {
|
|||||||
|
|
||||||
export class BaseGuildEmoji extends Emoji {
|
export class BaseGuildEmoji extends Emoji {
|
||||||
protected constructor(client: Client<true>, data: RawGuildEmojiData, guild: Guild | GuildPreview);
|
protected constructor(client: Client<true>, data: RawGuildEmojiData, guild: Guild | GuildPreview);
|
||||||
|
public imageURL(options?: BaseImageURLOptions): string;
|
||||||
|
public get url(): string;
|
||||||
public available: boolean | null;
|
public available: boolean | null;
|
||||||
public get createdAt(): Date;
|
public get createdAt(): Date;
|
||||||
public get createdTimestamp(): number;
|
public get createdTimestamp(): number;
|
||||||
@@ -1312,6 +1314,7 @@ export class Emoji extends Base {
|
|||||||
public id: Snowflake | null;
|
public id: Snowflake | null;
|
||||||
public name: string | null;
|
public name: string | null;
|
||||||
public get identifier(): string;
|
public get identifier(): string;
|
||||||
|
public imageURL(options?: BaseImageURLOptions): string | null;
|
||||||
public get url(): string | null;
|
public get url(): string | null;
|
||||||
public toJSON(): unknown;
|
public toJSON(): unknown;
|
||||||
public toString(): string;
|
public toString(): string;
|
||||||
@@ -1530,7 +1533,6 @@ export class GuildEmoji extends BaseGuildEmoji {
|
|||||||
public guild: Guild;
|
public guild: Guild;
|
||||||
public author: User | null;
|
public author: User | null;
|
||||||
public get roles(): GuildEmojiRoleManager;
|
public get roles(): GuildEmojiRoleManager;
|
||||||
public get url(): string;
|
|
||||||
public delete(reason?: string): Promise<GuildEmoji>;
|
public delete(reason?: string): Promise<GuildEmoji>;
|
||||||
public edit(options: GuildEmojiEditOptions): Promise<GuildEmoji>;
|
public edit(options: GuildEmojiEditOptions): Promise<GuildEmoji>;
|
||||||
public equals(other: GuildEmoji | unknown): boolean;
|
public equals(other: GuildEmoji | unknown): boolean;
|
||||||
|
|||||||
Reference in New Issue
Block a user