Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

71
Vistas
Tenor API search varied results

I'm making a Discord bot. Currently where if you type -gif **arguments** it uses the Tenor API and posts the result of the gif within a message which does work currently fine, but it always gives me the same result with the same search query. My code is below, so how would I make it to where I could vary the search results of a search with the same query?

const Tenor = require("tenorjs").client({
    "Key": "Ihaveakeyjustnotshowingit", // https://tenor.com/developer/keyregistration
    "Filter": "off", // "off", "low", "medium", "high", not case sensitive
    "Locale": "en_US", // Your locale here, case-sensitivity depends on input
    "MediaFilter": "minimal", // either minimal or basic, not case sensitive
    "DateFormat": "MM/D/YYYY - H:mm:ss A" // Change this accordingly
});

const fs = require('fs');
const discord = require('discord.js');


module.exports = {
    name: 'gif',
    aliases: ['tenor', 'gifsearch', 'gf'],
    category: 'Funny',
    utilisation: '{prefix}gif',

    execute(client, message, args) {

        const msgArgs = message.content.slice(this.name.length + 1)

        Tenor.Search.Query(msgArgs, "1").then(Results => {
            Results.forEach(Post => {
                message.channel.send(Post.itemurl)
            });
      }).catch(console.error);
    },
};
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

    Tenor.Search.Query(msgArgs, '10').then(Results => {
             var totalResponses = Results.length;
             var responseIndex = Math.floor(Math.random() * 10 + 1) % totalResponses;
             var responseFinal = Results[responseIndex];
            message.channel.send(responseFinal.itemurl)
    }).catch(console.error);
}

Request 10 responses, choose one random from the incoming responses and use it in the message.channel.send section! Note: Tried, works.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda