mirror of
https://github.com/danbulant/discord.js
synced 2026-06-24 17:21:59 +00:00
Webpack build for branch master: c93c4ad21f
This commit is contained in:
parent
56123a2887
commit
cf1bfdd4aa
2 changed files with 282 additions and 281 deletions
|
|
@ -1061,19 +1061,23 @@ class Collection extends Map {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Searches for the existence of a single item where its specified property's value is identical to the given value
|
* Searches for the existence of a single item where its specified property's value is identical to the given value
|
||||||
* (`item[prop] === value`).
|
* (`item[prop] === value`), or the given function returns a truthy value.
|
||||||
* <warn>Do not use this to check for an item by its ID. Instead, use `collection.has(id)`. See
|
* <warn>Do not use this to check for an item by its ID. Instead, use `collection.has(id)`. See
|
||||||
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has) for details.</warn>
|
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has) for details.</warn>
|
||||||
* @param {string} prop The property to test against
|
* @param {string|Function} propOrFn The property to test against, or the function to test with
|
||||||
* @param {*} value The expected value
|
* @param {*} [value] The expected value - only applicable and required if using a property for the first argument
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
* @example
|
* @example
|
||||||
* if (collection.exists('username', 'Bob')) {
|
* if (collection.exists('username', 'Bob')) {
|
||||||
* console.log('user here!');
|
* console.log('user here!');
|
||||||
* }
|
* }
|
||||||
|
* @example
|
||||||
|
* if (collection.exists(user => user.username === 'Bob')) {
|
||||||
|
* console.log('user here!');
|
||||||
|
* }
|
||||||
*/
|
*/
|
||||||
exists(prop, value) {
|
exists(propOrFn, value) {
|
||||||
return Boolean(this.find(prop, value));
|
return Boolean(this.find(propOrFn, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -4273,7 +4277,7 @@ if (typeof Object.create === 'function') {
|
||||||
|
|
||||||
/*<replacement>*/
|
/*<replacement>*/
|
||||||
|
|
||||||
var processNextTick = __webpack_require__(31);
|
var processNextTick = __webpack_require__(30);
|
||||||
/*</replacement>*/
|
/*</replacement>*/
|
||||||
|
|
||||||
/*<replacement>*/
|
/*<replacement>*/
|
||||||
|
|
@ -4443,7 +4447,7 @@ class Channel extends Base {
|
||||||
const GroupDMChannel = __webpack_require__(35);
|
const GroupDMChannel = __webpack_require__(35);
|
||||||
const TextChannel = __webpack_require__(49);
|
const TextChannel = __webpack_require__(49);
|
||||||
const VoiceChannel = __webpack_require__(50);
|
const VoiceChannel = __webpack_require__(50);
|
||||||
const GuildChannel = __webpack_require__(30);
|
const GuildChannel = __webpack_require__(29);
|
||||||
const types = Constants.ChannelTypes;
|
const types = Constants.ChannelTypes;
|
||||||
let channel;
|
let channel;
|
||||||
if (data.type === types.DM) {
|
if (data.type === types.DM) {
|
||||||
|
|
@ -6192,7 +6196,7 @@ exports.RichPresenceAssets = RichPresenceAssets;
|
||||||
/* 21 */
|
/* 21 */
|
||||||
/***/ (function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
const Attachment = __webpack_require__(34);
|
const Attachment = __webpack_require__(33);
|
||||||
const Util = __webpack_require__(6);
|
const Util = __webpack_require__(6);
|
||||||
const { RangeError } = __webpack_require__(4);
|
const { RangeError } = __webpack_require__(4);
|
||||||
|
|
||||||
|
|
@ -6533,11 +6537,10 @@ module.exports = MessageEmbed;
|
||||||
|
|
||||||
const Long = __webpack_require__(44);
|
const Long = __webpack_require__(44);
|
||||||
const Role = __webpack_require__(19);
|
const Role = __webpack_require__(19);
|
||||||
const Emoji = __webpack_require__(29);
|
|
||||||
const Invite = __webpack_require__(36);
|
const Invite = __webpack_require__(36);
|
||||||
const GuildAuditLogs = __webpack_require__(72);
|
const GuildAuditLogs = __webpack_require__(72);
|
||||||
const Webhook = __webpack_require__(23);
|
const Webhook = __webpack_require__(23);
|
||||||
const GuildChannel = __webpack_require__(30);
|
const GuildChannel = __webpack_require__(29);
|
||||||
const GuildMember = __webpack_require__(18);
|
const GuildMember = __webpack_require__(18);
|
||||||
const VoiceRegion = __webpack_require__(73);
|
const VoiceRegion = __webpack_require__(73);
|
||||||
const Constants = __webpack_require__(0);
|
const Constants = __webpack_require__(0);
|
||||||
|
|
@ -7588,18 +7591,6 @@ class Guild extends Base {
|
||||||
.then(image => this.createEmoji(image, name, { roles, reason }));
|
.then(image => this.createEmoji(image, name, { roles, reason }));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete an emoji.
|
|
||||||
* @param {Emoji|string} emoji The emoji to delete
|
|
||||||
* @param {string} [reason] Reason for deleting the emoji
|
|
||||||
* @returns {Promise<Emoji>}
|
|
||||||
*/
|
|
||||||
deleteEmoji(emoji, reason) {
|
|
||||||
if (!(emoji instanceof Emoji)) emoji = this.emojis.get(emoji);
|
|
||||||
return this.client.api.guilds(this.id).emojis(emoji.id).delete({ reason })
|
|
||||||
.then(() => this.client.actions.GuildEmojiDelete.handle(emoji).data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Causes the client to leave the guild.
|
* Causes the client to leave the guild.
|
||||||
* @returns {Promise<Guild>}
|
* @returns {Promise<Guild>}
|
||||||
|
|
@ -7813,7 +7804,7 @@ module.exports = Guild;
|
||||||
/* WEBPACK VAR INJECTION */(function(Buffer) {const path = __webpack_require__(26);
|
/* WEBPACK VAR INJECTION */(function(Buffer) {const path = __webpack_require__(26);
|
||||||
const Util = __webpack_require__(6);
|
const Util = __webpack_require__(6);
|
||||||
const Embed = __webpack_require__(21);
|
const Embed = __webpack_require__(21);
|
||||||
const Attachment = __webpack_require__(34);
|
const Attachment = __webpack_require__(33);
|
||||||
const MessageEmbed = __webpack_require__(21);
|
const MessageEmbed = __webpack_require__(21);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -8735,10 +8726,10 @@ module.exports = User;
|
||||||
/* WEBPACK VAR INJECTION */(function(Buffer) {const path = __webpack_require__(26);
|
/* WEBPACK VAR INJECTION */(function(Buffer) {const path = __webpack_require__(26);
|
||||||
const MessageCollector = __webpack_require__(67);
|
const MessageCollector = __webpack_require__(67);
|
||||||
const Shared = __webpack_require__(68);
|
const Shared = __webpack_require__(68);
|
||||||
const MessageStore = __webpack_require__(33);
|
const MessageStore = __webpack_require__(32);
|
||||||
const Snowflake = __webpack_require__(9);
|
const Snowflake = __webpack_require__(9);
|
||||||
const Collection = __webpack_require__(3);
|
const Collection = __webpack_require__(3);
|
||||||
const Attachment = __webpack_require__(34);
|
const Attachment = __webpack_require__(33);
|
||||||
const MessageEmbed = __webpack_require__(21);
|
const MessageEmbed = __webpack_require__(21);
|
||||||
const { RangeError, TypeError } = __webpack_require__(4);
|
const { RangeError, TypeError } = __webpack_require__(4);
|
||||||
|
|
||||||
|
|
@ -9082,239 +9073,6 @@ module.exports = TextBasedChannel;
|
||||||
/* 29 */
|
/* 29 */
|
||||||
/***/ (function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
const Collection = __webpack_require__(3);
|
|
||||||
const Snowflake = __webpack_require__(9);
|
|
||||||
const Base = __webpack_require__(10);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a custom emoji.
|
|
||||||
* @extends {Base}
|
|
||||||
*/
|
|
||||||
class Emoji extends Base {
|
|
||||||
constructor(guild, data) {
|
|
||||||
super(guild.client);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The guild this emoji is part of
|
|
||||||
* @type {Guild}
|
|
||||||
*/
|
|
||||||
this.guild = guild;
|
|
||||||
|
|
||||||
this._patch(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
_patch(data) {
|
|
||||||
/**
|
|
||||||
* The ID of the emoji
|
|
||||||
* @type {Snowflake}
|
|
||||||
*/
|
|
||||||
this.id = data.id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The name of the emoji
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
this.name = data.name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether or not this emoji requires colons surrounding it
|
|
||||||
* @type {boolean}
|
|
||||||
*/
|
|
||||||
this.requiresColons = data.require_colons;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether this emoji is managed by an external service
|
|
||||||
* @type {boolean}
|
|
||||||
*/
|
|
||||||
this.managed = data.managed;
|
|
||||||
|
|
||||||
this._roles = data.roles;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The timestamp the emoji was created at
|
|
||||||
* @type {number}
|
|
||||||
* @readonly
|
|
||||||
*/
|
|
||||||
get createdTimestamp() {
|
|
||||||
return Snowflake.deconstruct(this.id).timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The time the emoji was created
|
|
||||||
* @type {Date}
|
|
||||||
* @readonly
|
|
||||||
*/
|
|
||||||
get createdAt() {
|
|
||||||
return new Date(this.createdTimestamp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A collection of roles this emoji is active for (empty if all), mapped by role ID
|
|
||||||
* @type {Collection<Snowflake, Role>}
|
|
||||||
* @readonly
|
|
||||||
*/
|
|
||||||
get roles() {
|
|
||||||
const roles = new Collection();
|
|
||||||
for (const role of this._roles) {
|
|
||||||
if (this.guild.roles.has(role)) roles.set(role, this.guild.roles.get(role));
|
|
||||||
}
|
|
||||||
return roles;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The URL to the emoji file
|
|
||||||
* @type {string}
|
|
||||||
* @readonly
|
|
||||||
*/
|
|
||||||
get url() {
|
|
||||||
return this.client.rest.cdn.Emoji(this.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The identifier of this emoji, used for message reactions
|
|
||||||
* @type {string}
|
|
||||||
* @readonly
|
|
||||||
*/
|
|
||||||
get identifier() {
|
|
||||||
if (this.id) return `${this.name}:${this.id}`;
|
|
||||||
return encodeURIComponent(this.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Data for editing an emoji.
|
|
||||||
* @typedef {Object} EmojiEditData
|
|
||||||
* @property {string} [name] The name of the emoji
|
|
||||||
* @property {Collection<Snowflake, Role>|RoleResolvable[]} [roles] Roles to restrict emoji to
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Edits the emoji.
|
|
||||||
* @param {EmojiEditData} data The new data for the emoji
|
|
||||||
* @param {string} [reason] Reason for editing this emoji
|
|
||||||
* @returns {Promise<Emoji>}
|
|
||||||
* @example
|
|
||||||
* // Edit an emoji
|
|
||||||
* emoji.edit({name: 'newemoji'})
|
|
||||||
* .then(e => console.log(`Edited emoji ${e}`))
|
|
||||||
* .catch(console.error);
|
|
||||||
*/
|
|
||||||
edit(data, reason) {
|
|
||||||
return this.client.api.guilds(this.guild.id).emojis(this.id)
|
|
||||||
.patch({ data: {
|
|
||||||
name: data.name,
|
|
||||||
roles: data.roles ? data.roles.map(r => r.id ? r.id : r) : undefined,
|
|
||||||
}, reason })
|
|
||||||
.then(() => this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the name of the emoji.
|
|
||||||
* @param {string} name The new name for the emoji
|
|
||||||
* @param {string} [reason] Reason for changing the emoji's name
|
|
||||||
* @returns {Promise<Emoji>}
|
|
||||||
*/
|
|
||||||
setName(name, reason) {
|
|
||||||
return this.edit({ name }, reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a role to the list of roles that can use this emoji.
|
|
||||||
* @param {Role} role The role to add
|
|
||||||
* @returns {Promise<Emoji>}
|
|
||||||
*/
|
|
||||||
addRestrictedRole(role) {
|
|
||||||
return this.addRestrictedRoles([role]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add multiple roles to the list of roles that can use this emoji.
|
|
||||||
* @param {Collection<Snowflake, Role>|RoleResolvable[]} roles Roles to add
|
|
||||||
* @returns {Promise<Emoji>}
|
|
||||||
*/
|
|
||||||
addRestrictedRoles(roles) {
|
|
||||||
const newRoles = new Collection(this.roles);
|
|
||||||
for (let role of roles instanceof Collection ? roles.values() : roles) {
|
|
||||||
role = this.client.resolver.resolveRole(this.guild, role);
|
|
||||||
if (!role) {
|
|
||||||
return Promise.reject(new TypeError('INVALID_TYPE', 'roles',
|
|
||||||
'Array or Collection of Roles or Snowflakes', true));
|
|
||||||
}
|
|
||||||
newRoles.set(role.id, role);
|
|
||||||
}
|
|
||||||
return this.edit({ roles: newRoles });
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove a role from the list of roles that can use this emoji.
|
|
||||||
* @param {Role} role The role to remove
|
|
||||||
* @returns {Promise<Emoji>}
|
|
||||||
*/
|
|
||||||
removeRestrictedRole(role) {
|
|
||||||
return this.removeRestrictedRoles([role]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove multiple roles from the list of roles that can use this emoji.
|
|
||||||
* @param {Collection<Snowflake, Role>|RoleResolvable[]} roles Roles to remove
|
|
||||||
* @returns {Promise<Emoji>}
|
|
||||||
*/
|
|
||||||
removeRestrictedRoles(roles) {
|
|
||||||
const newRoles = new Collection(this.roles);
|
|
||||||
for (let role of roles instanceof Collection ? roles.values() : roles) {
|
|
||||||
role = this.client.resolver.resolveRole(this.guild, role);
|
|
||||||
if (!role) {
|
|
||||||
return Promise.reject(new TypeError('INVALID_TYPE', 'roles',
|
|
||||||
'Array or Collection of Roles or Snowflakes', true));
|
|
||||||
}
|
|
||||||
if (newRoles.has(role.id)) newRoles.delete(role.id);
|
|
||||||
}
|
|
||||||
return this.edit({ roles: newRoles });
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* When concatenated with a string, this automatically returns the emoji mention rather than the object.
|
|
||||||
* @returns {string}
|
|
||||||
* @example
|
|
||||||
* // Send an emoji:
|
|
||||||
* const emoji = guild.emojis.first();
|
|
||||||
* msg.reply(`Hello! ${emoji}`);
|
|
||||||
*/
|
|
||||||
toString() {
|
|
||||||
return this.requiresColons ? `<:${this.name}:${this.id}>` : this.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether this emoji is the same as another one.
|
|
||||||
* @param {Emoji|Object} other The emoji to compare it to
|
|
||||||
* @returns {boolean} Whether the emoji is equal to the given emoji or not
|
|
||||||
*/
|
|
||||||
equals(other) {
|
|
||||||
if (other instanceof Emoji) {
|
|
||||||
return (
|
|
||||||
other.id === this.id &&
|
|
||||||
other.name === this.name &&
|
|
||||||
other.managed === this.managed &&
|
|
||||||
other.requiresColons === this.requiresColons &&
|
|
||||||
other._roles === this._roles
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return (
|
|
||||||
other.id === this.id &&
|
|
||||||
other.name === this.name &&
|
|
||||||
other._roles === this._roles
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = Emoji;
|
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
/* 30 */
|
|
||||||
/***/ (function(module, exports, __webpack_require__) {
|
|
||||||
|
|
||||||
const Channel = __webpack_require__(16);
|
const Channel = __webpack_require__(16);
|
||||||
const Role = __webpack_require__(19);
|
const Role = __webpack_require__(19);
|
||||||
const Invite = __webpack_require__(36);
|
const Invite = __webpack_require__(36);
|
||||||
|
|
@ -9745,7 +9503,7 @@ module.exports = GuildChannel;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
/* 31 */
|
/* 30 */
|
||||||
/***/ (function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
@ -9796,13 +9554,13 @@ function nextTick(fn, arg1, arg2, arg3) {
|
||||||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8)))
|
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8)))
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
/* 32 */
|
/* 31 */
|
||||||
/***/ (function(module, exports) {
|
/***/ (function(module, exports) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
/* 33 */
|
/* 32 */
|
||||||
/***/ (function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
const DataStore = __webpack_require__(11);
|
const DataStore = __webpack_require__(11);
|
||||||
|
|
@ -9905,7 +9663,7 @@ module.exports = MessageStore;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
/* 34 */
|
/* 33 */
|
||||||
/***/ (function(module, exports) {
|
/***/ (function(module, exports) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -9984,6 +9742,249 @@ class Attachment {
|
||||||
module.exports = Attachment;
|
module.exports = Attachment;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
/* 34 */
|
||||||
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
|
const Collection = __webpack_require__(3);
|
||||||
|
const Snowflake = __webpack_require__(9);
|
||||||
|
const Base = __webpack_require__(10);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a custom emoji.
|
||||||
|
* @extends {Base}
|
||||||
|
*/
|
||||||
|
class Emoji extends Base {
|
||||||
|
constructor(guild, data) {
|
||||||
|
super(guild.client);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The guild this emoji is part of
|
||||||
|
* @type {Guild}
|
||||||
|
*/
|
||||||
|
this.guild = guild;
|
||||||
|
|
||||||
|
this._patch(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
_patch(data) {
|
||||||
|
/**
|
||||||
|
* The ID of the emoji
|
||||||
|
* @type {Snowflake}
|
||||||
|
*/
|
||||||
|
this.id = data.id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the emoji
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
this.name = data.name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not this emoji requires colons surrounding it
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
this.requiresColons = data.require_colons;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this emoji is managed by an external service
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
this.managed = data.managed;
|
||||||
|
|
||||||
|
this._roles = data.roles;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The timestamp the emoji was created at
|
||||||
|
* @type {number}
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
|
get createdTimestamp() {
|
||||||
|
return Snowflake.deconstruct(this.id).timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The time the emoji was created
|
||||||
|
* @type {Date}
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
|
get createdAt() {
|
||||||
|
return new Date(this.createdTimestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A collection of roles this emoji is active for (empty if all), mapped by role ID
|
||||||
|
* @type {Collection<Snowflake, Role>}
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
|
get roles() {
|
||||||
|
const roles = new Collection();
|
||||||
|
for (const role of this._roles) {
|
||||||
|
if (this.guild.roles.has(role)) roles.set(role, this.guild.roles.get(role));
|
||||||
|
}
|
||||||
|
return roles;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The URL to the emoji file
|
||||||
|
* @type {string}
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
|
get url() {
|
||||||
|
return this.client.rest.cdn.Emoji(this.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The identifier of this emoji, used for message reactions
|
||||||
|
* @type {string}
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
|
get identifier() {
|
||||||
|
if (this.id) return `${this.name}:${this.id}`;
|
||||||
|
return encodeURIComponent(this.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data for editing an emoji.
|
||||||
|
* @typedef {Object} EmojiEditData
|
||||||
|
* @property {string} [name] The name of the emoji
|
||||||
|
* @property {Collection<Snowflake, Role>|RoleResolvable[]} [roles] Roles to restrict emoji to
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edits the emoji.
|
||||||
|
* @param {EmojiEditData} data The new data for the emoji
|
||||||
|
* @param {string} [reason] Reason for editing this emoji
|
||||||
|
* @returns {Promise<Emoji>}
|
||||||
|
* @example
|
||||||
|
* // Edit an emoji
|
||||||
|
* emoji.edit({name: 'newemoji'})
|
||||||
|
* .then(e => console.log(`Edited emoji ${e}`))
|
||||||
|
* .catch(console.error);
|
||||||
|
*/
|
||||||
|
edit(data, reason) {
|
||||||
|
return this.client.api.guilds(this.guild.id).emojis(this.id)
|
||||||
|
.patch({ data: {
|
||||||
|
name: data.name,
|
||||||
|
roles: data.roles ? data.roles.map(r => r.id ? r.id : r) : undefined,
|
||||||
|
}, reason })
|
||||||
|
.then(() => this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the name of the emoji.
|
||||||
|
* @param {string} name The new name for the emoji
|
||||||
|
* @param {string} [reason] Reason for changing the emoji's name
|
||||||
|
* @returns {Promise<Emoji>}
|
||||||
|
*/
|
||||||
|
setName(name, reason) {
|
||||||
|
return this.edit({ name }, reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a role to the list of roles that can use this emoji.
|
||||||
|
* @param {Role} role The role to add
|
||||||
|
* @returns {Promise<Emoji>}
|
||||||
|
*/
|
||||||
|
addRestrictedRole(role) {
|
||||||
|
return this.addRestrictedRoles([role]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add multiple roles to the list of roles that can use this emoji.
|
||||||
|
* @param {Collection<Snowflake, Role>|RoleResolvable[]} roles Roles to add
|
||||||
|
* @returns {Promise<Emoji>}
|
||||||
|
*/
|
||||||
|
addRestrictedRoles(roles) {
|
||||||
|
const newRoles = new Collection(this.roles);
|
||||||
|
for (let role of roles instanceof Collection ? roles.values() : roles) {
|
||||||
|
role = this.client.resolver.resolveRole(this.guild, role);
|
||||||
|
if (!role) {
|
||||||
|
return Promise.reject(new TypeError('INVALID_TYPE', 'roles',
|
||||||
|
'Array or Collection of Roles or Snowflakes', true));
|
||||||
|
}
|
||||||
|
newRoles.set(role.id, role);
|
||||||
|
}
|
||||||
|
return this.edit({ roles: newRoles });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a role from the list of roles that can use this emoji.
|
||||||
|
* @param {Role} role The role to remove
|
||||||
|
* @returns {Promise<Emoji>}
|
||||||
|
*/
|
||||||
|
removeRestrictedRole(role) {
|
||||||
|
return this.removeRestrictedRoles([role]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove multiple roles from the list of roles that can use this emoji.
|
||||||
|
* @param {Collection<Snowflake, Role>|RoleResolvable[]} roles Roles to remove
|
||||||
|
* @returns {Promise<Emoji>}
|
||||||
|
*/
|
||||||
|
removeRestrictedRoles(roles) {
|
||||||
|
const newRoles = new Collection(this.roles);
|
||||||
|
for (let role of roles instanceof Collection ? roles.values() : roles) {
|
||||||
|
role = this.client.resolver.resolveRole(this.guild, role);
|
||||||
|
if (!role) {
|
||||||
|
return Promise.reject(new TypeError('INVALID_TYPE', 'roles',
|
||||||
|
'Array or Collection of Roles or Snowflakes', true));
|
||||||
|
}
|
||||||
|
if (newRoles.has(role.id)) newRoles.delete(role.id);
|
||||||
|
}
|
||||||
|
return this.edit({ roles: newRoles });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When concatenated with a string, this automatically returns the emoji mention rather than the object.
|
||||||
|
* @returns {string}
|
||||||
|
* @example
|
||||||
|
* // Send an emoji:
|
||||||
|
* const emoji = guild.emojis.first();
|
||||||
|
* msg.reply(`Hello! ${emoji}`);
|
||||||
|
*/
|
||||||
|
toString() {
|
||||||
|
return this.requiresColons ? `<:${this.name}:${this.id}>` : this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete the emoji.
|
||||||
|
* @param {string} [reason] Reason for deleting the emoji
|
||||||
|
* @returns {Promise<Emoji>}
|
||||||
|
*/
|
||||||
|
delete(reason) {
|
||||||
|
return this.client.api.guilds(this.guild.id).emojis(this.id).delete({ reason })
|
||||||
|
.then(() => this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this emoji is the same as another one.
|
||||||
|
* @param {Emoji|Object} other The emoji to compare it to
|
||||||
|
* @returns {boolean} Whether the emoji is equal to the given emoji or not
|
||||||
|
*/
|
||||||
|
equals(other) {
|
||||||
|
if (other instanceof Emoji) {
|
||||||
|
return (
|
||||||
|
other.id === this.id &&
|
||||||
|
other.name === this.name &&
|
||||||
|
other.managed === this.managed &&
|
||||||
|
other.requiresColons === this.requiresColons &&
|
||||||
|
other._roles === this._roles
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
other.id === this.id &&
|
||||||
|
other.name === this.name &&
|
||||||
|
other._roles === this._roles
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = Emoji;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
/* 35 */
|
/* 35 */
|
||||||
/***/ (function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
@ -9991,7 +9992,7 @@ module.exports = Attachment;
|
||||||
const Channel = __webpack_require__(16);
|
const Channel = __webpack_require__(16);
|
||||||
const TextBasedChannel = __webpack_require__(28);
|
const TextBasedChannel = __webpack_require__(28);
|
||||||
const Collection = __webpack_require__(3);
|
const Collection = __webpack_require__(3);
|
||||||
const MessageStore = __webpack_require__(33);
|
const MessageStore = __webpack_require__(32);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
{ type: 3,
|
{ type: 3,
|
||||||
|
|
@ -10633,7 +10634,7 @@ SafeBuffer.allocUnsafeSlow = function (size) {
|
||||||
|
|
||||||
/*<replacement>*/
|
/*<replacement>*/
|
||||||
|
|
||||||
var processNextTick = __webpack_require__(31);
|
var processNextTick = __webpack_require__(30);
|
||||||
/*</replacement>*/
|
/*</replacement>*/
|
||||||
|
|
||||||
module.exports = Writable;
|
module.exports = Writable;
|
||||||
|
|
@ -13312,7 +13313,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
||||||
|
|
||||||
const Channel = __webpack_require__(16);
|
const Channel = __webpack_require__(16);
|
||||||
const TextBasedChannel = __webpack_require__(28);
|
const TextBasedChannel = __webpack_require__(28);
|
||||||
const MessageStore = __webpack_require__(33);
|
const MessageStore = __webpack_require__(32);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a direct message channel between two users.
|
* Represents a direct message channel between two users.
|
||||||
|
|
@ -13372,7 +13373,7 @@ module.exports = DMChannel;
|
||||||
/***/ (function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
const Collection = __webpack_require__(3);
|
const Collection = __webpack_require__(3);
|
||||||
const Emoji = __webpack_require__(29);
|
const Emoji = __webpack_require__(34);
|
||||||
const ReactionEmoji = __webpack_require__(47);
|
const ReactionEmoji = __webpack_require__(47);
|
||||||
const { Error } = __webpack_require__(4);
|
const { Error } = __webpack_require__(4);
|
||||||
|
|
||||||
|
|
@ -13764,11 +13765,11 @@ module.exports = ClientApplication;
|
||||||
/* 49 */
|
/* 49 */
|
||||||
/***/ (function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
const GuildChannel = __webpack_require__(30);
|
const GuildChannel = __webpack_require__(29);
|
||||||
const Webhook = __webpack_require__(23);
|
const Webhook = __webpack_require__(23);
|
||||||
const TextBasedChannel = __webpack_require__(28);
|
const TextBasedChannel = __webpack_require__(28);
|
||||||
const Collection = __webpack_require__(3);
|
const Collection = __webpack_require__(3);
|
||||||
const MessageStore = __webpack_require__(33);
|
const MessageStore = __webpack_require__(32);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a guild text channel on Discord.
|
* Represents a guild text channel on Discord.
|
||||||
|
|
@ -13859,7 +13860,7 @@ module.exports = TextChannel;
|
||||||
/* 50 */
|
/* 50 */
|
||||||
/***/ (function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
const GuildChannel = __webpack_require__(30);
|
const GuildChannel = __webpack_require__(29);
|
||||||
const Collection = __webpack_require__(3);
|
const Collection = __webpack_require__(3);
|
||||||
const { Error } = __webpack_require__(4);
|
const { Error } = __webpack_require__(4);
|
||||||
|
|
||||||
|
|
@ -14036,7 +14037,7 @@ module.exports = Array.isArray || function (arr) {
|
||||||
|
|
||||||
/*<replacement>*/
|
/*<replacement>*/
|
||||||
|
|
||||||
var processNextTick = __webpack_require__(31);
|
var processNextTick = __webpack_require__(30);
|
||||||
/*</replacement>*/
|
/*</replacement>*/
|
||||||
|
|
||||||
module.exports = Readable;
|
module.exports = Readable;
|
||||||
|
|
@ -15036,7 +15037,7 @@ module.exports = __webpack_require__(13).EventEmitter;
|
||||||
|
|
||||||
/*<replacement>*/
|
/*<replacement>*/
|
||||||
|
|
||||||
var processNextTick = __webpack_require__(31);
|
var processNextTick = __webpack_require__(30);
|
||||||
/*</replacement>*/
|
/*</replacement>*/
|
||||||
|
|
||||||
// undocumented cb() API, needed for core, not for public API
|
// undocumented cb() API, needed for core, not for public API
|
||||||
|
|
@ -16683,7 +16684,7 @@ module.exports = DiscordAPIError;
|
||||||
/* WEBPACK VAR INJECTION */(function(Buffer) {const browser = typeof window !== 'undefined';
|
/* WEBPACK VAR INJECTION */(function(Buffer) {const browser = typeof window !== 'undefined';
|
||||||
const EventEmitter = __webpack_require__(13);
|
const EventEmitter = __webpack_require__(13);
|
||||||
const Constants = __webpack_require__(0);
|
const Constants = __webpack_require__(0);
|
||||||
const zlib = __webpack_require__(32);
|
const zlib = __webpack_require__(31);
|
||||||
const PacketManager = __webpack_require__(123);
|
const PacketManager = __webpack_require__(123);
|
||||||
const erlpack = (function findErlpack() {
|
const erlpack = (function findErlpack() {
|
||||||
try {
|
try {
|
||||||
|
|
@ -18527,7 +18528,7 @@ module.exports = ClientUserSettings;
|
||||||
/***/ (function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
/* WEBPACK VAR INJECTION */(function(Buffer) {const path = __webpack_require__(26);
|
/* WEBPACK VAR INJECTION */(function(Buffer) {const path = __webpack_require__(26);
|
||||||
const fs = __webpack_require__(32);
|
const fs = __webpack_require__(31);
|
||||||
const snekfetch = __webpack_require__(37);
|
const snekfetch = __webpack_require__(37);
|
||||||
|
|
||||||
const Util = __webpack_require__(6);
|
const Util = __webpack_require__(6);
|
||||||
|
|
@ -18537,7 +18538,7 @@ const Guild = __webpack_require__(22);
|
||||||
const Channel = __webpack_require__(16);
|
const Channel = __webpack_require__(16);
|
||||||
const GuildMember = __webpack_require__(18);
|
const GuildMember = __webpack_require__(18);
|
||||||
const Role = __webpack_require__(19);
|
const Role = __webpack_require__(19);
|
||||||
const Emoji = __webpack_require__(29);
|
const Emoji = __webpack_require__(34);
|
||||||
const ReactionEmoji = __webpack_require__(47);
|
const ReactionEmoji = __webpack_require__(47);
|
||||||
const { Error, TypeError } = __webpack_require__(4);
|
const { Error, TypeError } = __webpack_require__(4);
|
||||||
|
|
||||||
|
|
@ -18859,17 +18860,17 @@ module.exports = {
|
||||||
|
|
||||||
// Structures
|
// Structures
|
||||||
Activity: __webpack_require__(20).Activity,
|
Activity: __webpack_require__(20).Activity,
|
||||||
Attachment: __webpack_require__(34),
|
Attachment: __webpack_require__(33),
|
||||||
Channel: __webpack_require__(16),
|
Channel: __webpack_require__(16),
|
||||||
ClientUser: __webpack_require__(66),
|
ClientUser: __webpack_require__(66),
|
||||||
ClientUserSettings: __webpack_require__(76),
|
ClientUserSettings: __webpack_require__(76),
|
||||||
Collector: __webpack_require__(43),
|
Collector: __webpack_require__(43),
|
||||||
DMChannel: __webpack_require__(45),
|
DMChannel: __webpack_require__(45),
|
||||||
Emoji: __webpack_require__(29),
|
Emoji: __webpack_require__(34),
|
||||||
GroupDMChannel: __webpack_require__(35),
|
GroupDMChannel: __webpack_require__(35),
|
||||||
Guild: __webpack_require__(22),
|
Guild: __webpack_require__(22),
|
||||||
GuildAuditLogs: __webpack_require__(72),
|
GuildAuditLogs: __webpack_require__(72),
|
||||||
GuildChannel: __webpack_require__(30),
|
GuildChannel: __webpack_require__(29),
|
||||||
GuildMember: __webpack_require__(18),
|
GuildMember: __webpack_require__(18),
|
||||||
Invite: __webpack_require__(36),
|
Invite: __webpack_require__(36),
|
||||||
Message: __webpack_require__(17),
|
Message: __webpack_require__(17),
|
||||||
|
|
@ -19107,7 +19108,7 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
|
||||||
/***/ (function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
/* WEBPACK VAR INJECTION */(function(Buffer) {__webpack_require__(38);
|
/* WEBPACK VAR INJECTION */(function(Buffer) {__webpack_require__(38);
|
||||||
const zlib = __webpack_require__(32);
|
const zlib = __webpack_require__(31);
|
||||||
const qs = __webpack_require__(41);
|
const qs = __webpack_require__(41);
|
||||||
const http = __webpack_require__(57);
|
const http = __webpack_require__(57);
|
||||||
const https = __webpack_require__(103);
|
const https = __webpack_require__(103);
|
||||||
|
|
@ -21969,7 +21970,7 @@ module.exports = mimeOfBuffer;
|
||||||
/* 108 */
|
/* 108 */
|
||||||
/***/ (function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
const fs = __webpack_require__(32);
|
const fs = __webpack_require__(31);
|
||||||
const path = __webpack_require__(26);
|
const path = __webpack_require__(26);
|
||||||
const mime = __webpack_require__(60);
|
const mime = __webpack_require__(60);
|
||||||
const EventEmitter = __webpack_require__(13);
|
const EventEmitter = __webpack_require__(13);
|
||||||
|
|
@ -24177,7 +24178,7 @@ module.exports = RoleStore;
|
||||||
/***/ (function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
const DataStore = __webpack_require__(11);
|
const DataStore = __webpack_require__(11);
|
||||||
const Emoji = __webpack_require__(29);
|
const Emoji = __webpack_require__(34);
|
||||||
/**
|
/**
|
||||||
* Stores emojis.
|
* Stores emojis.
|
||||||
* @private
|
* @private
|
||||||
|
|
|
||||||
2
discord.master.min.js
vendored
2
discord.master.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue