fedpep
fedpep
DIAdiscord.js - Imagine an app
Created by fedpep on 10/21/2024 in #djs-questions
Fetch all reactions from a message but without cache
Thanks! I added the reaction intents and everything seems to work as expected now
13 replies
DIAdiscord.js - Imagine an app
Created by fedpep on 10/21/2024 in #djs-questions
Fetch all reactions from a message but without cache
That looks exactly like what I need. Can you link to the documentation on both things (force fetch and update cache with reaction intents)?
13 replies
DIAdiscord.js - Imagine an app
Created by fedpep on 10/21/2024 in #djs-questions
Fetch all reactions from a message but without cache
Thanks for the explanation. This help request comes from another thing that I asked here: https://discord.com/channels/222078108977594368/1295427588843372678 The issue I have right now is that when I export all the posts in a forum, the reaction numbers are not updated/synced with what is on the server.
13 replies
DIAdiscord.js - Imagine an app
Created by fedpep on 10/21/2024 in #djs-questions
Fetch all reactions from a message but without cache
Up! Is there no way to achieve this, right? I couldn't find a get or fetch command that is not using the cache.
13 replies
DIAdiscord.js - Imagine an app
Created by fedpep on 10/21/2024 in #djs-questions
Fetch all reactions from a message but without cache
I’m using a variable to simply add the emoji count on each iteration and then console.log that variable to check the results
13 replies
DIAdiscord.js - Imagine an app
Created by fedpep on 10/21/2024 in #djs-questions
Fetch all reactions from a message but without cache
No, I mean that I got the count wrong... e.g a message have 87 reactions but with that code above I just got 61
13 replies
DIAdiscord.js - Imagine an app
Created by fedpep on 10/14/2024 in #djs-questions
How can I get an array of all the posts in a forum?
🙌 thanks
25 replies
DIAdiscord.js - Imagine an app
Created by fedpep on 10/14/2024 in #djs-questions
How can I get an array of all the posts in a forum?
As I said, I need to export in a csv file title, number of reactions and number of comments of all the messages in a forum on Discord
25 replies
DIAdiscord.js - Imagine an app
Created by fedpep on 10/14/2024 in #djs-questions
How can I get an array of all the posts in a forum?
Thank you very much for your help! Definitely not the cleanest code but it does work
const inputChannel = await interaction.options.getChannel('channel');
const channel = await inputChannel.threads.fetch();

channel.threads.forEach(async post => {
let output;
let r = "";
// const mess = await post.messages.fetch(post.id);
const mess = await post.fetchStarterMessage();
const react = mess.reactions.cache.forEach(async (reaction) => {
const emojiName = reaction._emoji.name
const emojiCount = reaction.count
r = emojiName + emojiCount

});
output = `${post.name}, https://discord.com/channels/${post.guildId}/${post.parentId}/threads/${post.id}/, ${post.messageCount}, ${r}`;
// THIS WORKS
console.log(output);
});
const inputChannel = await interaction.options.getChannel('channel');
const channel = await inputChannel.threads.fetch();

channel.threads.forEach(async post => {
let output;
let r = "";
// const mess = await post.messages.fetch(post.id);
const mess = await post.fetchStarterMessage();
const react = mess.reactions.cache.forEach(async (reaction) => {
const emojiName = reaction._emoji.name
const emojiCount = reaction.count
r = emojiName + emojiCount

});
output = `${post.name}, https://discord.com/channels/${post.guildId}/${post.parentId}/threads/${post.id}/, ${post.messageCount}, ${r}`;
// THIS WORKS
console.log(output);
});
25 replies
DIAdiscord.js - Imagine an app
Created by fedpep on 10/14/2024 in #djs-questions
How can I get an array of all the posts in a forum?
Hey @gwapes really sorry about it. Let me explain myself better. With the above code now I am able to fetch all the posts that are in a specific forum. Now what I need is: 1. the title of every post 2. the number of reactions every post received (with the default tag, which is 👍 ) 3. the number of messages that are in that post From the discussion happened yesterday I understood that now that I have the collection of all the thread, I just need to loop through it and use the message.fetch(id) The problem is that since these are threads and not messages in a text channel, I can't understand what is the channel id and the message id I should use
25 replies
DIAdiscord.js - Imagine an app
Created by fedpep on 10/14/2024 in #djs-questions
How can I get an array of all the posts in a forum?
Hey, so this is my new code:
const guild = interaction.guild;
const channelLog = await guild.channels.fetch(process.env.BOT_LOG_CHANNEL_ID);
const inputChannel = await interaction.options.getChannel('channel');
const channel = await inputChannel.threads.fetch();
channel.threads.forEach(async post => {
console.log(post);
});
const guild = interaction.guild;
const channelLog = await guild.channels.fetch(process.env.BOT_LOG_CHANNEL_ID);
const inputChannel = await interaction.options.getChannel('channel');
const channel = await inputChannel.threads.fetch();
channel.threads.forEach(async post => {
console.log(post);
});
and it's working because I can fetch all the threads in the specific forum (this is an excract of the output).
guildId: '***',
messages: GuildMessageManager { channel: [Circular *2] },
members: ThreadMemberManager { thread: [Circular *2] },
flags: ChannelFlagsBitField { bitfield: 0 },
id: '***',
name: '***',
parentId: '***',
locked: false,
invitable: null,
archived: false,
autoArchiveDuration: 4320,
archiveTimestamp: 1728659798143,
_createdTimestamp: 1728659798143,
ownerId: '***',
lastMessageId: '***',
lastPinTimestamp: null,
rateLimitPerUser: 0,
messageCount: 21,
memberCount: 4,
totalMessageSent: 21,
appliedTags: []
}
guildId: '***',
messages: GuildMessageManager { channel: [Circular *2] },
members: ThreadMemberManager { thread: [Circular *2] },
flags: ChannelFlagsBitField { bitfield: 0 },
id: '***',
name: '***',
parentId: '***',
locked: false,
invitable: null,
archived: false,
autoArchiveDuration: 4320,
archiveTimestamp: 1728659798143,
_createdTimestamp: 1728659798143,
ownerId: '***',
lastMessageId: '***',
lastPinTimestamp: null,
rateLimitPerUser: 0,
messageCount: 21,
memberCount: 4,
totalMessageSent: 21,
appliedTags: []
}
Now I can't get the messages. I tried to use the id and it didn't work
25 replies
DIAdiscord.js - Imagine an app
Created by fedpep on 10/14/2024 in #djs-questions
How can I get an array of all the posts in a forum?
I see there is a fetchedActive and a fetchedArchive
25 replies
DIAdiscord.js - Imagine an app
Created by fedpep on 10/14/2024 in #djs-questions
How can I get an array of all the posts in a forum?
Oh, I think you might be right. One post is showed as “older” so I guess it’s archived. Am I right? Is there a way to fetch all the messages (including older one)?
25 replies
DIAdiscord.js - Imagine an app
Created by fedpep on 10/14/2024 in #djs-questions
How can I get an array of all the posts in a forum?
I’m using a test server and there are 2 posts at the moment
25 replies
DIAdiscord.js - Imagine an app
Created by fedpep on 10/14/2024 in #djs-questions
How can I get an array of all the posts in a forum?
But the collection that I have (see above) s only 1 item and not all the messages
25 replies
DIAdiscord.js - Imagine an app
Created by fedpep on 10/14/2024 in #djs-questions
How can I get an array of all the posts in a forum?
The why is that I used a forum channel on Discord to collect feature requests on a product and now I have to extract everything to a Google Sheet I was hoping to automate the process as much as possibile via the discord API In my head I could get the forum ID, get all the posts in it, and then extract the information that I need from each message
25 replies
DIAdiscord.js - Imagine an app
Created by fedpep on 10/14/2024 in #djs-questions
How can I get an array of all the posts in a forum?
Any suggestions on how to do that? It’s a new forum (so there are no many messages) and I want to extract them all
25 replies
DIAdiscord.js - Imagine an app
Created by fedpep on 10/14/2024 in #djs-questions
How can I get an array of all the posts in a forum?
Now I get this
{
threads: Collection(1) [Map] {
'***' => ThreadChannel {
type: 11,
guild: [Guild],
guildId: '****',
messages: [GuildMessageManager],
members: [ThreadMemberManager],
flags: [ChannelFlagsBitField],
id: '***',
name: '***',
parentId: '***',
locked: false,
invitable: null,
archived: false,
autoArchiveDuration: 4320,
archiveTimestamp: 1728659798143,
_createdTimestamp: 1728659798143,
ownerId: '***',
lastMessageId: '***',
lastPinTimestamp: null,
rateLimitPerUser: 0,
messageCount: 21,
memberCount: 4,
totalMessageSent: 21,
appliedTags: []
}
},
members: Collection(0) [Map] {},
hasMore: false
}
{
threads: Collection(1) [Map] {
'***' => ThreadChannel {
type: 11,
guild: [Guild],
guildId: '****',
messages: [GuildMessageManager],
members: [ThreadMemberManager],
flags: [ChannelFlagsBitField],
id: '***',
name: '***',
parentId: '***',
locked: false,
invitable: null,
archived: false,
autoArchiveDuration: 4320,
archiveTimestamp: 1728659798143,
_createdTimestamp: 1728659798143,
ownerId: '***',
lastMessageId: '***',
lastPinTimestamp: null,
rateLimitPerUser: 0,
messageCount: 21,
memberCount: 4,
totalMessageSent: 21,
appliedTags: []
}
},
members: Collection(0) [Map] {},
hasMore: false
}
I see the last message in the forum but not a list of all the messages
25 replies
DIAdiscord.js - Imagine an app
Created by fedpep on 10/14/2024 in #djs-questions
How can I get an array of all the posts in a forum?
Ok, so I changed the code to this:
const channel = await interaction.options.getChannel('channel');
console.log(channel.threads.fetch());
const channel = await interaction.options.getChannel('channel');
console.log(channel.threads.fetch());
And now I get this: Promise { <pending> }
25 replies
DIAdiscord.js - Imagine an app
Created by fedpep on 10/14/2024 in #djs-questions
How can I get an array of all the posts in a forum?
@Qjuh thanks for your answer but I still can't get this to work. I receive an error: TypeError: Cannot read properties of undefined (reading 'fetch') This is my code:
module.exports = {
name: Events.InteractionCreate,
data: new SlashCommandBuilder()
.setName('forum-export')
.setDescription('Export messages in a forum')
.addChannelOption(option =>
option.setName('channel')
.setDescription('The channel to echo into')
.addChannelTypes(ChannelType.GuildForum)
)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),

async execute(interaction) {
await interaction.deferReply({ ephemeral: true });

try {
const guild = interaction.guild;
const channelLog = await guild.channels.fetch(process.env.BOT_LOG_CHANNEL_ID);
const channel = await interaction.options.getChannel('channel');
console.log(channel.thread.fetch(channel.id));

await interaction.editReply({content: `Run`});

}
module.exports = {
name: Events.InteractionCreate,
data: new SlashCommandBuilder()
.setName('forum-export')
.setDescription('Export messages in a forum')
.addChannelOption(option =>
option.setName('channel')
.setDescription('The channel to echo into')
.addChannelTypes(ChannelType.GuildForum)
)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),

async execute(interaction) {
await interaction.deferReply({ ephemeral: true });

try {
const guild = interaction.guild;
const channelLog = await guild.channels.fetch(process.env.BOT_LOG_CHANNEL_ID);
const channel = await interaction.options.getChannel('channel');
console.log(channel.thread.fetch(channel.id));

await interaction.editReply({content: `Run`});

}
25 replies