Save events

This commit is contained in:
Melaine Gérard 2024-10-04 12:54:51 +02:00
commit 0bb6a8763c
6 changed files with 92 additions and 0 deletions

View File

@ -0,0 +1,24 @@
name: Retrieve Events Datas
run-name: Retrieve Events Datas
on: [push]
jobs:
Retrieve-Events-Datas:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: "20.x"
- run: npm ci
- run: npm run retrieve-datas
- name: Commit and push changes
run: |
git config --global user.email "camelia@localhost"
git config --global user.name "Camélia Studio"
git add events.json
# On amend le dernier commit pour ajouter les modifications
git commit --amend --no-edit
git push

7
.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
.idea/
.vscode/
.fleet/
*.iml
node_modules/
.env

1
events.json Normal file
View File

@ -0,0 +1 @@
[]

28
package-lock.json generated Normal file
View File

@ -0,0 +1,28 @@
{
"name": "camelianimes-datas",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "camelianimes-datas",
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"dotenv": "^16.4.5"
}
},
"node_modules/dotenv": {
"version": "16.4.5",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz",
"integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==",
"license": "BSD-2-Clause",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://dotenvx.com"
}
}
}
}

15
package.json Normal file
View File

@ -0,0 +1,15 @@
{
"name": "camelianimes-datas",
"version": "1.0.0",
"main": "retrieve-datas.js",
"scripts": {
"retrieve-datas": "node retrieve-datas.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"dotenv": "^16.4.5"
}
}

17
retrieve-datas.js Normal file
View File

@ -0,0 +1,17 @@
const {config} = require('dotenv');
const {writeFileSync} = require("node:fs");
config();
(async () => {
let datas = await fetch("https://discord.com/api/v10/guilds/" + process.env.DISCORD_GUILD_ID + "/scheduled-events?with_user_count=true", {
method: "GET",
headers: {
"Authorization": "Bot " + process.env.DISCORD_BOT_TOKEN,
}
})
.then(response => response.json())
.then(data => data);
writeFileSync("events.json", JSON.stringify(datas, null, 4));
})()