首页 > 解决方案 > 关闭票务系统不起作用... Discord.js

问题描述

您好,我的 Discord 票务系统有点问题,这让我很困惑......当它创建票务系统的频道时它不起作用,这真的让我很困惑......

代码:

Open ticket command:
const Discord = require('discord.js')


module.exports = {
    name: 'ticket',
    description: "opens a ticket",
    execute(message, args){
        const user = message.author.id;
        const name = "ticket-" + user;
        if(message.guild.channels.cache.find(ch => ch.name == name)){
            message.channel.send("You have already opened a ticket!")
        }else{
    message.guild.channels.create(name).then((chan)=>{
    chan.updateOverwrite(message.guild.roles.everyone, {
        SEND_MESSAGES: false,
        VIEW_CHANNEL: false
    })
    chan.updateOverwrite(user,{
        SEND_MESSAGES: true,
        VIEW_CHANNEL: true
    })
    message.channel.send("I have created a ticket for you! Please go to the channel at the top of the server, Only you will have access to it and it will be called ticket(id)");
    chan.send("Support will be here shortly").then((m)=>{
        m.pin()
    })
    })   

     }
    }
}

close ticket command (this is were the error is):

const Discord = require('discord.js');

module.exports = {
    name: 'endticket',
    description: "ends the ticket",
    execute(client, message, args){
        if(!message.member.hasPermission("ADMINISTRATOR")) return message.channel.send("Only a moderator can end a ticket!")

        if(message.member.hasPermission("ADMINISTRATOR")) message.channnel.delete()
    }
}

console error:

TypeError: Cannot read property 'delete' of undefined

我不明白出了什么问题...谢谢。

标签: javascriptnode.jsdiscorddiscord.jsticket-system

解决方案


推荐阅读