CategoryChildManager create method not working

Hey everyone! I am having trouble creating a child channel within a category. Here is the code
const { Events, ChannelType } = require('discord.js');
const Game = require('../games/gameClass');
const GameCategory = require('../schemas/gameCategory');



let currentGame;
module.exports = {
name: Events.VoiceStateUpdate,
async execute(oldState, newState) {


try {
let currentChannel = newState.channel;

if (currentChannel.full) {
const gameCategoryId = await GameCategory.findOne({ guildId: newState.guild.id });
const gameCategory = await newState.guild.channels.fetch(gameCategoryId.channelId);


console.log('queue full');
let players = [];

for (let i = 0; i < newState.channel.members.size; i++) {
players.push(newState.channel.members.at(i).id);
console.log(i);
}



let gameId = Math.ceil(Math.random() * 10000);
console.log(players);


console.log(gameCategory.id);

// This actually returns the ID of the category, so the category channel is being found.
/*

I am using the .create() method of the category channel. I'm pretty sure the syntax is correct because if I do
newState.guild.channels.create()
with the same syntax, it works.

However, when I try to make a child channel inside of the category, it does not work.
Can somebody please help me :)


*/


await gameCategory.create({
name: `Game-${gameId}`,
type: ChannelType.GuildText
});

}

} catch (err) {

}



},
}


const { Events, ChannelType } = require('discord.js');
const Game = require('../games/gameClass');
const GameCategory = require('../schemas/gameCategory');



let currentGame;
module.exports = {
name: Events.VoiceStateUpdate,
async execute(oldState, newState) {


try {
let currentChannel = newState.channel;

if (currentChannel.full) {
const gameCategoryId = await GameCategory.findOne({ guildId: newState.guild.id });
const gameCategory = await newState.guild.channels.fetch(gameCategoryId.channelId);


console.log('queue full');
let players = [];

for (let i = 0; i < newState.channel.members.size; i++) {
players.push(newState.channel.members.at(i).id);
console.log(i);
}



let gameId = Math.ceil(Math.random() * 10000);
console.log(players);


console.log(gameCategory.id);

// This actually returns the ID of the category, so the category channel is being found.
/*

I am using the .create() method of the category channel. I'm pretty sure the syntax is correct because if I do
newState.guild.channels.create()
with the same syntax, it works.

However, when I try to make a child channel inside of the category, it does not work.
Can somebody please help me :)


*/


await gameCategory.create({
name: `Game-${gameId}`,
type: ChannelType.GuildText
});

}

} catch (err) {

}



},
}


I hope that I wrote my problem in detail šŸ™‚
6 Replies
d.js toolkit
d.js toolkitā€¢17mo 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!
Den
DenOPā€¢17mo ago
Forgot to mention, upon the execution of the code, no error is returned to the console even when I use .catch All the other code is being executed too, and I can see that because all the console.log methods are coming through.
d.js docs
d.js docsā€¢17mo ago
property CategoryChannel#children A manager of the channels belonging to this category
Den
DenOPā€¢17mo ago
OMG thank you so much. I misread the docs haha You are a saviour šŸ™‚
Den
DenOPā€¢17mo ago
Den
DenOPā€¢17mo ago
it worked šŸ™‚ thanks
Want results from more Discord servers?
Add your server