mirror of
https://github.com/stronk-dev/RandomChad.git
synced 2025-07-05 02:35:08 +02:00
✨ add discord webhook functionality to the changing room
This commit is contained in:
parent
6e3760d36c
commit
2c1f80a045
@ -1,4 +1,6 @@
|
||||
## Requirements
|
||||
|
||||
- [ ] `./functions`: set Infura project ID through `firebase functions:config:set infura.projectid=`
|
||||
- [ ] also set `integration.secret`
|
||||
- [ ] also set `discord.webhookurl`
|
||||
- [ ] `./functions/package.json`: dependencies for backend, run `npm i` in `./functions`
|
||||
|
@ -3,13 +3,13 @@ const { getRgbArrayFromColorName, randomNumberBetween } = require( '../modules/h
|
||||
const { getTokenIdsOfAddress } = require( '../modules/contract' )
|
||||
const svgFromAttributes = require( './svg-generator' )
|
||||
const Throttle = require( 'promise-parallel-throttle' )
|
||||
const { notifyDiscordWebhook } = require( '../integrations/discord' )
|
||||
|
||||
// ///////////////////////////////
|
||||
// Rocketeer generator
|
||||
// ///////////////////////////////
|
||||
async function generateNewOutfitFromId( id, network='mainnet' ) {
|
||||
|
||||
|
||||
/* ///////////////////////////////
|
||||
// Changing room variables
|
||||
// /////////////////////////////*/
|
||||
@ -87,8 +87,19 @@ async function generateNewOutfitFromId( id, network='mainnet' ) {
|
||||
// Path format of new rocketeers is id-outfitnumber.{svg,jpg}
|
||||
try {
|
||||
|
||||
// Generate new outfit
|
||||
const newOutfitSvg = await svgFromAttributes( rocketeer.attributes, `${ network }Rocketeers/${ id }-${ available_outfits + 1 }` )
|
||||
|
||||
// Notify discord
|
||||
const [ firstname ] = rocketeer.name.split( ' ' )
|
||||
await notifyDiscordWebhook(
|
||||
rocketeer.name,
|
||||
`${ firstname } obtained a new outfit on ${ network }!`,
|
||||
rocketeer.image,
|
||||
`Outfit #${ available_outfits + 1 }`,
|
||||
newOutfitSvg.replace( '.svg','.jpg' )
|
||||
)
|
||||
|
||||
return newOutfitSvg
|
||||
|
||||
} catch( e ) {
|
||||
|
14
functions/package-lock.json
generated
14
functions/package-lock.json
generated
@ -3837,6 +3837,15 @@
|
||||
"resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz",
|
||||
"integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8="
|
||||
},
|
||||
"isomorphic-fetch": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-3.0.0.tgz",
|
||||
"integrity": "sha512-qvUtwJ3j6qwsF3jLxkZ72qCgjMysPzDfeV240JHiGZsANBYd+EEuu35v7dfrJ9Up0Ak07D7GGSkGhCHTqg/5wA==",
|
||||
"requires": {
|
||||
"node-fetch": "^2.6.1",
|
||||
"whatwg-fetch": "^3.4.1"
|
||||
}
|
||||
},
|
||||
"isstream": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
|
||||
@ -6366,6 +6375,11 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"whatwg-fetch": {
|
||||
"version": "3.6.2",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.6.2.tgz",
|
||||
"integrity": "sha512-bJlen0FcuU/0EMLrdbJ7zOnW6ITZLrZMIarMUVmdKtsGvZna8vxKYaexICWPfZ8qwf9fzNq+UEIZrnSaApt6RA=="
|
||||
},
|
||||
"whatwg-mimetype": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-3.0.0.tgz",
|
||||
|
@ -21,6 +21,7 @@
|
||||
"express": "^4.17.1",
|
||||
"firebase-admin": "^10.0.0",
|
||||
"firebase-functions": "^3.11.0",
|
||||
"isomorphic-fetch": "^3.0.0",
|
||||
"jsdom": "^18.0.0",
|
||||
"promise-parallel-throttle": "^3.3.0",
|
||||
"puppeteer": "^12.0.0",
|
||||
|
Loading…
x
Reference in New Issue
Block a user