aiko-chan-ai / discord.js-selfbot-v13

An unofficial discord.js fork for creating selfbots
https://discordjs-self-v13.netlify.app
GNU General Public License v3.0
777 stars 165 forks source link

Modal Not working for me #1023

Closed SatoX69 closed 8 months ago

SatoX69 commented 8 months ago

Which package has the bugs?

The core library

Issue description

I tried making a wrapper for Suno ai's chirp command, it prompts a modal box, I tried using this snippet given below but it keeps returning this error again and again Screenshot_2024-01-29-22-43-07-206_com microsoft rdc androidx

Code sample

if (!response.isMessage) {
        response.components[0].components[0].setValue(
            genre,
        );
        response.components[1].components[0].setValue(
            lyrics,
        );
        await response.reply();
    }

Package version

3.1.3

Node.js version

Node.js v18

Operating system

Windows 8

Priority this issue should have

Medium (should be fixed soon)

Checklist

Additional Information

No response

aiko-chan-ai commented 8 months ago

I'll check it later (it's midnight now)

SatoX69 commented 8 months ago

I'll check it later (it's midnight now)

Okay, goodnight.

aiko-chan-ai commented 8 months ago

Okay, goodnight.

Please send me full logs and screenshots (when using the bot) or videos if possible ;-;

aiko-chan-ai commented 8 months ago

I also need the bot's id to try the command

SatoX69 commented 8 months ago

I also need the bot's id to try the command

Sure, here's the code (may have some syntax error since I removed express):

const axios = require('axios');
const async = require('async');
const { Client, Intents, MessageAttachment } = require('discord.js-selfbot-v13');

const QUEUE = [];

const client = new Client({
  checkUpdate: false,
  intent: [
    Intents.MessageContent,
    Intents.MessageEmbed
  ]
});

client.on('ready', async () => {
  console.log(`${client.user.username} is ready`);
});

const requestQueue = async.queue(async (task, callback) => {
  const { res, handler } = task;
  await handler();
  callback();
}, 1);

function processQueue() {
  res = { message: "sorry" };
  if (QUEUE.length >= 6) {
    QUEUE.shift();
    return res;
  }
  return null;
}
const req = {
  body: {
    lyrics: "Some Random Song Lyric",
    genre: "pop",
    GPT: false
  }
}
async function server() {
  QUEUE.push("Request");
  const { lyrics, genre = "random", GPT = false } = req.body;
  if (!lyrics || lyrics.length < 8) return res.send("Include Lyrics");

  const result = processQueue();
  if (result) {
    return res.json(result);
  }
  const newResult = processQueue();
  if (newResult) {
    res.json(newResult);
  } else {
    requestQueue.push({
      res,
      handler: async () => {
        await generate(lyrics, genre, GPT, res);
      }
    });
  }
}

client.login("token");

async function generate(lyrics, genre, GPT, res) {
  const channel = client.channels.cache.get('1154828271431712878');
  try {
    const response = await channel.sendSlash('1135968813125468303', 'chirp');
    if (!response.isMessage) {
      response.components[1].components[0].setValue(lyrics);
      await response.reply();
    }

    const message = await waitForResponse();
    handleResponse(message, res);
  } catch (e) {
    throw e
  }
}

async function waitForResponse() {
  return new Promise((resolve) => {
    client.on('messageCreate', (message) => {
      if (message.author.bot && message.attachments) {
        resolve(message);
      }
    });
  });
}

function handleResponse(message, res) {
  const songs = [];
  try {
    message.attachments.forEach((attachment) => {
      songs.push({ link: attachment.url });
    });
   // res.json({ music: [...songs] })
   console.log(songs)
  } catch (x) {
    throw x
  } finally {
    QUEUE.shift();
    songs.length = 0
  }
}

setTimeout(() => {
  server()
}, 10000)

Error: 2024-01-30T17:01:19.832Z: DiscordAPIError: Invalid Form Body data.components: Must be between 3 and 3 in length. at RequestHandler.execute (C:\Users\Administrator\Desktop\DJS\node_modules\discord.js-selfbot-v13\src\rest\RequestHandler.js:391:13) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async RequestHandler.push (C:\Users\Administrator\Desktop\DJS\node_modules\discord.js-selfbot-v13\src\rest\RequestHandler.js:63:14)

Edit: Included the entire code

VillainsRule commented 8 months ago

You are submitting an invalid modal. This is an error being sent from the bot. The modal has an input that must be 3 characters length. Run the command yourself and figure out which input has this limitation.

SatoX69 commented 8 months ago

You are submitting an invalid modal. This is an error being sent from the bot. The modal has an input that must be 3 characters length. Run the command yourself and figure out which input has this limitation.

It does work when I try it myself though

Screenshot_2024-01-29-23-23-28-259_com discord-edit orca-image-1051048993

The top "describe type of music" is by default "random", the bottom "Chatgpt" part is blank (default), do I need to fill these for it to work via the self bot?

aiko-chan-ai commented 8 months ago

fixed

SatoX69 commented 8 months ago

It's working now, thanks