票务机器人只说 id 的

Ticket bot only saying the id's

我带着问题又回来了:)。我正在构建自己的票证功能,我才刚刚开始,但如果我为票证创建一个渠道,它只会说票证-(Discord 帐户 ID),嵌入也是如此。谁能看看?

const discord = require("discord.js");
const { MessageEmbed, Collection, Permissions} = require('discord.js');
const { execute } = require("./ticket");

module.exports = {
    name: 'create',
    description: 'create your own ticket.',
    execute(message, client, args){

        if(message.guild.channels.cache.find(channel => channel.name ===   "Ticket from <@" + message.author + ">")) {
            message.reply(`${message.member.user.toString()} **You have successfully created a ticket, Please click on ${channel} to view your ticket**`).then(m => m.delete({ timeout: 14000 }).catch(e => {}));

            if(message.guild.channels.cache.find(channel => channel.name === `ticket-${message.author.id}`)) {
                return message.reply('<a:no:784463793366761532> **You already have a ticket, please close your exsisting ticket first before opening a new one**');
        }

        message.delete();

        message.guild.channels.create(`Ticket ${message.author}`, {
            permissionOverwrites: [
                {
                    id: message.author.id,
                    allow: ['SEND_MESSAGES', 'VIEW_CHANNEL'],
                },
                {
                    id: message.guild.roles.everyone,
                    deny: ['VIEW_CHANNEL'],
                },
            ],
            type: 'text',
        }).then(async channel => {
            const embed = new MessageEmbed()
            .setTitle("<@" + message.author + "> Ticket")
            .setDescription(`**${message.author}, Welcome to your channel! Support will be arriving soon**\n**While you wait please tell us what your problem is**\n**If you want to close the ticket please type .close\`**`)
            .setColor("BLUE")
            channel.send({ embeds: [embed] })
        });
    }
}
}

我稍微清理了一下代码,少即是多。文本频道中没有空格,所以我用 Discord 使用的 hypens 替换了它们。下面的代码将检查一个频道是否已经存在,如果不存在则创建一个。

const {
    MessageEmbed,
} = require('discord.js');

module.exports = {
    name: 'create',
    description: 'create your own ticket.',
    async execute(message, client, args) {
        const channelName = `ticket-${message.author.username}`
        const existing = message.guild.channels.cache.find(channel => channel.name === channelName.toLowerCase());

        if (existing) {
            return message.reply({
                content: `<a:no:784463793366761532> **You already have a ticket, please close your exsisting ticket first before opening a new one**\n${existing}.`,
            }).then((m) => {
                setTimeout(() => {
                    m.delete();
                }, 14000);
            })
        }

        message.delete();

        message.guild.channels.create(channelName, {
            type: 'GUILD_TEXT',
            permissionOverwrites: [{
                id: message.guild.id,
                deny: ['VIEW_CHANNEL'],
            }, {
                id: message.author.id,
                allow: ['SEND_MESSAGES', 'VIEW_CHANNEL'],
            }],
        }).then(async channel => {
            const embed = new MessageEmbed()
                .setColor("BLUE")
                .setTitle(`${message.author.username} Ticket`)
                .setDescription(`**${message.author}, Welcome to your channel! Support will be arriving soon**\n**While you wait please tell us what your problem is**\n**If you want to close the ticket please type .close\`**`)
            channel.send({
                embeds: [embed]
            })
        });
    }
}