mirror of
https://github.com/YuzuZensai/play-dl-test.git
synced 2026-01-06 04:32:40 +00:00
Some changes
This commit is contained in:
70
.github/discord.js
vendored
Normal file
70
.github/discord.js
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
const bot_token = process.env['BOT_TOKEN']
|
||||
const { request } = require('https')
|
||||
|
||||
let tag = undefined, body = undefined, channel = undefined;
|
||||
|
||||
process.argv.forEach((arg) => {
|
||||
const [ key, value ] = arg.split('=')
|
||||
if(key === 'tag') tag = value
|
||||
if(key === 'body') body = value
|
||||
if(key === 'channel') channel = value
|
||||
})
|
||||
|
||||
if(!tag || !body || !channel) {
|
||||
console.log(`Some args are missing`)
|
||||
process.exit(1)
|
||||
}
|
||||
else if(!bot_token) {
|
||||
console.log('Bot Token is missing')
|
||||
process.exit(1)
|
||||
};
|
||||
|
||||
(async() => {
|
||||
const body_args = body.replaceAll('\r', '').split('- [x]')
|
||||
body_args.shift()
|
||||
body_args.unshift('**Change Log :-**\n')
|
||||
const description = body_args.join('\n<a:tick:893093621623037972>')
|
||||
const embed = {
|
||||
title : tag,
|
||||
url : `https://github.com/play-dl/play-dl/releases/tag/${tag}`,
|
||||
description : description,
|
||||
color : 0x00FF00
|
||||
}
|
||||
|
||||
const payload = {
|
||||
embeds : [embed]
|
||||
}
|
||||
|
||||
console.log(payload)
|
||||
|
||||
const x = await https_getter(`https://discord.com/api/v9/channels/${channel}/messages`, {
|
||||
headers : {
|
||||
"Authorization" : `Bot ${bot_token}`,
|
||||
"content-type" : "application/json"
|
||||
},
|
||||
method : "POST",
|
||||
body : JSON.stringify(payload)
|
||||
})
|
||||
console.log(x.statusCode)
|
||||
process.exit(0)
|
||||
})()
|
||||
|
||||
function https_getter(req_url, options = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const s = new URL(req_url);
|
||||
options.method ??= 'GET';
|
||||
const req_options = {
|
||||
host: s.hostname,
|
||||
path: s.pathname + s.search,
|
||||
headers: options.headers ?? {},
|
||||
method: options.method
|
||||
};
|
||||
|
||||
const req = request(req_options, resolve);
|
||||
req.on('error', (err) => {
|
||||
reject(err);
|
||||
});
|
||||
if (options.method === 'POST') req.write(options.body);
|
||||
req.end();
|
||||
});
|
||||
}
|
||||
12
.github/docs.js
vendored
Normal file
12
.github/docs.js
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
const fs = require('fs')
|
||||
|
||||
const path = "play-dl/index.ts"
|
||||
|
||||
if(!fs.existsSync(path)) {
|
||||
console.log('File Missing')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const oldData = fs.readFileSync(path, 'utf-8')
|
||||
|
||||
fs.writeFileSync(path, oldData.split('// Export Default ')[0])
|
||||
17
.github/workflows/main.yml
vendored
17
.github/workflows/main.yml
vendored
@@ -42,6 +42,9 @@ jobs:
|
||||
- name: Install Dependencies
|
||||
run: npm install
|
||||
|
||||
- name: Deleting default exports for ESM.
|
||||
run: node .github/docs.js
|
||||
|
||||
- name: TypeDoc
|
||||
run: npx typedoc
|
||||
|
||||
@@ -53,3 +56,17 @@ jobs:
|
||||
git add *
|
||||
git commit -m "Automated Docs"
|
||||
git push
|
||||
|
||||
publish_discord:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 16
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- name: Publish on discord
|
||||
run: node .github/discord.js channel="888999793458835466" body="${{ github.event.release.body }}" tag="${{ github.event.release.tag_name }}"
|
||||
env:
|
||||
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
|
||||
Reference in New Issue
Block a user