如何计算每个用户的一个频道中的消息数?

2022-01-10 00:00:00 discord javascript discord.js

我想用 discord.js 编写一个不和谐的机器人......但是在文档中,我没有找到一个函数来计算每个用户的频道中的消息数量......有没有一个函数可以像用户一样使用带有过滤器的搜索栏?

I want to code a discord bot with the discord.js ... But in the documentation, I don't found a function to count the number of messages in a channel of each user... Is there a function to use the searchbar with filters like an user?

推荐答案

搜索不(尚)可用于 Bots.

The search is not ( yet ) avaible for Bots.

你可以Channel#fetchMessages 但这将是 Api 密集型的.

You could Channel#fetchMessages but this would be very Api intensive.

最好的方法是获取一个数据库并在用户发送消息时增加它,但这只会在机器人运行时计算消息.

Best way would be to get a database and increment it when the user sends a message, but that will only count messages when the bot is running.

相关文章