我的亲吻命令需要帮助,我试图让它在我执行 !kiss
时亲吻我提到的人。但是当它尝试发送嵌入时它不会发送并且我收到一个错误:
错误:
0|index | DiscordAPIError: Invalid Form Body
0|index | embed.image.url: Scheme "2" is not supported. Scheme must be one of ('http', 'https').
0|index | at RequestHandler.execute (/Users/mahdiabbas/Documents/metanoia/node_modules/discord.js/src/rest/RequestHandler.js:154:13)
0|index | at processTicksAndRejections (internal/process/task_queues.js:93:5)
0|index | at async RequestHandler.push (/Users/mahdiabbas/Documents/metanoia/node_modules/discord.js/src/rest/RequestHandler.js:39:14) {
0|index | method: 'post',
0|index | path: '/channels/808886209899397150/messages',
0|index | code: 50035,
0|index | httpStatus: 400
0|index | }
我的代码:
const Discord = require('discord.js');
const fs = require('fs');
const db = require('quick.db');
module.exports = {
name: 'kiss',
async execute(message, args) {
let mention = message.mentions.users.first();
if (!mention) {
return message.channel.send('You need to mention a user to kiss.');
}
db.add(`commandran_${message.guild.id}`, 1);
let dbfetch = db.fetch(`commandran_${message.guild.id}`);
const responses = [
"https://tenor.com/view/anime-couple-peck-cute-kiss-gif-12612515",
"https://tenor.com/view/anime-kiss-crying-cute-couple-gif-13970544",
"https://tenor.com/view/koi-to-uso-anime-kiss-gif-13344412"
];
const randomIndex = Math.floor(Math.random() * responses.length);
const kissEmbed = new Discord.MessageEmbed()
.setAuthor(`You have kissed ${mention}`)
.setFooter(`You have kissed a total of ${dbfetch} people.`)
.setImage(randomIndex)
message.channel.send(kissEmbed)
}
}
答案 0 :(得分:3)
问题在于您将整数传递给 setImage
,而不是来自 responses
的实际图像 URL。
.setImage(responses[randomIndex])