Change announcement to $2.5 instead of $5 and add image to embed
This commit is contained in:
parent
9a07443b38
commit
400d0b4dfe
|
@ -2,3 +2,4 @@ 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
|
13
main.js
13
main.js
|
@ -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}.`);
|
||||||
}
|
}
|
||||||
|
@ -61,9 +61,12 @@ async function checkPriceContinuously() {
|
||||||
|
|
||||||
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);
|
||||||
|
|
Loading…
Reference in New Issue