forked from discordjs/discord.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UserSelectMenuInteraction.js
55 lines (45 loc) · 1.51 KB
/
UserSelectMenuInteraction.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
'use strict';
const { Collection } = require('@discordjs/collection');
const MessageComponentInteraction = require('./MessageComponentInteraction');
const Events = require('../util/Events');
/**
* Represents a {@link ComponentType.UserSelect} select menu interaction.
* @extends {MessageComponentInteraction}
*/
class UserSelectMenuInteraction extends MessageComponentInteraction {
constructor(client, data) {
super(client, data);
/**
* An array of the selected user ids
* @type {Snowflake[]}
*/
this.values = data.data.values ?? [];
/**
* Collection of the selected users
* @type {Collection<Snowflake, User>}
*/
this.users = new Collection();
/**
* Collection of the selected members
* @type {Collection<Snowflake, GuildMember|APIGuildMember>}
*/
this.members = new Collection();
for (const user of Object.values(data.data.resolved.users)) {
this.users.set(user.id, this.client.users._add(user));
}
if (data.data.resolved.members) {
for (const [id, member] of Object.entries(data.data.resolved.members)) {
const user = data.data.resolved.users[id];
if (!user) {
this.client.emit(
Events.Debug,
`[UserSelectMenuInteraction] Received a member without a user, skipping ${id}`,
);
continue;
}
this.members.set(id, this.guild?.members._add({ user, ...member }) ?? { user, ...member });
}
}
}
}
module.exports = UserSelectMenuInteraction;