This repository has been archived by the owner on Oct 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
/
discord.js
72 lines (62 loc) · 2.9 KB
/
discord.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const { Webhook, MessageBuilder } = require('discord-webhook-node');
const config = require('./config');
const { TXID } = require ('./index')
const hook = new Webhook(config.hookurl);
const fetch = require('node-fetch')
exports.contentToDiscord = (author, permlink) => {
let params = [author, permlink];
let method = 'condenser_api.get_content'
let body = {
jsonrpc: "2.0",
method,
params,
id: 1
};
fetch(config.clientURL, {
body: JSON.stringify(body),
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
method: "POST"
})
.then(j => j.json())
.then(result => {
r = result.result
const embed = new MessageBuilder()
.setTitle(`New ${config.TOKEN} content!`)
.setAuthor(author, 'https://cdn.discordapp.com/embed/avatars/0.png', `https://${config.mainFE}/@${author}`)
.setURL(`https://${config.mainFE}/${config.tag}/@${author}/${permlink}`)
.addField(r.title, (JSON.parse(r.json_metadata).description || `View this on ${config.mainFE}`), true)
//.addField('Second field', 'this is not inline')
.setColor('#00b0f4')
//.setThumbnail('https://cdn.discordapp.com/embed/avatars/0.png')
//.setDescription('Oh look a description :)')
//.setImage('https://cdn.discordapp.com/embed/avatars/0.png')
//.setFooter('Hey its a footer', 'https://cdn.discordapp.com/embed/avatars/0.png')
.setTimestamp();
hook.send(embed)
.catch(e => console.log(e))
}).catch(e => { console.log(e) })
}
exports.renderNFTtoDiscord = (script, uid, owner, set) => {
const embed = new MessageBuilder()
.setTitle(`New ${set} NFT minted!`)
.setAuthor(owner, 'https://cdn.discordapp.com/embed/avatars/0.png', `https://${config.mainFE}/@${owner}`)
.setURL(`https://${config.mainFE}/@${owner}#inventory/`)
.addField(`${set}:${uid}`, `View this on ${config.mainFE}`, true)
//.addField('Second field', 'this is not inline')
.setColor('#00b0f4')
//.setThumbnail('https://cdn.discordapp.com/embed/avatars/0.png')
//.setDescription('Oh look a description :)')
.setImage(`https://${config.mainRender}/render/${script}/${uid}`)
//.setFooter('Hey its a footer', 'https://cdn.discordapp.com/embed/avatars/0.png')
.setTimestamp();
hook.send(embed)
.catch(e => console.log(e))
}
//exports.contentToDiscord('disregardfiat', 'dlux-development-update-jan-15')
exports.postToDiscord = (msg, id) => {
if(config.hookurl)hook.send(msg)
if(config.status)TXID.store(msg, id)
}
//great place to build a feed function to edb