channels not creating

hey folks can anyone check this code if I run the setup commmand and choose options voice and default only the category is created the channels does not create also the value of options logs empty
16 Replies
d.js toolkit
d.js toolkit2y 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.
Aditya Kirad
Aditya KiradOP2y ago
node version latest
xubby
xubby2y ago
types are numbers. you can fully utilize the ChannelTypes enum literally
Names of Channel Types: use Object.keys() and filter numbers out type: ChannelTypes['GuildVoice'] or ChannelTypes.GuildVoice
also that ternary ordering without enclosing with parentheses could cause unexpected behavior
Aditya Kirad
Aditya KiradOP2y ago
but that can't be reason due to which I'm getting empty value when I log the options value
xubby
xubby2y ago
bruh.. the question you asked and the name of the channel are totally different. anywho, prolly you missing an intent..
Aditya Kirad
Aditya KiradOP2y ago
what intent does I need for it
xubby
xubby2y ago
you got GuildMessages and GuildMessageContent intent?
Aditya Kirad
Aditya KiradOP2y ago
I got guildMessages btw is there any method in discord.js by which i can get all intents like there is a method in hikari to get all intents which is hikari.intents.all there is not guildMessageContent you there @lil bubby
xubby
xubby2y ago
my bad, it's MessageContent intent. either way, your vscode intellisense would tell you
Aditya Kirad
Aditya KiradOP2y ago
solved that error due to which i was not getting option value btw can you look at this
const createChannel = async (name: string, permissions: OverwriteData[]) => {
await guild.channels.create({
name: name,
type: (channelType === channelOption.voice ? ChannelType.GuildVoice : channelType === channelOption.text ? ChannelType.GuildText : channelType === channelOption.announcement ? ChannelType.GuildAnnouncement : channelType === channelOption.stage ? ChannelType.GuildStageVoice : null),
parent: category.id,
permissionOverwrites: [
{
id: category.id,
deny: [PermissionFlagsBits.SendMessages, channelType === channelOption.voice || channelType === channelOption.stage ? PermissionFlagsBits.Connect : '0']
},
{
id: mutedRole.id,
deny: [PermissionFlagsBits.SendMessages]
},
...permissions
]
})
}
const createChannel = async (name: string, permissions: OverwriteData[]) => {
await guild.channels.create({
name: name,
type: (channelType === channelOption.voice ? ChannelType.GuildVoice : channelType === channelOption.text ? ChannelType.GuildText : channelType === channelOption.announcement ? ChannelType.GuildAnnouncement : channelType === channelOption.stage ? ChannelType.GuildStageVoice : null),
parent: category.id,
permissionOverwrites: [
{
id: category.id,
deny: [PermissionFlagsBits.SendMessages, channelType === channelOption.voice || channelType === channelOption.stage ? PermissionFlagsBits.Connect : '0']
},
{
id: mutedRole.id,
deny: [PermissionFlagsBits.SendMessages]
},
...permissions
]
})
}
xubby
xubby2y ago
and what's the issue?
Aditya Kirad
Aditya KiradOP2y ago
I'm getting this error
[0] Error executing setup
[0] TypeError [InvalidType]: Supplied parameter is not a User nor a Role.
[0] at Function.resolve (E:\Discord Bots\Server Stats\node_modules\discord.js\src\structures\PermissionOverwrites.js:184:28)
[0] at E:\Discord Bots\Server Stats\node_modules\discord.js\src\managers\GuildChannelManager.js:168:81
[0] at Array.map (<anonymous>)
[0] at GuildChannelManager.create (E:\Discord Bots\Server Stats\node_modules\discord.js\src\managers\GuildChannelManager.js:168:51)
[0] at Object.<anonymous> (E:\Discord Bots\Server Stats\src\commands\server_stats\setup.ts:102:30)
[0] at Generator.next (<anonymous>)
[0] at E:\Discord Bots\Server Stats\src\commands\server_stats\setup.ts:8:71
[0] at new Promise (<anonymous>)
[0] at __awaiter (E:\Discord Bots\Server Stats\src\commands\server_stats\setup.ts:4:12)
[0] at createChannel (E:\Discord Bots\Server Stats\src\commands\server_stats\setup.ts:101:80) {
[0] code: 'InvalidType'
[0] }
[0] Error executing setup
[0] TypeError [InvalidType]: Supplied parameter is not a User nor a Role.
[0] at Function.resolve (E:\Discord Bots\Server Stats\node_modules\discord.js\src\structures\PermissionOverwrites.js:184:28)
[0] at E:\Discord Bots\Server Stats\node_modules\discord.js\src\managers\GuildChannelManager.js:168:81
[0] at Array.map (<anonymous>)
[0] at GuildChannelManager.create (E:\Discord Bots\Server Stats\node_modules\discord.js\src\managers\GuildChannelManager.js:168:51)
[0] at Object.<anonymous> (E:\Discord Bots\Server Stats\src\commands\server_stats\setup.ts:102:30)
[0] at Generator.next (<anonymous>)
[0] at E:\Discord Bots\Server Stats\src\commands\server_stats\setup.ts:8:71
[0] at new Promise (<anonymous>)
[0] at __awaiter (E:\Discord Bots\Server Stats\src\commands\server_stats\setup.ts:4:12)
[0] at createChannel (E:\Discord Bots\Server Stats\src\commands\server_stats\setup.ts:101:80) {
[0] code: 'InvalidType'
[0] }
xubby
xubby2y ago
coz one of those values you passed to the propertyid aren't a User or Role type
Aditya Kirad
Aditya KiradOP2y ago
i think this is due category.id hey can you also check this it's giving me wrong number of counts
const guild = interaction.guild;
const members = guild.members.cache;
let totalMemberCount = 0;
let actualMemberCount = 0;
let botCount = 0;

members.forEach(member => {
++totalMemberCount
if(member.user.bot) {
++botCount
} else {
++actualMemberCount
}
})

const channelsCount = guild.channels.cache.size;
const rolesCount = guild.roles.cache.size;
const emojiCount = guild.emojis.cache.size;
const stickersCount = guild.stickers.cache.size;
const boostsCount = guild.premiumSubscriptionCount;
const guild = interaction.guild;
const members = guild.members.cache;
let totalMemberCount = 0;
let actualMemberCount = 0;
let botCount = 0;

members.forEach(member => {
++totalMemberCount
if(member.user.bot) {
++botCount
} else {
++actualMemberCount
}
})

const channelsCount = guild.channels.cache.size;
const rolesCount = guild.roles.cache.size;
const emojiCount = guild.emojis.cache.size;
const stickersCount = guild.stickers.cache.size;
const boostsCount = guild.premiumSubscriptionCount;
also this code does not places the category at the top position
const category = await interaction.guild.channels.create({
name: '📊 SERVER STATS 📊',
type: ChannelType.GuildCategory,
position: 1
});
const category = await interaction.guild.channels.create({
name: '📊 SERVER STATS 📊',
type: ChannelType.GuildCategory,
position: 1
});
d.js docs
d.js docs2y ago
Tag suggestion for @adityakirad: Getting your bot's member countclient.users.cache.size is unreliable because it will only return cached users • The preferred method is using collection.reduce() on client.guilds.cache
client.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0)
client.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0)
xubby
xubby2y ago
prolly set the position to 0
Want results from more Discord servers?
Add your server