I am trying to make a bot which will create a channel called ticket-####
(#### being 4 random digits), and then make that channel so only the person who used the command and admins in the server can see, which works fine. However, i want text after the command (in this case +create) to be posted in this new channel. I.E: If i use +create I need help with Discord
, it would make a private channel between that user and the admins and the bot would send a message in that channel which is I need help with discord
. I keep getting the error TypeError: Cannot read property 'send' of undefined
. This is my create.js code:
name: "create",
description: "Starts the channel",
execute(message, args, Discord, client) {
var fourRD = Math.floor(1000 + Math.random() * 9000);
const Embed = new Discord.MessageEmbed()
.setColor("#1e2240")
.setTitle("Ticket Created!")
.setDescription(
"Your ticket is #ticket-" +
fourRD +
". You can use this to get in touch with developers who will answer your questions."
);
message.channel.send(Embed);
message.guild.channels.create(`ticket-` + fourRD, {
type: "text",
permissionOverwrites: [
{
id: message.author.id,
allow: ["VIEW_CHANNEL"]
},
{
id: message.guild.id,
deny: ["VIEW_CHANNEL"]
}
]
});
const newchannel = client.channels.cache.find(
channel => channel.name === "ticket" + fourRD
);
newchannel.send(args[0]);
}
};
Tysm <3