Upgrade help from 11.3 to 14
Guys help me please upgrade my index.js file, it written in 11.3 version, for that I get error :
require('dotenv').config(); // Load .env file
const axios = require('axios');
const Discord = require('discord.js');
const client = new Discord.Client();
function getPrices() {
// API for price data.
axios
.get('https://api.genelpara.com/embed/para-birimleri.json')
.then((res) => {
// If we got a valid response
if (res.data && res.data.USD && res.data.USD.alis) {
let usdBuyPrice = parseFloat(res.data.USD.alis).toFixed(2);
client.guilds
.find((guild) => guild.id === process.env.SERVER_ID)
.me.setNickname(
USD/TL: ${usdBuyPrice}
);
console.log('Updated USD buy price to', usdBuyPrice);
} else {
console.log('Could not load USD buy price data');
}
})
.catch((err) => console.log('Error retrieving USD buy price:', err));
}
// Runs when client connects to Discord.
client.on('ready', () => {
console.log('Logged in as', client.user.tag);
getPrices(); // Ping server once on startup
// Ping the server and set the new status message every x minutes. (Minimum of 1 minute)
setInterval(getPrices, Math.max(1, process.env.PING_FREQUENCY || 1) * 60 * 1000);
});
// Login to Discord
client.login(process.env.DISCORD_TOKEN);2 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Post the full error stack trace, not just the top part!
- Show your code!
- Explain what exactly your issue is.
- Not a discord.js issue? Check out #useful-servers.
- Issue solved? Press the button!