question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

channel.nsfw returns undefined if the channel is not nsfw

See original GitHub issue

Hello,i was wondering because if a channel is not nsfw it returns undefined

this is a code sample

module.exports = {
	name: 'channel-info',
	execute(message, args) {
               let channel = message.guild.channels.cache.find(channel => channel.name === 'Public Channel')

               message.channel.send(`Nsfw: ${channel.nsfw}`)
		}

this is my code:

const Discord = require('discord.js')
module.exports = {
	name: 'channel-info',
	execute(message, args) {
		if (!message.member.hasPermission('MANAGE_CHANNELS')) return message.channel.send(`${message.author.username} Non Hai Il Permesso Di Fare Il Comando __**channel-info**__`)
		
		if(!message.guild.me.hasPermission('MANAGE_CHANNELS')) return message.channel.send('Non Ho Il Permesso Di Vedere Le Informazioni Di Un Canale')

		let Nomecanale = message.content.substring(message.content.indexOf(' ')+1)

		let canale = message.guild.channels.cache.find(channel => channel.name === (Nomecanale))

		if(!canale) return message.channel.send('Canale Non Trovato')

        const channelinfo = new Discord.MessageEmbed()
	.setColor('ff0000')
	.setTitle(`Ecco Le Informazioni Del Canale: ${canale.name}`)
	.setDescription(`**Nome: ${canale.name}\nDescrizione: ${canale.topic}\nCategoria: ${canale.parent}\nTipo: ${canale.type}\nPosizione: ${canale.position}\nID: ${canale.id}\nSlowmode: ${canale.rateLimitPerUser}\nNsfw: ${canale.nsfw}\nVelocità Di Trasmissione: ${canale.bitrate}**`)
	.setTimestamp()
	.setFooter(`Comando Eseguito Da: ${message.author.username}`);
		

message.channel.send(channelinfo);
		}
	}

discord.js version: v12.2.0

node.js version: v12.16.2

operating system: Windows 7

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
AlexDiego123commented, May 16, 2020

No even if its a text channel it returns undefined

0reactions
AlexDiego123commented, May 18, 2020

me being able to reproduce this does not mean that the issue is resolved, please keep it open so we can actually keep track of it

ok i reopened the issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'nsfw' of undefined - discord.js
As the error states, message.channel is undefined . Check the value of the second argument you pass into run() . – Bucket. Mar...
Read more >
Check if a channel is NSFW and if it is send a message | Rold
Check if a channel is NSFW and if it is send a message. This snippet does not contain any NSFW, it only checks...
Read more >
Updating from v12 to v13
Threads are a new type of sub-channel that can be used to help separate ... The ClientUser#setActivity method no longer returns a Promise....
Read more >
hikari.channels - hikari 2.0.0.dev113 documentation
Return the channel ID of the channel being followed. ... before hikari.undefined. ... If provided, whether the channel should be marked as NSFW...
Read more >
How To Create NSFW Channels on Discord - YouTube
How to create NSFW channels on Discord? In this tutorial, I show you how to make a NSFW channel on Discord in both...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found