I'm trying to make a ticket system for my discord bot but I can't figure out why excatly this part of code isn't working. I'm using discord.js v13.
So basically I have made this embed with reaction which is meant to be pressed and bot creates new text channel.
And here is my code for creating new ticket after pressing reaction on embed:
client.on('messageReactionAdd', async (reaction, user) => {
if(user.partial) await user.fetch();
if(reaction.partial) await reaction.fetch();
if(reaction.message.partial) await reaction.message.fetch();
if(user.bot) return;
const ticketid = await settings.get(`${reaction.message.guild.id}-ticket`);
if(!ticketid) return;
if(reaction.message.id == ticketid && reaction.emoji.name == '🎫') {
reaction.users.remove(user);
reaction.message.guild.channels.create(`ticket-${user.username}`, {
permissionOverwrites: [
{
id: user.id,
allow: ["SEND_MESSAGES", "VIEW_CHANNEL"]
},
{
id: reaction.message.guild.roles.everyone,
deny: ["VIEW_CHANNEL"]
}
],
type: 'text'
}).then(async channel => {
channel.send({ embeds: [new MessageEmbed().setTitle("Sveicināts `<@${user.id}>`!").setDescription("Lai saņemtu palīdzību raksti šajā kanālā.").setColor("FFFA33")] })
})
}
});
Can someone please help me, I've been trying to make this work for days now.
you need to use collector https://discord.js.org/#/docs/main/stable/class/Collector or check the guide https://discordjs.guide/popular-topics/collectors.html#basic-reaction-collector