最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - how to pull message data from discord.js? - Stack Overflow

programmeradmin0浏览0评论

Discord.js is an API for Discord that allows the developers to make plugins for the program, discord. here's the link to the API code it's in js, .js/

Discord is setup to be like a server where you connect and chat on channels, my problem is how do I pull the message data from the channels.

What they did is setup all the channels in a JSON cache and within the channel, objects is another cache with the messages objects(what documentation says). But when I get to the message cache all I see is messages: Cache { limit: 1000 } }. How do I pull all the message objects from the channel?

Discord.js is an API for Discord that allows the developers to make plugins for the program, discord. here's the link to the API code it's in js, https://github./hydrabolt/discord.js/

Discord is setup to be like a server where you connect and chat on channels, my problem is how do I pull the message data from the channels.

What they did is setup all the channels in a JSON cache and within the channel, objects is another cache with the messages objects(what documentation says). But when I get to the message cache all I see is messages: Cache { limit: 1000 } }. How do I pull all the message objects from the channel?

Share Improve this question edited Mar 28, 2018 at 11:31 user948581 asked Aug 7, 2016 at 23:42 Electro lemonElectro lemon 731 gold badge1 silver badge6 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 2

For those using discord.js v8 or lower.

If you want to pull all the message objects from the channel I reend ignoring the cach and instead using getChannelLogs(channel, limit, options, callback) Which will allow you to fetch up to 100 messages at once, but those messages do not have to be cached within discord.js. You can quite easily create a recursive function that on the callback fetches more messages to fetch as many messages as you want.

That said server.channel.messages will be all of the messages in it that discord.js has cached. If it appears empty chances are no-one sent a message since the bot was activated.

source: http://discordjs.readthedocs.io/en/latest/docs_client.html#getchannellogs-channel-limit-options-callback

发布评论

评论列表(0)

  1. 暂无评论