Repository navigation
Expand file tree
/
Copy pathapp.js
More file actions
59 lines (48 loc) · 1.77 KB
/
Copy pathapp.js
File metadata and controls
59 lines (48 loc) · 1.77 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
50
51
52
53
54
55
56
57
58
59
const Discord = require('discord.js'); // require disord.js node module
const client = new Discord.Client();
const Request = require("request"); // require request node module
client.on("message", message => {
// run if the message start with https://steemit.com
if(message.content.startsWith("https://steemit.com")){
const msg = message.content; // store input message
const url = "http://api.steemtools.cf/get_blog_count?url="; // steemtools api
const api = url.concat(msg); // generate api address
Request.get(api, (error, response, body) => { if(error) { return console.dir(error);
// Get data in JSON from API by HTTP request
}
const result = JSON.parse(body); // convert json to object
//run only when total_words value is not equal to zero or null
if(result.total_words !== 0){
message.channel.send({embed:{
author: {
name: client.user.username,
icon_url: client.user.avatarURL
},
title: message.content,
url: message.content,
fields: [{
name: "Total Words",
value: result.total_words
},
{
name: "Total Characters",
value: result.total_char
},
{
name: "Total Votes",
value: result.net_votes
}
],
footer: {
text: "This BOT is developed by © Nawab69"
}
}
}); // send embed message
};
});
};
// Here you can add more command
});
console.log('mcBOT Connected Successfully'); // Bot connected message show in terminal
// client.login("client secret"); // insert client secret here (uncomment)
client.login(process.env.BOT_TOKEN); //BOT_TOKEN is the Client Secret. Only for heroku server. (comment this line if you run own server)