From 3ff221d8c5ac80811927441ffb09f30bdc7e4d35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Melaine=20G=C3=A9rard?= Date: Fri, 4 Oct 2024 12:54:51 +0200 Subject: [PATCH] :sparkles: Save events --- .gitea/workflows/retrieve-datas.yaml | 21 +++++++++++++++++++++ .gitignore | 8 ++++++++ package-lock.json | 28 ++++++++++++++++++++++++++++ package.json | 15 +++++++++++++++ retrieve-datas.js | 17 +++++++++++++++++ 5 files changed, 89 insertions(+) create mode 100644 .gitea/workflows/retrieve-datas.yaml create mode 100644 .gitignore create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 retrieve-datas.js diff --git a/.gitea/workflows/retrieve-datas.yaml b/.gitea/workflows/retrieve-datas.yaml new file mode 100644 index 0000000..0ece93e --- /dev/null +++ b/.gitea/workflows/retrieve-datas.yaml @@ -0,0 +1,21 @@ +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: Upload artifact + uses: https://gitea.com/actions/upload-artifact@v4 + with: + name: events + path: ./events.json \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3ab52ff --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.idea/ +.vscode/ +.fleet/ +*.iml + +node_modules/ +.env +events.json \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..ba54649 --- /dev/null +++ b/package-lock.json @@ -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" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..587670a --- /dev/null +++ b/package.json @@ -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" + } +} diff --git a/retrieve-datas.js b/retrieve-datas.js new file mode 100644 index 0000000..879962a --- /dev/null +++ b/retrieve-datas.js @@ -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)); +})() \ No newline at end of file