-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdiscord.js
58 lines (55 loc) · 1.41 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
import axios from "axios";
import { shortenAddress } from "./helper/solana.js";
export const postToDiscord = async (discordWebhook, salesData) => {
const { date, collection, mint, buyer, seller, salesPrice, signature, transactionURL } =
salesData;
const { name: exchangeName, favicon } = salesData.exchange;
const { name: nftName, image } = salesData.metadata.offChain;
const payload = {
embeds: [
{
author: {
name: `${collection} Collection`
},
title: `${nftName} → SOLD`,
url: transactionURL,
timestamp: date,
fields: [
{
name: "Price",
value: `${salesPrice} S◎L`
},
{
name: "Seller",
value: shortenAddress(seller),
inline: true
},
{
name: "Buyer",
value: shortenAddress(buyer),
inline: true
},
{
name: "Mint Token",
value: mint,
inline: true
},
{
name: "Transaction ID",
value: signature
}
],
thumbnail: {
url: image
},
footer: {
text: exchangeName,
icon_url: favicon
}
}
]
};
return axios
.post(discordWebhook, payload)
.catch(e => console.log("postToDiscord Error:", e, "\nSignature:", signature));
};