Я следовал этому уроку о том, как сделать диск-бот, все работало нормально до 33:32, где он добавил giphy-материал, который я уже установил, giphy sdk / api, создал приложение, но после того, как он сделал оператор поиска, он сказал, что вы можете консоль записать это, так что я сделал это, и были некоторые результаты gif, которые вернули undefined на моей консоли (я не знаю, почему), затем он добавил некоторые математические вещи, которые я также сделал Затем, в тот момент, когда он добавил часть обмена сообщениями, где он также добавил этот код files:[responseFinal.images.fixed_height.url]
, который затем возвратил это на моей консоли
(node:3136) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'images' of undefined
at D:\Discord bots\Oboto v2.0\index.js:24:61
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:3136) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3136) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
, и это сбило меня с толку, затем я выбрал альтернативный подход вместо того, чтобы делать giphy.search
, я сделал giphy.random
с теми же аргументами, удалил математические вещи и console.log(response)
ответ и угадаю, что это на самом деле дало мне один gif! (в консоли, конечно), а затем я применил к своему files:[]
Заявление аааа, и оно вернуло то же самое (cannot read property 'images' of undefined
) Я тоже немного новичок в раздорах. js и javascript, также вот весь мой код,
const Discord = require('discord.js');
const { prefix, token, giphyToken } = require('./config.json');
const client = new Discord.Client();
var GphApiClient = require('giphy-js-sdk-core')
giphy = GphApiClient(giphyToken)
client.once('ready', () => {
console.log('Ready!');
});
client.on('message', message => {
if (message.member.hasPermission(["KICK_MEMBERS", "BAN_MEMBERS"])){
if (message.content.startsWith(`${prefix}kick`)) {
let member = message.mentions.members.first();
member.kick().then((member) =>{
giphy.random('gifs', {'q':'fail'})
.then((response) => {
console.log(response);
message.channel.send(":wave:",{files:[response.images.fixed_height.url]});
})
})
}
}
})
client.login(token);