mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 08:33:30 +01:00
Merge branch 'master' of https://github.com/hydrabolt/discord.js
This commit is contained in:
@@ -29,11 +29,9 @@ class GuildMemberRoleStore extends DataStore {
|
||||
if (roleOrRoles.includes(null)) {
|
||||
return Promise.reject(new TypeError('INVALID_TYPE', 'roles',
|
||||
'Array or Collection of Roles or Snowflakes', true));
|
||||
} else {
|
||||
for (const role of roleOrRoles) super.set(role.id, role);
|
||||
}
|
||||
|
||||
return this.set(this, reason);
|
||||
const newRoles = [...new Set(roleOrRoles.concat(this.array()))];
|
||||
return this.set(newRoles, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,11 +69,9 @@ class GuildMemberRoleStore extends DataStore {
|
||||
if (roleOrRoles.includes(null)) {
|
||||
return Promise.reject(new TypeError('INVALID_TYPE', 'roles',
|
||||
'Array or Collection of Roles or Snowflakes', true));
|
||||
} else {
|
||||
for (const role of roleOrRoles) super.remove(role);
|
||||
}
|
||||
|
||||
return this.set(this, reason);
|
||||
const newRoles = this.keyArray().filter(role => !roleOrRoles.includes(role));
|
||||
return this.set(newRoles, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -132,8 +132,8 @@ class Role extends Base {
|
||||
/**
|
||||
* Compares this role's position to another role's.
|
||||
* @param {RoleResolvable} role Role to compare to this one
|
||||
* @returns {number} Negative number if the this role's position is lower (other role's is higher),
|
||||
* positive number if the this one is higher (other's is lower), 0 if equal
|
||||
* @returns {number} Negative number if this role's position is lower (other role's is higher),
|
||||
* positive number if this one is higher (other's is lower), 0 if equal
|
||||
*/
|
||||
comparePositionTo(role) {
|
||||
role = this.guild.roles.resolve(role);
|
||||
|
||||
@@ -55,6 +55,11 @@ class TextChannel extends GuildChannel {
|
||||
/**
|
||||
* Fetches all webhooks for the channel.
|
||||
* @returns {Promise<Collection<Snowflake, Webhook>>}
|
||||
* @example
|
||||
* // Fetch webhooks
|
||||
* channel.fetchWebhooks()
|
||||
* .then(hooks => console.log(`This channel has ${hooks.size} hooks`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
fetchWebhooks() {
|
||||
return this.client.api.channels[this.id].webhooks.get().then(data => {
|
||||
@@ -72,8 +77,12 @@ class TextChannel extends GuildChannel {
|
||||
* @param {string} [options.reason] Reason for creating the webhook
|
||||
* @returns {Promise<Webhook>} webhook The created webhook
|
||||
* @example
|
||||
* channel.createWebhook('Snek', 'https://i.imgur.com/mI8XcpG.jpg')
|
||||
* .then(webhook => console.log(`Created webhook ${webhook}`))
|
||||
* // Create a webhook for the current channel
|
||||
* channel.createWebhook('Snek', {
|
||||
* avatar: 'https://i.imgur.com/mI8XcpG.jpg',
|
||||
* reason: 'Needed a cool new Webhook'
|
||||
* })
|
||||
* .then(console.log)
|
||||
* .catch(console.error)
|
||||
*/
|
||||
async createWebhook(name, { avatar, reason } = {}) {
|
||||
|
||||
Reference in New Issue
Block a user