gpt4 book ai didi

javascript - 获取随机 Discord 用户

转载 作者:行者123 更新时间:2023-11-30 14:24:38 25 4
gpt4 key购买 nike

我正在创建一个机器人来标记随机用户,但我遇到了一些困难。

我怎样才能得到一个随机用户?我目前正在这样做:

let usersCount = message.guild.memberCount;
let users = Array.from(message.guild.members);
let randomNumber = Math.floor(Math.random() * usersCount);
let randomUser = users[randomNumber];

console.log(randomUser);

但是它返回这个,整个公会:

[ '208045530369097728', GuildMember {
guild:
Guild {
members: [Object],
channels: [Object],
roles: [Object],
presences: [Object],
deleted: false,
available: true,
id: '4481898438608814093132',
name: 'bot test',
icon: '21cddd6a700aaff9b9ccb0c2c1b8de5e',
splash: null,
region: 'brazil',
memberCount: 71,
large: false,
features: [],
applicationID: null,
afkTimeout: 300,
afkChannelID: '448206219711217674',
systemChannelID: null,
embedEnabled: undefined,
verificationLevel: 0,
explicitContentFilter: 0,
mfaLevel: 0,
joinedTimestamp: 1535857830448,
defaultMessageNotifications: 'ALL',
ownerID: '2013795851090283612',
_rawVoiceStates: Collection {},
emojis: [Object] },
user:
User {
id: '2180145503619097728',
username: 'xxxx!',
discriminator: '4198',
avatar: 'a1fb0d1c273a18acc69fa9f796a8c7d7',
bot: false,
lastMessageID: null,
lastMessage: null },
joinedTimestamp: 1526933713197,
_roles:
[ '44811902750147915532',
'45769217147885815476',
'47113897343090168840' ],
serverDeaf: false,
serverMute: false,
selfMute: undefined,
selfDeaf: undefined,
voiceSessionID: undefined,
voiceChannelID: undefined,
speaking: false,
nickname: 'xxxx',
lastMessageID: null,
lastMessage: null,
deleted: false } ]

如何获取用户并标记他?

我已经尝试过 randomUser.user,返回未定义。我不知道

最佳答案

已解决

 var user = message.guild.members.random();
console.log(`${user.user}`);

关于javascript - 获取随机 Discord 用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52138159/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com