Update to use new TenorJSv2
All checks were successful
NodBot PE Dockerization / build (push) Successful in 1m28s
All checks were successful
NodBot PE Dockerization / build (push) Successful in 1m28s
This commit is contained in:
parent
623070690a
commit
57f729de24
@ -1,7 +1,9 @@
|
|||||||
const fn = require('../functions');
|
const fn = require('../functions');
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const dotenv = require('dotenv').config();
|
const dotenv = require('dotenv').config();
|
||||||
|
const Tenor = require('tenorjs-v2');
|
||||||
|
|
||||||
|
const tenor = new Tenor(process.env.tenorAPIKey);
|
||||||
// TODO: Tenor has changed API versions, switch from TenorJS (unmaintained) to axios for
|
// TODO: Tenor has changed API versions, switch from TenorJS (unmaintained) to axios for
|
||||||
// general API usage. See: https://github.com/Jinzulen/TenorJS/issues/12
|
// general API usage. See: https://github.com/Jinzulen/TenorJS/issues/12
|
||||||
// see also: https://developers.google.com/tenor/guides/migrate-from-v1
|
// see also: https://developers.google.com/tenor/guides/migrate-from-v1
|
||||||
@ -15,32 +17,17 @@ module.exports = {
|
|||||||
const client = message.client;
|
const client = message.client;
|
||||||
if (!client.gifs.has(commandData.args)) {
|
if (!client.gifs.has(commandData.args)) {
|
||||||
if (process.env.isDev) console.log('https://tenor.googleapis.com/v2/search?' + `&q=${commandData.args}` + `&key=${process.env.tenorAPIKey}` + '&limit=1&contentfilter=off');
|
if (process.env.isDev) console.log('https://tenor.googleapis.com/v2/search?' + `&q=${commandData.args}` + `&key=${process.env.tenorAPIKey}` + '&limit=1&contentfilter=off');
|
||||||
const q = await axios.get(
|
tenor.search(commandData.args, "1").then(res => {
|
||||||
'https://tenor.googleapis.com/v2/search?' +
|
if (res[0] == undefined) {
|
||||||
`&q=${commandData.args}` +
|
|
||||||
`&key=${process.env.tenorAPIKey}` +
|
|
||||||
'&limit=1' +
|
|
||||||
`&contentfilter=off`
|
|
||||||
).then(res => {
|
|
||||||
if (process.env.isDev) console.log(res.data.results);
|
|
||||||
if (res.data.results[0] == undefined) {
|
|
||||||
message.reply('Sorry I was unable to find a GIF of ' + commandData.args);
|
message.reply('Sorry I was unable to find a GIF of ' + commandData.args);
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
commandData.embed_url = res.data.results[0].url;
|
commandData.embed_url = res[0].mediaUrl;
|
||||||
|
// message.reply(fn.embeds.gif(commandData));
|
||||||
|
// message.channel.send(`> ${commandData.author} - ${commandData.args}.gif`);
|
||||||
|
// message.channel.send(commandData.embed_url);
|
||||||
message.reply(commandData.embed_url);
|
message.reply(commandData.embed_url);
|
||||||
}).catch(err => console.error(err));
|
}).catch(err => console.error(err));
|
||||||
// tenor.Search.Query(commandData.args, "1").then(res => {
|
|
||||||
// if (res[0] == undefined) {
|
|
||||||
// message.reply('Sorry I was unable to find a GIF of ' + commandData.args);
|
|
||||||
// return;
|
|
||||||
// };
|
|
||||||
// commandData.embed_url = res[0].media[0].gif.url;
|
|
||||||
// // message.reply(fn.embeds.gif(commandData));
|
|
||||||
// // message.channel.send(`> ${commandData.author} - ${commandData.args}.gif`);
|
|
||||||
// // message.channel.send(commandData.embed_url);
|
|
||||||
// message.reply(commandData.embed_url);
|
|
||||||
// }).catch(err => console.error(err));
|
|
||||||
} else {
|
} else {
|
||||||
// message.reply(commandData.args + ' requested by ' + message.author.username + '\n' + client.gifs.get(commandData.args).embed_url);
|
// message.reply(commandData.args + ' requested by ' + message.author.username + '\n' + client.gifs.get(commandData.args).embed_url);
|
||||||
commandData.embed_url = client.gifs.get(commandData.args).embed_url;
|
commandData.embed_url = client.gifs.get(commandData.args).embed_url;
|
||||||
|
@ -13,7 +13,8 @@
|
|||||||
"dotenv": "^10.0.0",
|
"dotenv": "^10.0.0",
|
||||||
"fuzzy-search": "^3.2.1",
|
"fuzzy-search": "^3.2.1",
|
||||||
"mysql": "^2.18.1",
|
"mysql": "^2.18.1",
|
||||||
"tenorjs": "1.0.10"
|
"tenorjs": "1.0.10",
|
||||||
|
"tenorjs-v2": "^1.0.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^20.x"
|
"node": "^20.x"
|
||||||
|
Loading…
Reference in New Issue
Block a user