mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 00:53:31 +01:00
Move all util methods into class
Remove TransformMessageOptions altogether
This commit is contained in:
@@ -5,9 +5,7 @@ const Presence = require('./Presence').Presence;
|
||||
const GuildMember = require('./GuildMember');
|
||||
const Constants = require('../util/Constants');
|
||||
const Collection = require('../util/Collection');
|
||||
const cloneObject = require('../util/CloneObject');
|
||||
const arraysEqual = require('../util/ArraysEqual');
|
||||
const moveElementInArray = require('../util/MoveElementInArray');
|
||||
const Util = require('../util/Util');
|
||||
|
||||
/**
|
||||
* Represents a guild (or a server) on Discord.
|
||||
@@ -681,7 +679,7 @@ class Guild {
|
||||
let updatedRoles = Object.assign([], this.roles.array()
|
||||
.sort((r1, r2) => r1.position !== r2.position ? r1.position - r2.position : r1.id - r2.id));
|
||||
|
||||
moveElementInArray(updatedRoles, role, position, relative);
|
||||
Util.moveElementInArray(updatedRoles, role, position, relative);
|
||||
|
||||
updatedRoles = updatedRoles.map((r, i) => ({ id: r.id, position: i }));
|
||||
return this.client.rest.methods.setRolePositions(this.id, updatedRoles);
|
||||
@@ -771,7 +769,7 @@ class Guild {
|
||||
this.memberCount === guild.member_count &&
|
||||
this.large === guild.large &&
|
||||
this.icon === guild.icon &&
|
||||
arraysEqual(this.features, guild.features) &&
|
||||
Util.arraysEqual(this.features, guild.features) &&
|
||||
this.ownerID === guild.owner_id &&
|
||||
this.verificationLevel === guild.verification_level &&
|
||||
this.embedEnabled === guild.embed_enabled;
|
||||
@@ -837,12 +835,12 @@ class Guild {
|
||||
}
|
||||
|
||||
_updateMember(member, data) {
|
||||
const oldMember = cloneObject(member);
|
||||
const oldMember = Util.cloneObject(member);
|
||||
|
||||
if (data.roles) member._roles = data.roles;
|
||||
if (typeof data.nick !== 'undefined') member.nickname = data.nick;
|
||||
|
||||
const notSame = member.nickname !== oldMember.nickname || !arraysEqual(member._roles, oldMember._roles);
|
||||
const notSame = member.nickname !== oldMember.nickname || !Util.arraysEqual(member._roles, oldMember._roles);
|
||||
|
||||
if (this.client.ws.status === Constants.Status.READY && notSame) {
|
||||
/**
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
const Attachment = require('./MessageAttachment');
|
||||
const Embed = require('./MessageEmbed');
|
||||
const MessageReaction = require('./MessageReaction');
|
||||
const Util = require('../util/Util');
|
||||
const Collection = require('../util/Collection');
|
||||
const Constants = require('../util/Constants');
|
||||
const escapeMarkdown = require('../util/EscapeMarkdown');
|
||||
let GuildMember;
|
||||
|
||||
/**
|
||||
@@ -409,7 +409,7 @@ class Message {
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
editCode(lang, content) {
|
||||
content = escapeMarkdown(this.client.resolver.resolveString(content), true);
|
||||
content = Util.escapeMarkdown(this.client.resolver.resolveString(content), true);
|
||||
return this.edit(`\`\`\`${lang || ''}\n${content}\n\`\`\``);
|
||||
}
|
||||
|
||||
|
||||
@@ -223,6 +223,33 @@ class TextBasedChannel {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {Object} MessageSearchOptions
|
||||
* @property {string} [content] Message content
|
||||
* @property {string} [maxID] Maximum ID for the filter
|
||||
* @property {string} [minID] Minimum ID for the filter
|
||||
* @property {string} [has] One of `link`, `embed`, `file`, `video`, `image`, or `sound`,
|
||||
* or add `-` to negate (e.g. `-file`)
|
||||
* @property {ChannelResolvable} [channel] Channel to limit search to (only for guild search endpoint)
|
||||
* @property {UserResolvable} [author] Author to limit search
|
||||
* @property {string} [authorType] One of `user`, `bot`, `webhook`, or add `-` to negate (e.g. `-webhook`)
|
||||
* @property {string} [sortBy='recent'] `recent` or `relevant`
|
||||
* @property {string} [sortOrder='desc'] `asc` or `desc`
|
||||
* @property {number} [contextSize=2] How many messages to get around the matched message (0 to 2)
|
||||
* @property {number} [limit=25] Maximum number of results to get (1 to 25)
|
||||
* @property {number} [offset=0] Offset the "pages" of results (since you can only see 25 at a time)
|
||||
* @property {UserResolvable} [mentions] Mentioned user filter
|
||||
* @property {boolean} [mentionsEveryone] If everyone is mentioned
|
||||
* @property {string} [linkHostname] Filter links by hostname
|
||||
* @property {string} [embedProvider] The name of an embed provider
|
||||
* @property {string} [embedType] one of `image`, `video`, `url`, `rich`
|
||||
* @property {string} [attachmentFilename] The name of an attachment
|
||||
* @property {string} [attachmentExtension] The extension of an attachment
|
||||
* @property {Date} [before] Date to find messages before
|
||||
* @property {Date} [after] Date to find messages before
|
||||
* @property {Date} [during] Date to find messages during (range of date to date + 24 hours)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Performs a search within the channel.
|
||||
* @param {MessageSearchOptions} [options={}] Options to pass to the search
|
||||
|
||||
Reference in New Issue
Block a user