TechSupport
TechSupport
DIAdiscord.js - Imagine an app
Created by TechSupport on 6/24/2024 in #djs-questions
Running commands asynchronously
I have a script that uses puppeteer to webscrape different URL's based on user's choice. I wanted to know if there's a way to run commands asnychronously. So when my code is scraping Data from websites inside of loops doing all kinds of stuffs. Whenever I write /stop or /start or any other command. I want it to run. Is this possible?
33 replies
DIAdiscord.js - Imagine an app
Created by TechSupport on 3/14/2024 in #djs-questions
Discord Embed not sending
Code
if (previousTokenAddress !== rowData.tokenAddress) {
console.log('rowData:', rowData); // Log rowData to check its values

const embed = new EmbedBuilder()
.setTitle(rowData.tokenName)
.addFields(
{ name: 'Token Address', value: rowData.tokenAddress },
{ name: 'Amount', value: rowData.amount })
.setImage(rowData.tokenImage)
.setFooter({ text: rowData.timestamp, icon_url: rowData.tokenImage});

console.log('Embed:', embed.toJSON());
previousTokenAddress = rowData.tokenAddress; // Update previous token address
const channel = await discordClient.channels.fetch('1217259060227866664');
await channel.send({ embed });
}
if (previousTokenAddress !== rowData.tokenAddress) {
console.log('rowData:', rowData); // Log rowData to check its values

const embed = new EmbedBuilder()
.setTitle(rowData.tokenName)
.addFields(
{ name: 'Token Address', value: rowData.tokenAddress },
{ name: 'Amount', value: rowData.amount })
.setImage(rowData.tokenImage)
.setFooter({ text: rowData.timestamp, icon_url: rowData.tokenImage});

console.log('Embed:', embed.toJSON());
previousTokenAddress = rowData.tokenAddress; // Update previous token address
const channel = await discordClient.channels.fetch('1217259060227866664');
await channel.send({ embed });
}
embed.toJSON()
rowData: {
timestamp: '19 minutes ago',
amount: '+ 422,485.52',
tokenName: 'dibats',
tokenImage: 'https://bafkreibznbc5gktcsujoogybiphcmk46fekxlelly3v4x5sgh6e52qtrye.ipfs.nftstorage.link',
tokenAddress: 'CXSnY5JHZcGKWApubGkjm1fAYnuTHYoTy5diPiYHVbjM'
}
Embed: {
title: 'dibats',
fields: [
{
name: 'Token Address',
value: 'CXSnY5JHZcGKWApubGkjm1fAYnuTHYoTy5diPiYHVbjM'
}
]
}
rowData: {
timestamp: '19 minutes ago',
amount: '+ 422,485.52',
tokenName: 'dibats',
tokenImage: 'https://bafkreibznbc5gktcsujoogybiphcmk46fekxlelly3v4x5sgh6e52qtrye.ipfs.nftstorage.link',
tokenAddress: 'CXSnY5JHZcGKWApubGkjm1fAYnuTHYoTy5diPiYHVbjM'
}
Embed: {
title: 'dibats',
fields: [
{
name: 'Token Address',
value: 'CXSnY5JHZcGKWApubGkjm1fAYnuTHYoTy5diPiYHVbjM'
}
]
}
10 replies