Repository navigation
Expand file tree
/
Copy pathbot.js
More file actions
49 lines (42 loc) · 1.46 KB
/
Copy pathbot.js
File metadata and controls
49 lines (42 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const Discord = require('discord.js');
const fetch = require("node-fetch");
const client = new Discord.Client();
const api = "https://ethgasstation.info/api/ethgasAPI.json?";
const csv=require('csvtojson');
const fs = require('fs');
const util = require('util');
var currentPrice = 0;
function getPrices() {
return fetch(api)
.then(response => response.json())
.then(data => currentPrice =(data['average']/10));
};
getPrices().then(result => console.log('here', result));
function setStatus() {
getPrices().then(
console.log('setStatus to ', currentPrice + " gwei")).then(
client.user.setActivity(String(currentPrice + " gwei"), { type: 'WATCHING' })
);
}
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
console.log(currentPrice);
});
client.on('ready', () => {
setInterval(() => setStatus(), 60000);
});
client.on('message', msg => {
if (msg.author.bot == true) {return;}
if (msg.content === 'ping') {
msg.reply('pong');
} else if (String(msg.content) == ('gas') || String(msg.content) == ('!gas') || String(msg.content) == ('Gas') || String(msg.content) == ('GAS')) {
getPrices().then(
msg.reply('ETH gas is currently: ' + String(currentPrice + " gwei ⛽"))
);
} else if (String(msg.content).includes('wen moon')) {
msg.reply('Soon :tm:');
} else if (String(msg.content).includes('hands')) {
msg.reply(':hand_splayed::diamonds::hand_splayed:');
};
});
client.login(process.env.BOT_TOKEN);