mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Move around mentions and stuff
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -1,6 +1,7 @@
|
||||
const DocumentedItem = require('./DocumentedItem');
|
||||
const DocumentedItemMeta = require('./DocumentedItemMeta');
|
||||
const DocumentedVarType = require('./DocumentedVarType');
|
||||
const DocumentedParam = require('./DocumentedParam');
|
||||
|
||||
/*
|
||||
{ id: 'Client#rest',
|
||||
@@ -26,11 +27,20 @@ class DocumentedMember extends DocumentedItem {
|
||||
this.directData = data;
|
||||
this.directData.meta = new DocumentedItemMeta(this, data.meta);
|
||||
this.directData.type = new DocumentedVarType(this, data.type);
|
||||
if (data.properties) {
|
||||
const newProps = [];
|
||||
for (const param of data.properties) {
|
||||
newProps.push(new DocumentedParam(this, param));
|
||||
}
|
||||
this.directData.properties = newProps;
|
||||
} else {
|
||||
data.properties = [];
|
||||
}
|
||||
}
|
||||
|
||||
serialize() {
|
||||
super.serialize();
|
||||
const { id, name, description, memberof, type, access, meta } = this.directData;
|
||||
const { id, name, description, memberof, type, access, meta, properties } = this.directData;
|
||||
return {
|
||||
id,
|
||||
name,
|
||||
@@ -39,6 +49,7 @@ class DocumentedMember extends DocumentedItem {
|
||||
type: type.serialize(),
|
||||
access,
|
||||
meta: meta.serialize(),
|
||||
props: properties.map(p => p.serialize()),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -79,28 +79,37 @@ class Message {
|
||||
*/
|
||||
this.attachments = data.attachments;
|
||||
/**
|
||||
* A map of users mentioned in the message, the key is the user ID.
|
||||
* @type {Map<String, User>}
|
||||
* An object containing a further users or roles map
|
||||
* @type {Object}
|
||||
* @property {Map<String, User>} mentions.users Mentioned users, maps their ID to the user object.
|
||||
* @property {Map<String, Role>} mentions.roles Mentioned roles, maps their ID to the role object.
|
||||
*/
|
||||
this.mentions = new Map();
|
||||
this.mentions = {
|
||||
users: new Map(),
|
||||
roles: new Map(),
|
||||
};
|
||||
/**
|
||||
* The ID of the message (unique in the channel it was sent)
|
||||
* @type {String}
|
||||
*/
|
||||
this.id = data.id;
|
||||
/**
|
||||
* A map of roles mentioned in the message, the key is the role ID.
|
||||
* @type {Map<String, Role>}
|
||||
*/
|
||||
this.roleMentions = new Map();
|
||||
|
||||
for (const mention of data.mentions) {
|
||||
let user = this.client.users.get(mention.id);
|
||||
if (user) {
|
||||
this.mentions.set(user.id, user);
|
||||
this.mentions.users.set(user.id, user);
|
||||
} else {
|
||||
user = this.client.dataManager.newUser(mention);
|
||||
this.mentions.set(user.id, user);
|
||||
this.mentions.users.set(user.id, user);
|
||||
}
|
||||
}
|
||||
|
||||
if (data.mention_roles) {
|
||||
for (const mention of data.mention_roles) {
|
||||
const role = this.channel.guild.roles.get(mention);
|
||||
if (role) {
|
||||
this.mentions.roles.set(role.id, role);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -137,14 +146,21 @@ class Message {
|
||||
for (const mention of data.mentions) {
|
||||
let user = this.client.users.get(mention.id);
|
||||
if (user) {
|
||||
this.mentions.set(user.id, user);
|
||||
this.mentions.users.set(user.id, user);
|
||||
} else {
|
||||
user = this.client.dataManager.newUser(mention);
|
||||
this.mentions.set(user.id, user);
|
||||
this.mentions.users.set(user.id, user);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (data.mention_roles) {
|
||||
for (const mention of data.mention_roles) {
|
||||
const role = this.channel.guild.roles.get(mention);
|
||||
if (role) {
|
||||
this.mentions.roles.set(role.id, role);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (data.id) {
|
||||
this.id = data.id;
|
||||
}
|
||||
|
||||
@@ -213,6 +213,14 @@ class Role {
|
||||
|
||||
return ((this.permissions & permission) > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* When concatenated with a String, this automatically concatenates the Role mention rather than the Role object.
|
||||
* @returns {String}
|
||||
*/
|
||||
toString() {
|
||||
return `<@&${this.id}>`;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Role;
|
||||
|
||||
Reference in New Issue
Block a user