-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
50 lines (42 loc) · 1.51 KB
/
index.js
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
const Discord = require('discord.js');
const client = new Discord.Client();
const fetch = require("node-fetch");
client.once('ready', () => {
console.log('Ready!');
});
function messageSender(message) {
fetch("https://fishbase.ropensci.org/species?limit=1&offset=" + Math.floor(Math.random() * 100))
.then(stuff => stuff.json())
.then(json => {
const dataArr = json["data"];
const info = dataArr[0];
if (info["image"] == null || info["Comments"] == null) {
messageSender(message);
return;
}
const embed = new Discord.MessageEmbed()
.setColor('#0099ff')
.setTitle(info["Genus"] + " " + info["Species"])
.addField('Common Name', info["FBname"], true)
.setDescription(info["Comments"])
.setImage(info["image"]);
message.channel.send(embed);
})
}
function make(json) {
const dataArr = json["data"];
const info = dataArr[0];
const exampleEmbed = new Discord.MessageEmbed()
.setColor('#0099ff')
.setTitle(info["Genus"] + " " + info["Species"])
.addField('Common Name', info["FBname"], true)
.setDescription(info["Comments"])
.setImage(info["image"]);
return exampleEmbed;
}
client.on('message', message => {
if (message.content.includes("fish")) {
messageSender(message);
}
});
client.login('NzcxODQ0MzU2MDg4MjY2NzUy.X5yCEg.ZRG9HXQuvdaAm3Z1VnNLsUpC9fE');