mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 17:13:31 +01:00
Moved all error strings to src/errors/messages and a few other things (#1695)
* Added missing error messages As well as `Guild#setRolePosition` and `Guild#setChannelPosition`'s first arg validation And fixed a typo in `Guild#setChannelPosition` `roles` -> `channels` * Reverted collection and Util constructors * Removed leftover messages Should have been in the second commit. * It's a single invalid permission and removed unused flag error * Fix INVALID_TOKEN -> TOKEN_INVALID as of #1703
This commit is contained in:
@@ -3,7 +3,7 @@ const Role = require('./Role');
|
||||
const Permissions = require('../util/Permissions');
|
||||
const Collection = require('../util/Collection');
|
||||
const { Presence } = require('./Presence');
|
||||
const { Error } = require('../errors');
|
||||
const { Error, TypeError } = require('../errors');
|
||||
|
||||
/**
|
||||
* Represents a member of a guild on Discord.
|
||||
@@ -396,7 +396,7 @@ class GuildMember {
|
||||
*/
|
||||
addRole(role) {
|
||||
if (!(role instanceof Role)) role = this.guild.roles.get(role);
|
||||
if (!role) return Promise.reject(new TypeError('Supplied parameter was neither a Role nor a Snowflake.'));
|
||||
if (!role) return Promise.reject(new TypeError('INVALID_TYPE', 'role', 'Role nor a Snowflake'));
|
||||
if (this._roles.includes(role.id)) return Promise.resolve(this);
|
||||
return this.client.api.guilds[this.guild.id].members[this.user.id].roles[role.id]
|
||||
.put()
|
||||
@@ -426,7 +426,7 @@ class GuildMember {
|
||||
*/
|
||||
removeRole(role) {
|
||||
if (!(role instanceof Role)) role = this.guild.roles.get(role);
|
||||
if (!role) return Promise.reject(new TypeError('Supplied parameter was neither a Role nor a Snowflake.'));
|
||||
if (!role) return Promise.reject(new TypeError('INVALID_TYPE', 'role', 'Role nor a Snowflake'));
|
||||
return this.client.api.guilds[this.guild.id].members[this.user.id].roles[role.id]
|
||||
.delete()
|
||||
.then(() => this);
|
||||
|
||||
Reference in New Issue
Block a user