my bot is not creating a ticket channel when a user is reacting to the emoji, the bot is only creating a ticket channel when I give my bot administrator rights within discord role itself.
What could be wrong in my code when user reacts to the emoji? Something missing, or permissions missing below? My bots ID 701327880046510080
And btw. on my discord I have given my bot all rights, but not administrator rights at the bottom of roles permissions.
Any help would be appreciated!
if(reaction.message.id == ticketid && reaction.emoji.name == '🎫') {
reaction.users.remove(user);
const ticketChannel = reaction.message.guild.channels.cache.find(chan => chan.name === `ticket-${user.username}`)
if (ticketChannel) return;
reaction.message.guild.channels.create(`ticket-${user.username}`, {
parent: '701254271861260389',
position: 1,
permissionOverwrites: [
{
id: '701327880046510080',
allow: ["MANAGE_CHANNELS", "MANAGE_GUILD", "MANAGE_ROLES", "MANAGE_EMOJIS", "READ_MESSAGE_HISTORY", "MANAGE_MESSAGES", "SEND_MESSAGES", "VIEW_CHANNEL"]
},
{
id: user.id,
allow: ["SEND_MESSAGES", "VIEW_CHANNEL", "READ_MESSAGE_HISTORY"]
},
{
id: reaction.message.guild.roles.everyone,
deny: ["VIEW_CHANNEL"]
},
{
id: '306893721725829121',
allow: ["SEND_MESSAGES", "VIEW_CHANNEL", "READ_MESSAGE_HISTORY"]
}
],
It is most defintely a permission problem as you said it only works when you give the bot admin. It could also be because of the snippet below, you are allowing the permission but then denying it to everyone.
{
id: reaction.message.guild.roles.everyone,
deny: ["VIEW_CHANNEL"]
},
Try this and let me know if/what errors you get with the await you will need to make sure that your listener is async so that may need to be added to code above this which based on the other question it should be.
if (reaction.message.id == ticketid && reaction.emoji.name == '🎫') {
reaction.users.remove(user);
const channelName = `ticket-${user.username}`;
const ticketChannel = reaction.message.guild.channels.cache.find(chan => chan.name === channelName);
if (ticketChannel) return;
const newChannel = await reaction.message.guild.channels.create(channelName, {
parent: '701254271861260389',
position: 1,
permissionOverwrites: [{
id: reaction.message.guild.id,
deny: ["VIEW_CHANNEL"],
}, {
id: user,
allow: ["SEND_MESSAGES", "VIEW_CHANNEL", "READ_MESSAGE_HISTORY"],
}, {
id: '306893721725829121',
allow: ["SEND_MESSAGES", "VIEW_CHANNEL", "READ_MESSAGE_HISTORY"],
}, {
id: '701327880046510080',
allow: ["MANAGE_CHANNELS", "MANAGE_GUILD", "MANAGE_ROLES", "MANAGE_EMOJIS", "READ_MESSAGE_HISTORY", "MANAGE_MESSAGES", "SEND_MESSAGES", "VIEW_CHANNEL"]
}],
}).catch((error) => {
console.log(error)
});
console.log(newChannel);
}
If the above fails it is likely a permission issue, just need to find out for sure what is preventing it.