久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

與嵌入分開發送附件的 Djs 交互

Djs interaction sending attachment separately from embed(與嵌入分開發送附件的 Djs 交互)
本文介紹了與嵌入分開發送附件的 Djs 交互的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我試圖讓我的消息看起來像 this,但由于 interaction.reply 我得到的是 this.

I'm trying to make my message look like this, but as a result of interaction.reply I get this instead.

這是我的代碼:

fs.readdir("./pics", (error, files) => {
if (error) return console.log(error)
const num = (Math.floor(Math.random() * files.length)+1).toString();

const imagembed = new Discord.MessageEmbed()
.setTitle("Some cute pic for you!")
.setColor("#980002")
.setFooter("Requested by " + interaction.member.user.tag);
interaction.reply({ embeds: [imagembed], files: [`./pics/${num}.jpg`]})
})

有什么解決辦法嗎?

推薦答案

將圖像附加到嵌入中

在嵌入中附加圖像可以使用 <代碼>MessageEmbed.setImage().這需要一個有效的圖片鏈接.

Attaching images to embeds

Attaching images in embeds can be achieved using MessageEmbed.setImage(). This requires a valid link to picture.

自從 MessageEmbed.setImage() 是唯一的方法,要將圖像附加到嵌入中,您必須使用一些技巧.您必須將圖像作為文件發送到 MessagePayload 并將其添加到嵌入中.

Since MessageEmbed.setImage() is the only way, to attach an image to an embed, you have to use some trickery. You have to send the image as file in your MessagePayload and add it to the embed.

const embed = new discord.MessageEmbed().setImage("attachment://image.png");
interaction.reply({ embeds: [embed ], files: [`./path/to/image.png`] });


解決您的問題

對你來說,這將導致以下代碼:


Solution to your problem

For you, this would result in the following code:

fs.readdir("./pics", (error, files) => {
  if (error) return console.log(error)
  const num = (Math.floor(Math.random() * files.length) + 1).toString();

  const imagembed = new Discord.MessageEmbed()
    .setTitle("Some cute pic for you!")
    .setColor("#980002")
    .setFooter("Requested by " + interaction.member.user.tag)
    .setImage(`attachment://${num}.jpg`);
  interaction.reply({ embeds: [imagembed], files: [`./pics/${num}.jpg`] })
})

這篇關于與嵌入分開發送附件的 Djs 交互的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

discord.js v12: How do I await for messages in a DM channel?(discord.js v12:我如何等待 DM 頻道中的消息?)
how to make my bot mention the person who gave that bot command(如何讓我的機器人提及發出該機器人命令的人)
How to fix Must use import to load ES Module discord.js(如何修復必須使用導入來加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來自特定服務器的所有成員?)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務器時的歡迎消息)
主站蜘蛛池模板: 国产成人在线视频免费观看 | a欧美| 国产免费一二三区 | 日本亚洲欧美 | 日韩精品视频在线播放 | 中文字幕av网| 日本精品一区二区三区在线观看视频 | 欧美综合国产精品久久丁香 | 91社区视频| 色视频在线观看 | 精品国产一区二区在线 | 粉嫩av在线 | 久久小视频 | 免费簧片视频 | 成年人视频在线免费观看 | 欧美一区二区在线播放 | 日本 欧美 三级 高清 视频 | 成人欧美日韩一区二区三区 | 成人欧美一区二区三区1314 | a a毛片| 欧美日韩精品区 | 欧美片网站免费 | 国产欧美精品一区二区 | 久久久久国产一区二区三区不卡 | 国产高清亚洲 | 精品视频导航 | 密乳av| 国产精品一区视频 | eeuss国产一区二区三区四区 | 中国毛片免费 | 一本色道精品久久一区二区三区 | 国产高清视频 | 中文字幕日韩三级 | 久草热线 | 日韩 欧美 综合 | 伊人久久成人 | 综合在线视频 | 久久99蜜桃综合影院免费观看 | 成人免费在线播放 | 日韩最新网址 | 亚洲男人的天堂网站 |