【问题标题】:Copying and moving message in another channel在另一个频道中复制和移动消息
【发布时间】:2022-01-09 18:57:10
【问题描述】:

我的suggestion Script 在过去几个月里工作得很好,但几天前就停止工作了。我注意到我的.send 函数带有下划线,它是这样写的:

Property 'send' does not exist on type 'GuildChannel | ThreadChannel'.
Property 'send' does not exist on type 'GuildChannel'

我是顺便说一句。不确定这是否是脚本的问题,或者他们是否更改了我没有注意到的任何内容,并且我没有收到任何错误。脚本基本上是行不通的。

我的建议脚本:


        case "suggestion":
 
            var str = message.content.slice(" .suggestion".length);
            const suggestionembed = new Discord.MessageEmbed()
                .setThumbnail('png')
                .setTitle("Suggestion")
                .setColor('#151515')
                .addFields(
                    { name: "Person, that suggested somenthing:", value: `<@!${message.author.id}>` },
                    { name: 'Suggestion:', value: `${str}` },
                    { name: 'Channel:', value: `${message.channel}` },
                )
                .setTimestamp()

 
            await message.guild.channels.cache.find(c => c.name === 'suggestion')
                .send({ embeds: [suggestionembed] })
                .then(embedMessage => {
                    embedMessage.react("✅")
                    embedMessage.react("❌")
                });
            message.delete();
 
            break;

【问题讨论】:

    标签: discord.js


    【解决方案1】:

    如果您确定它是一个文本频道,请忽略它。那只是因为它可以是VoiceChannel。 Visual Studio Code 中没有自动完成功能,但它仍会按预期工作。如果你使用 TypeScript,你可以使用 as 告诉 TypeScript 这是一个 TextChannel

    【讨论】:

    • 您是否看到我的代码中有任何错误,但它突然停止工作,我不知道为什么
    • 你是什么意思停止工作?有什么错误吗?它只是结束 node.js 进程吗?
    • 我的意思是停止工作。我没有收到任何错误,机器人没有崩溃或任何事情。他只是不再对命令做出反应
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-08-29
    • 1970-01-01
    • 2021-11-08
    • 2021-02-06
    • 2020-01-23
    • 1970-01-01
    • 2020-08-28
    相关资源
    最近更新 更多