3 回答

TA貢獻2019條經驗 獲得超9個贊
您可以使用 a MessageEmbed
,如 programmerRaj 所說,或使用embed
以下屬性MessageOptions
:
const {MessageEmbed} = require('discord.js')
const embed = new MessageEmbed()
.setTitle('some title')
.setDescription('some description')
.setImage('image url')
// Discord.js v13
// These two are the same thing
channel.send({embeds: [embed]})
channel.send({
embeds: [{
title: 'some title',
description: 'some description',
image: {url: 'image url'}
}]
})
// Discord.js v12
// These two are the same thing
channel.send(embed)
channel.send({
embed: {
title: 'some title',
description: 'some description',
image: {url: 'image url'}
}
})
要在特定頻道中發送嵌入的用戶消息,您可以這樣做,client您的 Discord.js 在哪里Client:
// The channel that you want to send the messages to
const channel = client.channels.cache.get('channel id')
client.on('message',message => {
// Ignore bots
if (message.author.bot) return
// Send the embed
const embed = new MessageEmbed()
.setDescription(message.content)
.setAuthor(message.author.tag, message.author.displayAvatarURL())
channel.send({embeds: [embed]}).catch(console.error)
// Discord.js v12:
// channel.send(embed).catch(console.error)
})
請注意,上面的代碼將為不是由機器人發送的每條消息發送嵌入,因此您可能需要修改它,以便它僅在您需要時發送。
我建議閱讀Discord.js 的嵌入指南( archive ) 或上面鏈接的文檔,以獲取有關如何使用嵌入的更多信息。

TA貢獻1828條經驗 獲得超3個贊
此鏈接將帶您進入在線嵌入工具,該工具可根據您的意愿和想法自動創建 Discord 嵌入。這當然可以幫助你。
試試這個:-> https://autocode.com/tools/discord/embed-builder/

TA貢獻1900條經驗 獲得超5個贊
我認為你需要的是:
const Discord = require('discord.js');
const client = new Discord.Client()
client.on("message", async message =>{
if(message.author.bot) return;
if(message.channel.id === 'channelID'){
message.delete();
const newEmbed = new Discord.MessageEmbed()
.setAuthor(message.author.tag, message.author.displayAvatarURL())
.setDescription(`${message.content}`)
.setColor('#d32256')
.setImage(message.attachments.first().proxyURL)
.setTimestamp()
.setFooter('Instagram', 'ImageOfInsta');
message.channel.send(newEmbed);
},
});
其中 channelID 表示:您希望機器人重新發布的頻道和 ImageOfInsta:instagram 徽標的圖像!我通常先下載圖像或徽標,然后在 Discord 中重新上傳它。然后我在我的代碼中使用 Discord Image 的鏈接。
PS 此代碼僅在您上傳帶有短信的圖片時有效!
添加回答
舉報