get undefined on channelsmanager.fetch(forumChannel) but not on normal channel

Using both v14.6.0-dev and 14.5.0 SOLUTION HERE : https://canary.discord.com/channels/222078108977594368/1023950108770979840/1023953532350627960 when i try to get a forumchannel at the ready event like so :
client.channels.cache.get("1023939042062123038").threads.create({
name: 'Food Talk',
message: {
content: 'Discuss your favorite food!',
},
reason: 'Needed a separate thread for food',
}).then(t => t.send("test"))
client.channels.cache.get("1023939042062123038").threads.create({
name: 'Food Talk',
message: {
content: 'Discuss your favorite food!',
},
reason: 'Needed a separate thread for food',
}).then(t => t.send("test"))
i get an error : cannot read properties of undefined (reading threads) but when i change the channelID to some "normal text channel" it does its job without any problem the same error appears in the same way when trying to fetch the channel on messageCreate event :
message.guild.channels.fetch("1017460418677051432", {cache:true, force:true}).then(c => {
console.log(c)
c.threads.create({
name: 'Food Talk',
message: {
content: 'Discuss your favorite food!',
},
reason: 'Needed a separate thread for food',
}).then(t => t.send("test"))
})
message.guild.channels.fetch("1017460418677051432", {cache:true, force:true}).then(c => {
console.log(c)
c.threads.create({
name: 'Food Talk',
message: {
content: 'Discuss your favorite food!',
},
reason: 'Needed a separate thread for food',
}).then(t => t.send("test"))
})
same error (c is not defined and returns null on console.log) same thing, changing the channel if to some normal channel and it works like a charm
16 Replies
d.js docs
d.js docs3y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
조아오
조아오3y ago
Are you sure the provided id is from a forum channel? Actually, that is from a channel?
Kinton_Hiryuu
Kinton_HiryuuOP3y ago
i right click the forum channel and click copy id like i do for every normal channels i was starting to think about intents
조아오
조아오3y ago
If you have the Guilds, it shouldn't be an issue Wrong reply
Kinton_Hiryuu
Kinton_HiryuuOP3y ago
let me retry on v14.5.0 real quick but i had the guild intent can you give me the bitfield for it pls ? i usually use an array of "GUILDS","GUILD_MESSAGES" and so on but idk why it wont work this time
Jaworek
Jaworek3y ago
v13?
조아오
조아오3y ago
Ugh, can you run npm ls discord.js He said v14 on the post but doubt
Kinton_Hiryuu
Kinton_HiryuuOP3y ago
v14.5 and 14.6
Jaworek
Jaworek3y ago
Thonk
Kinton_Hiryuu
Kinton_HiryuuOP3y ago
조아오
조아오3y ago
GatewayIntentBits.Guilds and GatewayIntentBits.GuildMessages Idk it it is GatewayIntentBits or GatewayIntentsBits
Kinton_Hiryuu
Kinton_HiryuuOP3y ago
yeah mb im just dumv with those
Kinton_Hiryuu
Kinton_HiryuuOP3y ago
well, seems like the good guild intent fixed it ? i really struggle to understand how to declare them versions to versions (often switching from dev to stable)
Kinton_Hiryuu
Kinton_HiryuuOP3y ago
thx for the help i guess ?
조아오
조아오3y ago
Always use this, they won't change until v15 (and may not change there either)
Kinton_Hiryuu
Kinton_HiryuuOP3y ago
ok thx for the tips and for the one who's looking for the same problem as me, here's the bit of code that works : 1. Verify from npm ls that you got the good version and not an older one for whichever reason 2.
const DISCORD = require('discord.js');
client = new DISCORD.Client({ intents:[DISCORD.GatewayIntentBits.Guilds] });
client.login(CONFIG.token);

client.on('ready', () => {
const channel = client.channels.cache.get('1023939042062123038');
channel.threads.create({ name: 'Post name', message: { content: 'Message content' }});
})
const DISCORD = require('discord.js');
client = new DISCORD.Client({ intents:[DISCORD.GatewayIntentBits.Guilds] });
client.login(CONFIG.token);

client.on('ready', () => {
const channel = client.channels.cache.get('1023939042062123038');
channel.threads.create({ name: 'Post name', message: { content: 'Message content' }});
})
3, if you still get the error, try npm remove discord.js then npm i discord.js again so you dont have random shit in your djs version
Want results from more Discord servers?
Add your server