提问者:小点点

discord.js;&suggest[建议],使用${message},只想发送[建议],不带命令;怎么去?


我目前正在做我的建议机器人。你可以使用&;suggest[建议]触发它,然后机器人用[建议]发送一个嵌入到特定频道。问题是机器人也会发送命令。

示例:玩家:&建议制定一个更好的投票系统。BOT:&建议制定一个更好的投票系统。

但是我想:玩家:&建议制定一个更好的投票系统。BOT:做一个更好的投票系统。

我的宝贝:

execute(message) {

        const exampleEmbed = new Discord.MessageEmbed()
            .addField('Thank you for creating a suggestion to improve the network:', `${message}`, true)
        channel.send({ embed: exampleEmbed });
}; //cood is shorted so the cood shouldnt work atm. I just wanna know how send the message without the command

谢谢你的帮助!:)


共1个答案

匿名用户

您可以使用substring()将字符串前面的前几个字符去掉,只保留建议。

//message: "&suggest helpful suggestion" 
const suggestion = message.content.substring(9)
const exampleEmbed = new Discord.MessageEmbed()
            .addField('Thank you for creating a suggestion to improve the network:', `${suggestion}`, true)
        channel.send({ embed: exampleEmbed });