Outrage
Outrage

Reputation: 57

My discord.js command doesn't work properly

I need help with my kiss command, I tried to make it so when I do !kiss, it kisses the person I mentioned. But when it tries to send the embed it doesn't send and I get an error:

Error:

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  | }

My Code:

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)
        
        
    }
}

Upvotes: 0

Views: 382

Answers (1)

Jakye
Jakye

Reputation: 6645

The issue is that you're passing an integer to setImage, not the actual image URL from responses.


.setImage(responses[randomIndex])

Upvotes: 3

Related Questions