【问题标题】:Discord Bot - Random Command + EmbedDiscord Bot - 随机命令 + 嵌入
【发布时间】:2019-04-19 03:31:04
【问题描述】:

喂!

所以,我制作了一个不和谐的机器人,它使用一个命令从变量列表中随机挑选一部动漫。但由于我是新手,我有点不知道如何将它与嵌入相结合,这意味着选择项显示在嵌入中。

var facts = ["Item1", "Item2", "Item 3", "Item 4" ];
var fact = Math.floor(Math.random() * facts.length);

if (message.content.startsWith (prefix + "random")){
message.channel.send(facts[fact])
}

我尝试了几件事,但我的尝试都不值得在这里展示 - 我希望这足以让代码获得在此处发布它的权限。

【问题讨论】:

    标签: bots embed discord


    【解决方案1】:

    假设您使用 Discord.js 是因为您的代码看起来像 Javascript,请查看 AnIdiotsGuide 关于 Discord.js 在消息中的嵌入。

    对于一个非常基本的嵌入,您的代码需要类似于

    if (message.content.startsWith (prefix + "random")){
        message.channel.send({embed: {
            color: 3447003, // Or any other color desired
            description: "Here is your random Fact: " + facts[fact]
        }});
    }
    

    【讨论】:

      猜你喜欢
      • 2021-01-06
      • 2020-05-11
      • 2021-12-21
      • 2021-01-31
      • 2021-11-14
      • 2021-02-05
      • 1970-01-01
      • 2018-03-04
      • 1970-01-01
      相关资源
      最近更新 更多