我对discord.js 与node 相对较新。我正在尝试从线程中读取第一条消息,我不知道,作为数组并稍后保存。因为我想稍后通过 API 传递数据。
我在这里打破了我的王冠。
我已经尝试过:
const { ChannelType } = require('discord.js');
client.on('threadCreate', async (thread) => {
if (thread.type == ChannelType.GuildPublicThread) {
// When a new forum post is created
console.log(thread.parentId) // The forum channel ID
console.log(thread.id) // The forum post ID
console.log(thread.name) // The name of the forum post
}
})
但我找不到获取 wohl 线程数据的方法。也许有人可以帮我解决这个问题?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
const { ChannelType } = require('discord.js'); client.on('threadCreate', async (thread) => { if (thread.type === ChannelType.GuildPublicThread) { const messages = await thread.messages.fetch(); const firstMessage = messages.first(); // Access the data of the first message console.log(firstMessage.content); // Example: Log the content of the first message // You can save the necessary data from the first message for later use in your API const messageData = { content: firstMessage.content, author: firstMessage.author.tag, // Add more properties as needed }; // Pass the messageData to your API or perform further operations // ... } });