seyfert
Version:
The most advanced framework for discord bots
77 lines (76 loc) • 2.53 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ApplicationEmoji = exports.GuildEmoji = exports.Emoji = void 0;
const client_1 = require("../client");
const common_1 = require("../common");
const DiscordBase_1 = require("./extra/DiscordBase");
class Emoji extends DiscordBase_1.DiscordBase {
user;
constructor(client, data) {
super(client, { ...data, id: data.id });
this.user = (data.user && client_1.Transformers.User(client, data.user));
}
url(options) {
return this.rest.cdn.emojis(this.id).get(options);
}
toString() {
return common_1.Formatter.emojiMention(this.id, this.name, this.animated);
}
toJSON() {
return {
id: this.id,
name: this.name,
animated: !!this.animated,
};
}
}
exports.Emoji = Emoji;
class GuildEmoji extends Emoji {
guildId;
constructor(client, data, guildId) {
super(client, data);
this.guildId = guildId;
}
guild(mode = 'flow') {
switch (mode) {
case 'cache':
return (this.client.cache.guilds?.get(this.guildId) ||
(this.client.cache.adapter.isAsync ? Promise.resolve() : undefined));
default:
return this.client.guilds.fetch(this.guildId, mode === 'rest');
}
}
edit(body, reason) {
return this.client.emojis.edit(this.guildId, this.id, body, reason);
}
delete(reason) {
return this.client.emojis.delete(this.guildId, this.id, reason);
}
fetch(force = false) {
return this.client.emojis.fetch(this.guildId, this.id, force);
}
static methods({ client, guildId }) {
return {
edit: (emojiId, body, reason) => client.emojis.edit(guildId, emojiId, body, reason),
create: (body) => client.emojis.create(guildId, body),
fetch: (emojiId, force = false) => client.emojis.fetch(guildId, emojiId, force),
list: (force = false) => client.emojis.list(guildId, force),
};
}
}
exports.GuildEmoji = GuildEmoji;
class ApplicationEmoji extends Emoji {
constructor(client, data) {
super(client, data);
}
fetch() {
return this.client.applications.getEmoji(this.id);
}
edit(body) {
return this.client.applications.editEmoji(this.id, body);
}
delete() {
return this.client.applications.deleteEmoji(this.id);
}
}
exports.ApplicationEmoji = ApplicationEmoji;