javascript - 我的 discord.js 命令无法正常工作
问题描述
我的接吻命令需要帮助,我试图做到这一点,所以当我这样做时!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)
}
}
解决方案
问题是您将整数传递给setImage
,而不是来自 的实际图像 URL responses
。
.setImage(responses[randomIndex])
推荐阅读
- apache-spark - Apache Spark:用分号替换特定列中的每个点
- javascript - Typescript 项目 - 如何将导入的模块合并到最终构建中?
- javascript - 使用 ews-javascript-api 更新交流会议时出错
- python - 重新排序数据框的列索引
- html - IE11 Drag And Drop 在拖动时更改光标指针
- express - 在 express 中使用模型和控制器时,我似乎无法找到工作路线
- node.js - 带有等待异步问题的循环迭代
- android - 移动设备上的按钮动态填充/高度问题
- liquibase - 推荐的 Liquibase 挂钩,将执行的 SQL 审计到数据库表中
- r - 如何减少 Shiny 应用程序中的单个会话延迟以进行长时间运行的数据库查询?