首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将图像附加到嵌入

如何将图像附加到嵌入
EN

Stack Overflow用户
提问于 2019-01-07 10:02:27
回答 1查看 15.1K关注 0票数 0

我已经试着弄清楚这个问题有一段时间了。我想不出如何让机器人将图像附加到嵌入式上。我正在尝试从我的电脑上传一张照片。

代码语言:javascript
复制
const commando = require('discord.js-commando');
const discord = require('discord.js')

class HoundCommand extends commando.Command {
  constructor(client) {
    super(client, {
      name: 'hound',
      group: 'simple',
      memberName: 'hound',
      description: 'Tells info about hound'
    });
  }

  async run(message, args) {
    var myInfo = new discord.RichEmbed()
      .setTitle("Hound")
      .addField("Name", "Hound")
      .addField("Age", "12")
      .addField("Description", "Im good at siege, I stream occasionally and ya")
      .setColor("#020B0C")
    message.channel.sendEmbed(myInfo);
  }
}

module.exports = HoundCommand;
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-01-07 10:28:56

因为你想从你的本地磁盘上传你的图像,所以你需要准确地说出不一致嵌入。每个embed都有一个.attachFile()方法,你可以从本地磁盘上传一个文件,并通过以下语法直接在你的embed中使用它:attachment://fileName.extension

因此,以一个名为avatar.png的文件为例,您需要

代码语言:javascript
复制
var myInfo = new discord.RichEmbed()
  .setTitle("Hound")
  .addField("Name", "Hound")
  .addField("Age", "12")
  .addField("Description", "Im good at siege, I stream occasionally and ya")
  .setColor("#020B0C")
  .attachFile('./avatar.png')
  .setImage('attachment://avatar.png');
message.channel.sendEmbed(myInfo);

如果您需要一次上传多个文件,请使用.attachFiles()方法。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54067769

复制
相关文章

相似问题

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