mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Add role mentioning (#385)
* Add role mentioning * Add to docs * Forgot to save again
This commit is contained in:
committed by
abalabahaha
parent
95e3e3e3dc
commit
b4dcd657cf
@@ -70,4 +70,9 @@ Sees whether the role has the permission given.
|
|||||||
colorAsHex()
|
colorAsHex()
|
||||||
~~~~~~~~~~~~
|
~~~~~~~~~~~~
|
||||||
|
|
||||||
Returns the role's colour as hex, e.g. ``#FF0000``.
|
Returns the role's colour as hex, e.g. ``#FF0000``.
|
||||||
|
|
||||||
|
mention()
|
||||||
|
~~~~~~~~~
|
||||||
|
|
||||||
|
Returns a valid string that can be sent in a message to mention the role. By default, ``role.toString()`` does this so by adding a role object to a string, e.g. ``role + ""``, their mention code will be retrieved. If the role isn't mentionable, its name gets returned.
|
||||||
@@ -166,6 +166,15 @@ var Role = (function () {
|
|||||||
return this.client.removeUserFromRole.apply(this.client, [member, this, callback]);
|
return this.client.removeUserFromRole.apply(this.client, [member, this, callback]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Role.prototype.mention = function mention() {
|
||||||
|
if (this.mentionable) return "<@&" + this.id + ">";
|
||||||
|
return this.name;
|
||||||
|
};
|
||||||
|
|
||||||
|
Role.prototype.toString = function toString() {
|
||||||
|
return this.mention();
|
||||||
|
};
|
||||||
|
|
||||||
return Role;
|
return Role;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|||||||
@@ -160,4 +160,14 @@ export default class Role {
|
|||||||
removeUser(member, callback) {
|
removeUser(member, callback) {
|
||||||
return this.client.removeUserFromRole.apply(this.client, [member, this, callback]);
|
return this.client.removeUserFromRole.apply(this.client, [member, this, callback]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mention(){
|
||||||
|
if(this.mentionable)
|
||||||
|
return `<@&${this.id}>`;
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
toString(){
|
||||||
|
return this.mention();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user