-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #216 from kgpmask/discord-hooks
Separate discord hooks
- Loading branch information
Showing
10 changed files
with
97 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const axios = require('axios'); | ||
const hooks = !PARAMS.discordless ? JSON.parse(process.env.DISCORD_HOOKS) : {}; | ||
|
||
async function deployErrorHook (env, commit, err) { | ||
// env: prod | dev | ||
const webhookLink = hooks.deploy; | ||
const webhookObject = { | ||
embeds: [ | ||
{ | ||
title: `Deploy failed in ${env}`, | ||
fields: [ | ||
{ name: 'Error', value: `${err}` }, | ||
{ name: 'Commit', value: `\`${commit.id.slice(0, 7)}\` ${commit.message}` } | ||
] | ||
} | ||
] | ||
}; | ||
await axios.post(webhookLink, webhookObject); | ||
return 'Success'; | ||
} | ||
|
||
async function submissionHook (data) { | ||
const webhookLink = hooks.submission; | ||
const dataTypes = { | ||
'dig-art': 'Digital Art', | ||
'trd-art': 'Traditional Art', | ||
'amv-vid': 'AMV Video', | ||
'ani-vid': 'Animation Video', | ||
'ins-mus': 'Instrumental Music', | ||
'voc-mus': 'Vocal Music' | ||
}; | ||
const webhookObject = { | ||
embeds: [ | ||
{ | ||
title: `Submission: ${ dataTypes[data.type] }`, | ||
fields: [ | ||
{ name: 'Email', value: `${ data.email }` }, | ||
{ name: 'Name', value: `${ data.name }` }, | ||
{ name: 'Link', value: `[Submission Link](${ data.link })` }, | ||
{ name: 'Member of KGP', value: `${ data.member ? 'Yes' : 'No' }`, inline: true }, | ||
{ name: 'Proof', value: `${ data.proof ?? 'Not provided' }`, inline: true } | ||
] | ||
} | ||
] | ||
}; | ||
await axios.post(webhookLink, webhookObject); | ||
return 'Success'; | ||
} | ||
|
||
|
||
module.exports = { | ||
deployErrorHook, | ||
submissionHook | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters