简体   繁体   English

不和谐.js | JSON - 票务系统,机器人不创建票务通道

[英]Discord.js | JSON - Ticket system, bot does not create ticket channel

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我的机器人 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.试试这个,让我知道你是否/你在await时遇到了什么错误,你需要确保你的监听器是async的,因此可能需要添加到上面的代码中,这取决于它应该是的其他问题

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.如果上述方法失败,则可能是权限问题,只需要确定是什么阻止了它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM