'DiscordAPIError Invalid Form Body' when creating channel

Hello there. Basically, I am trying to create a text channel using the following code:
let newChannel = await interaction.guild.channels.create({
parent: admissionsTicketsCategoryId,
name: `admissions-from-${interaction.user.username.toLowerCase()}`,
type: "GUILD_TEXT",
permissionsOverwrites: [
{
id: interaction.user.id,
allow: [
"VIEW_CHANNEL",
"SEND_MESSAGES",
"EMBED_LINKS",
"ATTACH_FILES",
"READ_MESSAGE_HISTORY"
]
}
],
reason: `${interaction.user.tag} created a ticket`
})
let newChannel = await interaction.guild.channels.create({
parent: admissionsTicketsCategoryId,
name: `admissions-from-${interaction.user.username.toLowerCase()}`,
type: "GUILD_TEXT",
permissionsOverwrites: [
{
id: interaction.user.id,
allow: [
"VIEW_CHANNEL",
"SEND_MESSAGES",
"EMBED_LINKS",
"ATTACH_FILES",
"READ_MESSAGE_HISTORY"
]
}
],
reason: `${interaction.user.tag} created a ticket`
})
But whenever the code runs, I get the following error:
DiscordAPIError: Invalid Form Body
name: Could not interpret "{'parent': '988570987685613599', 'name': 'admissions-from-batimius', 'type': 'GUILD_TEXT', 'permissionsOverwrites': [{'id': '347858411897225236', 'allow': ['VIEW_CHANNEL', 'SEND_MESSAGES', 'EMBED_LINKS', 'ATTACH_FILES', 'READ_MESSAGE_HISTORY']}], 'reason': 'Batimius#5703 created a ticket'}" as string.
at RequestHandler.execute (C:\Users\Batman212369\Desktop\Discord Bots\LETI-Bot-V2\node_modules\discord.js\src\rest\RequestHandler.js:350:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (C:\Users\Batman212369\Desktop\Discord Bots\LETI-Bot-V2\node_modules\discord.js\src\rest\RequestHandler.js:51:14)
at async GuildChannelManager.create (C:\Users\Batman212369\Desktop\Discord Bots\LETI-Bot-V2\node_modules\discord.js\src\managers\GuildChannelManager.js:157:18)
at async Interaction.callback (C:\Users\Batman212369\Desktop\Discord Bots\LETI-Bot-V2\Cogs\ticket.js:40:22)
DiscordAPIError: Invalid Form Body
name: Could not interpret "{'parent': '988570987685613599', 'name': 'admissions-from-batimius', 'type': 'GUILD_TEXT', 'permissionsOverwrites': [{'id': '347858411897225236', 'allow': ['VIEW_CHANNEL', 'SEND_MESSAGES', 'EMBED_LINKS', 'ATTACH_FILES', 'READ_MESSAGE_HISTORY']}], 'reason': 'Batimius#5703 created a ticket'}" as string.
at RequestHandler.execute (C:\Users\Batman212369\Desktop\Discord Bots\LETI-Bot-V2\node_modules\discord.js\src\rest\RequestHandler.js:350:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (C:\Users\Batman212369\Desktop\Discord Bots\LETI-Bot-V2\node_modules\discord.js\src\rest\RequestHandler.js:51:14)
at async GuildChannelManager.create (C:\Users\Batman212369\Desktop\Discord Bots\LETI-Bot-V2\node_modules\discord.js\src\managers\GuildChannelManager.js:157:18)
at async Interaction.callback (C:\Users\Batman212369\Desktop\Discord Bots\LETI-Bot-V2\Cogs\ticket.js:40:22)
Not really sure why. If someone could help me, that would be awesome. Thank you for your time and help, I greatly appreciate it.
2 Replies
Lilly
Lilly3y ago
name should be as a string but you put it in the options object , https://discord.js.org/#/docs/discord.js/stable/class/GuildChannelManager?scrollTo=create , look at the exemples
Batimius
BatimiusOP3y ago
Worked like a charm. Thanks!
Want results from more Discord servers?
Add your server