我不是很有经验的javascript,我有一个问题,以显示我的附加图像。当有人输入#1机器人发送一个带有字符的嵌入,我也想发布图像!我不知道是格式错误还是应该先加载图像。因此,该图像是我的本地文件夹,与我的index.js文件位于同一目录中
我对颜色也有问题!我没有设法修改它!我没有设法修改它,我希望能够更改名称、标题或描述的颜色,但我不知道是否有可能我的测试不成功,您能帮我一点忙吗?这是我的代码。提前谢谢。
const { token, prefix } = require('../config.json');
const Discord = require('discord.js');
const client = new Discord.Client();
// Listen to the Bot being ready
client.once('ready', () => onClientReady());
function onClientReady()
{
// Listen to Messages in the channel
client.on('message', (message) => onMessageReceived(message));
}
// Upon a message being received, handle how we interact
function onMessageReceived(message)
{
if(message.author.bot) return;
if (message.content.toLowerCase().includes('#1'))
message.channel.send({ embed: {
color: 3447003,
title: "SpaceShips #1 New_York",
url: "http://google.com",
description: "RANK: 74 / SCORE: 121",
Thumbnail: (url="attachment://000793.jpg"),
fields: [{
name: "__**POWER**__",
value: "A-G 0: **39**",
"inline": true
},
{
name: "__**POWER**__",
value: "E-W: **76**",
"inline": true
},
{
name: "__**AUTONOMY**__",
value: "EY-W Nrg: **74**",
"inline": true
},
{
name: "__**AUTONOMY**__",
value: "B-P 0 Nrg: **73**",
"inline": true
},
{
name: "__**DISPLACEMENT**__",
value: "L-A: **79**",
"inline": true
},
{
name: "__**DISPLACEMENT**__",
value: "3D-V: **67**",
"inline": true
},
{
name: "__**SPECIALS**__",
value: "EM-W: **34**",
"inline": true
},
{
name: "__**SPECIALS**__",
value: "3D-W: **42**",
"inline": true
}
],
}
});
}
client.login(token);发布于 2021-09-10 15:31:22
如果您正在使用python,并且只想发送图像,请尝试以下操作:
await channel.send(file=discord.File('my_image.png'))发布于 2021-09-10 18:08:59
您可以简单地向要发送的embed对象添加一个图像值,如下所示:
message.channel.send({ embed: {
color: 3447003,
title: "SpaceShips #1 New_York",
url: "http://google.com",
description: "RANK: 74 / SCORE: 121",
thumbnail: {
url: "attachment://000793.jpg"
},
}
}); // Removed fields to clear up the clutter, you may add them like before!至于颜色,它是一个RGB值,你可以在谷歌上搜索你喜欢的颜色的值,然后替换它!
发布于 2021-09-11 17:46:17
如果你只想发送图片,我想在这里(Node.Js)
const path = require('path');
const Discord = require('discord.js');
let pic = path.resolve('test.jpg')
// the picture, if you console.log it will send the path of the file for example mine /src/image/test.jpg
message.channel.send(new Discord.MessageAttachment(pic))https://stackoverflow.com/questions/69134552
复制相似问题