fetch the new created channel

const { SlashCommandBuilder,PermissionFlagsBits } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('create')
.setDescription('add'),
async execute(interaction) {
interaction.guild.channels.create({
name: 'testticket',
reason: 'ticket',
permissionOverwrites: [
{
id: interaction.guild.roles.everyone,
deny: [PermissionFlagsBits.ViewChannel],
},
],
});
channels.fetch();
const newchannel = channel.id;
await interaction.reply(` ${interaction.user.username} created a ticket at${newchannel}`);
},
};
const { SlashCommandBuilder,PermissionFlagsBits } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('create')
.setDescription('add'),
async execute(interaction) {
interaction.guild.channels.create({
name: 'testticket',
reason: 'ticket',
permissionOverwrites: [
{
id: interaction.guild.roles.everyone,
deny: [PermissionFlagsBits.ViewChannel],
},
],
});
channels.fetch();
const newchannel = channel.id;
await interaction.reply(` ${interaction.user.username} created a ticket at${newchannel}`);
},
};
6 Replies
d.js toolkit
d.js toolkit4mo 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! - Marked as resolved by OP
TÆMBØ
TÆMBØ4mo ago
create() resolves to a channel object that is the channel that was created, so just make a variable from that resolved Promise
d.js docs
d.js docs4mo ago
:method: GuildChannelManager#create() Creates a new channel in the guild.
Unicorn.
Unicorn.4mo ago
const { ExportReturnType } = require('discord-html-transcripts');
const { SlashCommandBuilder,PermissionFlagsBits, channelLink } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('create')
.setDescription('add'),
async execute(interaction) {
interaction.guild.channels.create({
name: 'testticket',
reason: 'ticket',
permissionOverwrites: [
{
id: interaction.guild.roles.everyone,
deny: [PermissionFlagsBits.ViewChannel],
},
],
})
.then(id =>interaction.reply(` ${interaction.user.username} created a ticket at${id}`))
.then(setParent => setParent('1111581547087278080'))
.catch(console.error);
},
};
const { ExportReturnType } = require('discord-html-transcripts');
const { SlashCommandBuilder,PermissionFlagsBits, channelLink } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('create')
.setDescription('add'),
async execute(interaction) {
interaction.guild.channels.create({
name: 'testticket',
reason: 'ticket',
permissionOverwrites: [
{
id: interaction.guild.roles.everyone,
deny: [PermissionFlagsBits.ViewChannel],
},
],
})
.then(id =>interaction.reply(` ${interaction.user.username} created a ticket at${id}`))
.then(setParent => setParent('1111581547087278080'))
.catch(console.error);
},
};
how to use setparent when in then
Danial
Danial4mo ago
You can pass in the parent when creating the channel with the parent property Also, setParent in that second .then would be InteractionResponse and you can't call it
Unicorn.
Unicorn.4mo ago
oh i get it