mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 20:43:30 +01:00
Change message.mentions to a Map
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -74,10 +74,10 @@ class Message {
|
|||||||
*/
|
*/
|
||||||
this.attachments = data.attachments;
|
this.attachments = data.attachments;
|
||||||
/**
|
/**
|
||||||
* A list of users mentioned in the message
|
* A map of users mentioned in the message, the key is the user ID.
|
||||||
* @type {Array<User>}
|
* @type {Map<String, User>}
|
||||||
*/
|
*/
|
||||||
this.mentions = [];
|
this.mentions = new Map();
|
||||||
/**
|
/**
|
||||||
* The ID of the message (unique in the channel it was sent)
|
* The ID of the message (unique in the channel it was sent)
|
||||||
* @type {String}
|
* @type {String}
|
||||||
@@ -86,10 +86,10 @@ class Message {
|
|||||||
for (const mention of data.mentions) {
|
for (const mention of data.mentions) {
|
||||||
let user = this.client.users.get(mention.id);
|
let user = this.client.users.get(mention.id);
|
||||||
if (user) {
|
if (user) {
|
||||||
this.mentions.push(user);
|
this.mentions.set(user.id, user);
|
||||||
} else {
|
} else {
|
||||||
user = this.client.dataManager.newUser(mention);
|
user = this.client.dataManager.newUser(mention);
|
||||||
this.mentions.push(user);
|
this.mentions.set(user.id, user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,10 +126,10 @@ class Message {
|
|||||||
for (const mention of data.mentions) {
|
for (const mention of data.mentions) {
|
||||||
let user = this.client.users.get(mention.id);
|
let user = this.client.users.get(mention.id);
|
||||||
if (user) {
|
if (user) {
|
||||||
this.mentions.push(user);
|
this.mentions.set(user.id, user);
|
||||||
} else {
|
} else {
|
||||||
user = this.client.dataManager.newUser(mention);
|
user = this.client.dataManager.newUser(mention);
|
||||||
this.mentions.push(user);
|
this.mentions.set(user.id, user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -178,12 +178,16 @@ client.on('messageUpdate', (old, message) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
client.on('message', msg => {
|
client.on('message', msg => {
|
||||||
if (msg.content.startsWith('yoing')) {
|
if (msg.content.startsWith('?raw')) {
|
||||||
let startTime = Date.now();
|
msg.channel.sendMessage('```' + msg.content + '```');
|
||||||
msg.channel.sendMessage("Let's see if this works")
|
}
|
||||||
.then(message => {
|
|
||||||
let endTime = Date.now();
|
if (msg.content.startsWith('?eval') && msg.author.id === '66564597481480192') {
|
||||||
message.edit(`Ping took ${(endTime - startTime).toFixed(3)} ms. I think.`).catch(console.error);
|
try {
|
||||||
}).catch(console.error);
|
const com = eval(msg.content.split(" ").slice(1).join(" "));
|
||||||
|
msg.channel.sendMessage('```\n' + com + '```');
|
||||||
|
} catch(e) {
|
||||||
|
msg.channel.sendMessage('```\n' + e + '```');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user