【发布时间】:2021-05-08 15:06:46
【问题描述】:
所以我试图在不和谐的人队列中创建一个不和谐的人队列,我让机器人向我发送加入队列的人的姓名,但我不知道从这里去哪里。我想列出加入队列的人员名单,可能是文字。有谁知道我该怎么做?
我昨天才开始编码,所以我并不真正了解所有来龙去脉。这是我目前拥有的代码:
client.on('message', message => {
if(!message.content.startsWith(prefix)|| message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
if(command === 'ping'){
client.commands.get('ping').execute(message, args);
}
if(command === 'clear'){
client.commands.get('clear').execute(message, args);
}
if(command === 'embed'){
client.commands.get('embed').execute(message, args, Discord);
}
if(message.content === `${prefix}joinqueue`){
message.author.send('You have joined the queue!');
console.log(`${message.author.username} joined the queue.`);
client.users.fetch('518160902835666946').then(user => {
user.send(`${message.author.username} joined the queue!`)
})
}
});
还有一些其他命令,但我用于此的命令是最后一个。如果您使用该命令,它会向您发送一条私人消息,说明谁加入了,并向我发送一条私人消息,说明加入队列。我希望代码还将此人的姓名添加到文档中,以便我可以看到队列的顺序。我真的不太在意格式,只要能看到顺序就行了。
【问题讨论】:
-
欢迎来到 Stack Overflow!其他人很难给你一个不基于意见的答案。您能否编辑您的问题以包含您当前的代码?关于什么是文档的首选格式以及您是否希望它仅被附加或实时更新的一些附加细节。另外,你在哪里运行你的机器人,它是否可以访问文件系统,还是需要外部 API?
标签: discord.js