-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a temporary command, it is being overhauled in the near future once other changes outside of this project have taken place - which are needed to support this feature to it's planned effect.
- Loading branch information
1 parent
fface67
commit f19c365
Showing
10 changed files
with
633 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,3 +103,4 @@ dist | |
# TernJS port file | ||
.tern-port | ||
/OldCodebase/ | ||
/src/utils/commandutils/price/priceLinks.json |
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
const {PermissionFlagsBits} = require('discord.js'); | ||
const axios = require('axios'); | ||
|
||
const priceButtons = require('../../utils/commandutils/price/priceButtons'); | ||
const priceEmbeds = require('../../utils/commandutils/price/priceEmbeds'); | ||
|
||
// THIS FILE IS TEMPORARY, IT WILL BE REPLACED AND UPDATED VERY SOON. | ||
// The changes required to get this command "flush" with the rest of the | ||
// project require me to make a few changes to my database to accommodate | ||
// the new features. I will be working on this soon, but for now, this | ||
// command will be a placeholder. | ||
|
||
module.exports = { | ||
name: 'price', | ||
description: "Get VyFi's current price and common conversions!", | ||
devOnly: false, | ||
testOnly: true, | ||
deleted: false, | ||
options: [], | ||
permissionsRequired: [PermissionFlagsBits.SendMessages], | ||
botPermissions: [PermissionFlagsBits.SendMessages], | ||
|
||
callback: async (client, interaction) => { | ||
|
||
const temp = await axios.get(`hx`).catch(console.error); | ||
const priceUSD = temp.data[`8x`].priceUSD.toFixed(2); | ||
const priceADA = 0; | ||
|
||
// For ADA price, query mariaDB for the last price. Set to 0 while this feature is implemented. | ||
// This Feature currently requires me to edit the database manager functions. | ||
|
||
interaction.reply({ | ||
embeds: [priceEmbeds.buildPriceEmbed(priceUSD, priceADA)], | ||
components: [priceButtons.buildButtons(false, null)] | ||
}).then((m) => { | ||
const collector = m.createMessageComponentCollector({time: 60000, max: 4}); | ||
|
||
collector.on('collect', async (i) => { | ||
if (!i.isButton()) return; | ||
|
||
await i.deferUpdate(); | ||
if (i.user.id !== interaction.user.id) return i.followUp({ | ||
content: `These buttons aren't for you!`, | ||
ephemeral: true | ||
}); | ||
if (i.customId === 'refresh') { | ||
const temp = await axios.get(`x`).catch(console.error); | ||
const priceUSD = temp.data[`x`].priceUSD.toFixed(2); | ||
const priceADA = 0; | ||
|
||
return i.editReply({ | ||
embeds: [priceEmbeds.buildPriceEmbed(priceUSD, priceADA)], | ||
}).catch(function () { | ||
}) | ||
} | ||
await m.interaction.editReply({components: [priceButtons.buildButtons(true, i.customId)]}) | ||
|
||
return i.followUp({ | ||
content: `Thanks for using Vyfi!`, | ||
ephemeral: true | ||
}).catch(function () { | ||
}); | ||
|
||
}); | ||
}) | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const {ButtonBuilder, ButtonStyle, ActionRowBuilder} = require('discord.js'); | ||
const {gettingStartedURL, websiteURL} = require('./priceLinks.json'); | ||
|
||
function buildButtons(toggle = false, choice) { | ||
return new ActionRowBuilder().addComponents( | ||
new ButtonBuilder() | ||
.setLabel('Website') | ||
.setURL(websiteURL) | ||
.setStyle(ButtonStyle.Link), | ||
new ButtonBuilder() | ||
.setLabel('Getting Started') | ||
.setURL(gettingStartedURL) | ||
.setStyle(ButtonStyle.Link), | ||
new ButtonBuilder() | ||
.setLabel('Refresh Price') | ||
.setCustomId('refresh') | ||
.setStyle(toggle === true && choice === 'red' ? 'Secondary' : 'Danger') | ||
) | ||
} | ||
|
||
module.exports = { | ||
buildButtons | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const {EmbedBuilder} = require('discord.js'); | ||
const {thumbnailURL, footerIconURL, githubURL} = require('./priceLinks.json'); | ||
|
||
function buildPriceEmbed(priceUSD, priceADA) { | ||
return new EmbedBuilder() | ||
.setTitle('VyFi Price') | ||
.setFields( | ||
{name: "Current USD Price", value: `$${priceUSD}`}, | ||
{name: "Current ADA Price", value: `${priceADA}₳`}, | ||
{name: "Total Supply", value: `450,000,000VyFi`}, | ||
) | ||
.setColor('#03fcdb') | ||
.setThumbnail(thumbnailURL) | ||
.setTimestamp() | ||
.setFooter({text: githubURL, iconURL: footerIconURL}); | ||
} | ||
|
||
|
||
module.exports = { | ||
buildPriceEmbed | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"gettingStartedURL": "https://docs.vyfi.io/getting-started", | ||
"websiteURL": "https://vyfi.io", | ||
"thumbnailURL": "https://app.vyfi.io/images/vyfi-logo.png", | ||
"footerIconURL": "https://avatars.githubusercontent.com/u/78691968", | ||
"githubURL": "https://github.com/AdamT20054/VyFi" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// make a few functions to fetch prices from Mariadb or any other APIs needed | ||
|
||
// create database connector in data/database/utils |