Change announcement to $2.5 instead of $5 and add image to embed

This commit is contained in:
Wizzard 2024-03-13 23:01:55 -04:00
parent 9a07443b38
commit 400d0b4dfe
2 changed files with 11 additions and 7 deletions

View File

@ -1,4 +1,5 @@
DISCORD_BOT_TOKEN=asghjkhagsahjklsg.asgkljajkgslasklgjkaslglgaslgasl DISCORD_BOT_TOKEN=asghjkhagsahjklsg.asgkljajkgslasklgjkaslglgaslgasl
SOLANA_PRICE_CHANNEL_ID=90812589702150978578625187125 SOLANA_PRICE_CHANNEL_ID=90812589702150978578625187125
ANNOUNCEMENTS_CHANNEL_ID=187290509872150987215 ANNOUNCEMENTS_CHANNEL_ID=187290509872150987215
IMAGE_URL=https://image.com/image.png

15
main.js
View File

@ -40,7 +40,7 @@ async function immediatePriceCheckAndAnnounce() {
const lastKnownPrice = solanaData ? solanaData.price : null; const lastKnownPrice = solanaData ? solanaData.price : null;
const currentPrice = await fetchSolanaPrice(); const currentPrice = await fetchSolanaPrice();
if (currentPrice && lastKnownPrice !== null && (parseFloat(currentPrice) - lastKnownPrice >= 5)) { if (currentPrice && lastKnownPrice !== null && (parseFloat(currentPrice) - lastKnownPrice >= 2.5)) {
const announcementsChannel = await client.channels.fetch(announcementsChannelId); const announcementsChannel = await client.channels.fetch(announcementsChannelId);
await announcementsChannel.send(`@everyone Significant Solana price increase detected! Previous recorded price: $${lastKnownPrice}. Current price: $${currentPrice}.`); await announcementsChannel.send(`@everyone Significant Solana price increase detected! Previous recorded price: $${lastKnownPrice}. Current price: $${currentPrice}.`);
} }
@ -60,10 +60,13 @@ async function checkPriceContinuously() {
const solanaPriceChannel = await client.channels.fetch(solanaPriceChannelId); const solanaPriceChannel = await client.channels.fetch(solanaPriceChannelId);
const embed = new EmbedBuilder() const embed = new EmbedBuilder()
.setColor(0x0099ff) .setColor(0x0099ff)
.setTitle('Solana (SOL) Price') .setThumbnail('https://solana.com/src/img/branding/solanaLogoMark.png')
.setDescription(`$${price}`) .setTitle('Solana (SOL) Price Update')
.setTimestamp(); .setDescription(`**Current Price: \`$${price}\`**`)
.addFields({ name: '💰 Current Price', value: `**\`$${price}\`**`, inline: false })
.setTimestamp()
.setImage(process.env.IMAGE_URL)
if (lastPriceMessageId) { if (lastPriceMessageId) {
try { try {
@ -79,7 +82,7 @@ async function checkPriceContinuously() {
lastPriceMessageId = sentMessage.id; lastPriceMessageId = sentMessage.id;
} }
if (lastKnownPriceAtStartup !== null && (parseFloat(price) - lastKnownPriceAtStartup >= 5)) { if (lastKnownPriceAtStartup !== null && (parseFloat(price) - lastKnownPriceAtStartup >= 2.5)) {
const announcementsChannel = await client.channels.fetch(announcementsChannelId); const announcementsChannel = await client.channels.fetch(announcementsChannelId);
await announcementsChannel.send(`@everyonle Solana price has increased significantly! Current price: $${price}`); await announcementsChannel.send(`@everyonle Solana price has increased significantly! Current price: $${price}`);
lastKnownPriceAtStartup = parseFloat(price); lastKnownPriceAtStartup = parseFloat(price);