This is an example on how to restrict a command to a NSFW channel,
// authenticates you with the API standard library
// type `await lib.` to display API autocomplete
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let channel = await lib.discord.channels['@0.3.2'].retrieve({
channel_id: `${context.params.event.channel_id}`,
});
if (channel.nsfw) {
//some code when the channel is nsfw
await lib.discord.channels['@0.3.2'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `What are you doing in this NSFW channel, huh? 🤨📸`,
});
} else {
//some code when the channel is not nsfw
await lib.discord.channels['@0.3.2'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `Hey, <@${context.params.event.author.id}> switch to a NSFW channel before using this command!`,
});
}