andyyyy
andyyyy
DIAdiscord.js - Imagine an app
Created by andyyyy on 12/21/2023 in #djs-questions
i keep failing when i try to make a bot that grabs a image from a api
kk
13 replies
DIAdiscord.js - Imagine an app
Created by andyyyy on 12/21/2023 in #djs-questions
i keep failing when i try to make a bot that grabs a image from a api
/home/runner/FittingJointLaboratory/index.js:2 const fetch = require('node-fetch'); ^ Error [ERR_REQUIRE_ESM]: require() of ES Module /home/runner/FittingJointLaboratory/node_modules/node-fetch/src/index.js from /home/runner/FittingJointLaboratory/index.js not supported. Instead change the require of /home/runner/FittingJointLaboratory/node_modules/node-fetch/src/index.js in /home/runner/FittingJointLaboratory/index.js to a dynamic import() which is available in all CommonJS modules. at Object.<anonymous> (/home/runner/FittingJointLaboratory/index.js:2:15) { code: 'ERR_REQUIRE_ESM' } Node.js v20.10.0
13 replies
DIAdiscord.js - Imagine an app
Created by andyyyy on 12/21/2023 in #djs-questions
i keep failing when i try to make a bot that grabs a image from a api
and the error is
13 replies
DIAdiscord.js - Imagine an app
Created by andyyyy on 12/21/2023 in #djs-questions
i keep failing when i try to make a bot that grabs a image from a api
const Discord = require('discord.js'); const fetch = require('node-fetch'); const client = new Discord.Client(); const prefix = '!'; client.on('ready', () => { console.log(Logged in as ${client.user.tag}!); }); client.on('message', async (message) => { if (!message.content.startsWith(prefix) || message.author.bot) return; const args = message.content.slice(prefix.length).trim().split(/ +/); const command = args.shift().toLowerCase(); if (command === 'image') { const apiUrl = 'https://dog.ceo/api/breeds/image/random'; try { const response = await fetch(apiUrl); const data = await response.json(); if (data && data.image) {
message.channel.send(data.image); } else { message.channel.send('No image found.'); } } catch (error) { console.error('Error fetching image:', error); message.channel.send('Error fetching image.'); } } }); client.login('no token 4 u');
13 replies
DIAdiscord.js - Imagine an app
Created by andyyyy on 12/21/2023 in #djs-questions
i keep failing when i try to make a bot that grabs a image from a api
13 replies
DIAdiscord.js - Imagine an app
Created by andyyyy on 12/21/2023 in #djs-questions
i keep failing when i try to make a bot that grabs a image from a api
kk
13 replies