首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我的bot发送一个对所有用户都是不可见的嵌入,并且不显示发送的消息。

我的bot发送一个对所有用户都是不可见的嵌入,并且不显示发送的消息。
EN

Stack Overflow用户
提问于 2022-03-04 02:49:35
回答 1查看 541关注 0票数 -4

我一直在使用JS为我的服务器创建一个简单的不和谐机器人。我一直试图让它发送一条包含服务器规则的消息。当运行/rules命令时,我会收到一个通知来声明已经发送了一条消息,但是在任何设备上都看不到消息。我能够查看消息历史,所以我不明白为什么没有可见的嵌入或消息。

我的代码是使用Autocode的不和谐嵌入生成器制作的,并且在同一个Bot中为其他嵌入器工作过。在Builder中查看完整嵌入代码并查看其外观的链接是这里

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-03-04 22:28:45

学习自己制作这些代码要比使用生成器并试图反向设计它们的编码方式要容易得多:

一个简单的例子是:

代码语言:javascript
复制
const {
    MessageEmbed
} = require('discord.js')

module.exports = {
    name: "rules",
    description: "Post rules",

    run: async (client, interaction) => {

// build the message
        const embed = new MessageEmbed()
            .setColor('#00ff00') //change the color if you want
            .setTitle('Some Title')
            .setDescription(`Some description`)
            .addFields({
                name: 'Rule Name/Number',
                value: 'Rule text',
                inline: true
            }, {
                name: 'Rule Name/Number',
                value: `Rule text`,
                inline: true
            }, {
                name: 'Rule Name/Number',
                value: 'Rule text',
                inline: true
            })
// add more if needed


// send the message
        interaction.channel.send({
            embeds: [embed]
        })

// confirm they are sent and complete the interaction only visible to you
        return interaction.reply({
            content: 'Done',
            ephemeral: true
        })
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71346081

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档