Skip to content

Commit

Permalink
Updated with new API
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamT20054 committed May 29, 2022
1 parent 00d59f0 commit fa05e89
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 16 deletions.
Binary file not shown.
Empty file.
Binary file added .vs/slnx.sqlite
Binary file not shown.
2 changes: 1 addition & 1 deletion cooldownvalue.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3600000
3600000
2 changes: 1 addition & 1 deletion gasvalue.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
70
200
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions src/Events/ready.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ module.exports = new Event("ready", client => {
let i = 0 // for the alternating status
try {
setInterval(async () => {
const slow = await axios.get(`https://ethergas.io/low`);
const standard = await axios.get(`https://ethergas.io/standard`);
const fastest = await axios.get(`https://ethergas.io/fast`);
const res = await `https://www.ethgasstation.info/api/ethgasAPI.json`;

client.user.setActivity(`${fastest.data} | ${standard.data} | ${slow.data}`)
client.user.setActivity(`${res.data.fastest} | ${res.data.average} | ${res.data.slow}`)

}, 15000);
}
Expand Down
17 changes: 9 additions & 8 deletions src/Structures/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,18 @@ class Client extends Discord.Client {
async watchGas() {
const res = await axios.get(this.endpoint).catch(console.error);
const gasvalue = fs.readFileSync("gasvalue.json").toString();
console.log(res)

if (!res)
return setTimeout(() => { this.watchGas(); }, 500000);

const gas = res.data;
const gas = res.data.average;

if ((gas) <= gasvalue && (ping() == true )) {
cooldownfunc()
const slow = await axios.get(`https://ethergas.io/low`);
const standard = await axios.get(`https://ethergas.io/standard`);
const fastest = await axios.get(`https://ethergas.io/fast`);
const slow = res.data.safelow;
const standard = res.data.average;
const fastest = res.data.fastest;

// Construct embed
const pingEmbed = new Discord.MessageEmbed();
Expand All @@ -66,15 +67,15 @@ class Client extends Discord.Client {
.setColor("#00FFFF")
.addFields({
name: "Fastest",
value: `${fastest.data}`,
value: `${fastest}`,
inline: true
},{
name: "Standard",
value: `${standard.data}`,
value: `${standard}`,
inline: true
}, {
name: "Slowest",
value: `${slow.data}`,
value: `${slow}`,
inline: true
});

Expand All @@ -89,7 +90,7 @@ class Client extends Discord.Client {
}

get endpoint() {
return `https://ethergas.io/standard`;
return `https://www.ethgasstation.info/api/ethgasAPI.json`;
}

start(token) {
Expand Down

0 comments on commit fa05e89

Please sign in to comment.