Why does .content not work when it is in the array?

in my example the newName shows content in it but newName.content does not give back anything
9 Replies
d.js toolkit
d.js toolkit14mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Danial
Danial14mo ago
What is newName supposed to be? The message? If it's really the content then <String>.content indeed does not exist
Bobjoerules
BobjoerulesOP14mo ago
newName = message.first() and i when i console log "newName" the content shows as "content: 'test'" but when i console log "newName .content" nothing happens
Harnes
Harnes14mo ago
What is message?
Bobjoerules
BobjoerulesOP14mo ago
the messages sent in the channel wait i did not show my code opps the .content and .name dont work but they show in the list if you dont put them
Bobjoerules
BobjoerulesOP14mo ago
here is what i'm saying. it shows content in the first log but the second one does nothing wich is the one with .content
No description
Bobjoerules
BobjoerulesOP14mo ago
the .name for the catagory does not workj I dont think it has todo with the MESSAGECONTENT intent beacause it shows up while not using .content but does not show anything with but then again when i put .channelId it shows the channel id but for .content it does not
monbrey
monbrey14mo ago
I dont understand how newName[4] can work It otherwise looks right Can you show the full log
Bobjoerules
BobjoerulesOP14mo ago
oh that was just something i put in nothing todo with the broken part but here is the updated code
if (interaction.commandName === 'clonechannel'){
if (!(interaction.user.id === '')) {
interaction.reply('Only the owner can use this broken command!')
return;
}
interaction.reply('What is the name you want to use?')
const filter = m => m.author.id === interaction.user.id
const newchannel = interaction.channel.clone()
.then(newchannel => {
const newChannelId = newchannel.id;
interaction.channel.awaitMessages({ filter, max: 1, time: 60000 })
.then(message => {
newName = message.first()
console.log('Cloned Channel ID:', newChannelId);
const guild = interaction.guild;
const clonedChannel = guild.channels.cache.get(newChannelId);
clonedChannel.setName(newName.content)
.catch(console.error);
interaction.channel.send('the channel has been cloned with the name of: ' + newName.content);
})
})
.catch(collected => {
interaction.channel.send('Timeout');
});
}
if (interaction.commandName === 'clonechannel'){
if (!(interaction.user.id === '')) {
interaction.reply('Only the owner can use this broken command!')
return;
}
interaction.reply('What is the name you want to use?')
const filter = m => m.author.id === interaction.user.id
const newchannel = interaction.channel.clone()
.then(newchannel => {
const newChannelId = newchannel.id;
interaction.channel.awaitMessages({ filter, max: 1, time: 60000 })
.then(message => {
newName = message.first()
console.log('Cloned Channel ID:', newChannelId);
const guild = interaction.guild;
const clonedChannel = guild.channels.cache.get(newChannelId);
clonedChannel.setName(newName.content)
.catch(console.error);
interaction.channel.send('the channel has been cloned with the name of: ' + newName.content);
})
})
.catch(collected => {
interaction.channel.send('Timeout');
});
}
This clones a channel and renames the cloned channel to what you want Don't forget the need of GatewayIntentBits.MessageContent
Want results from more Discord servers?
Add your server