Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
lxRbckl committed Feb 28, 2024
1 parent b4c43d7 commit c3600af
Show file tree
Hide file tree
Showing 12 changed files with 261 additions and 72 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build and Push Docker Image


on:
push:
branches:

- Project-Kinma-2


jobs:
build:
runs-on: ubuntu-latest
env:

project: "project-kinma"
architecture: "linux/arm64"

steps:

- name: Evaluate Commit Message
run: |
commitMessage="${{ github.event.head_commit.message }}";
if [ "$commitMessage" != "Update" ]; then
echo "Cancelling Workflow.";
exit 1;
fi
- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup QEMU
uses: docker/setup-qemu-action@v3

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUBUSERNAME }}
password: ${{ secrets.DOCKERHUBTOKEN }}

- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: ${{ env.architecture }}
tags: ${{ secrets.DOCKERHUBUSERNAME }}/${{ env.project }}:latest
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules
.DS_Store
.DS_Store
.vscode
data
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM node:18.16.0


ENV tokenOctokit undefined
ENV tokenDiscord undefined

ENV guildId undefined
ENV channelId undefined
ENV applicationId undefined

ENV messageDepth undefined

ENV settingLink undefined
ENV dataFilePath undefined
ENV reposFilePath undefined
ENV settingFilePath undefined
ENV channelsFilePath undefined


WORKDIR /app
COPY ./ /app
RUN npm install


CMD ["node", "index.js"]
10 changes: 0 additions & 10 deletions config.json

This file was deleted.

1 change: 0 additions & 1 deletion data.json

This file was deleted.

9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"dependencies": {
"@octokit/rest": "^20.0.2",
"discord.js": "^14.14.1",
"lxrbckl": "^6.5.0",
"lxrbckl": "^6.8.0",
"node-cron": "^3.0.3"
}
}
9 changes: 9 additions & 0 deletions settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"users" : [
"ala2q6",
"lxRbckl"
],
"channels" : {
"V10" : "1199281939547435030"
}
}
49 changes: 29 additions & 20 deletions source/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,9 @@ class client {
this.token = pToken;
this.database = objDatabase;
this.supervisor = objSupervisor;
this.guildId = '768020237139705857'; // process.env.guildId;
this.channelId = '1210158694919176222'; // process.env.channelId;
this.applicationId = '1210136647992344596'; // process.env.applicationId; // 1211692530069143552

this.commands = {

'update' : new update(this.supervisor)

};
this.guildId = process.env.guildId;
this.channelId = process.env.channelId;
this.applicationId = process.env.applicationId;

this.client = new Client({

Expand All @@ -50,6 +44,18 @@ class client {

});

this.commands = {

'update' : new update({

objClient : this.client,
objDatabase : this.database,
objSupervisor : this.supervisor

})

};

}


Expand All @@ -65,7 +71,9 @@ class client {

this.client.on('interactionCreate', async (interaction) => {

//
let command = this.commands[interaction.commandName];
let result = await command.run();
this.message(result);

});

Expand All @@ -76,18 +84,17 @@ class client {

this.client.on('ready', async () => {

await this.supervisor.getChannels({
cron.schedule('0 0 * * *', async () => {

objClient : this.client,
pConfig : await this.database.loadConfig()

});
let result = await this.supervisor.run({

// cron.schedule('0 0 * * *', async () => {

// //
objClient : this.client,
objDatabase : this.database

});
this.message(result);

// });
});

});

Expand All @@ -111,7 +118,9 @@ class client {

);

// this.listen();
await this.database.buildDatabase();

this.listen();
this.schedule();

}
Expand Down
23 changes: 20 additions & 3 deletions source/command/update.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
class update {

constructor(objSupervisor) {

constructor({

objClient,
objDatabase,
objSupervisor

}) {

this.client = objClient;
this.database = objDatabase;
this.supervisor = objSupervisor;

}
Expand All @@ -20,7 +28,16 @@ class update {
}


async run() {return await this.supervisor.run()}
async run() {

return await this.supervisor.run({

objClient : this.client,
objDatabase : this.database

});

}

}

Expand Down
58 changes: 49 additions & 9 deletions source/database.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
// import <
const {fileGet, axiosGet} = require('lxrbckl');
const {

dirGet,
dirSet,
fileSet,
fileGet,
axiosGet

} = require('lxrbckl');

// >

Expand All @@ -8,27 +16,59 @@ class database {

constructor() {

this.developerMode = true;
this.dataFilePath = 'data.json'; // process.env.dataFilePath;
this.configFilePath = 'config.json'; // process.env.cofigFilePath;
this.configLink = 'https://raw.githubusercontent.com/lxRbckl/Project-Kinma/Project-Kinma-2/settings.json'; // process.env.configLink;
this.developerMode = false;
this.settingLink = process.env.settingLink;
this.dataFilePath = process.env.dataFilePath;
this.reposFilePath = process.env.reposFilePath;
this.settingFilePath = process.env.settingFilePath;
this.channelsFilePath = process.env.channelsFilePath;

}


async loadConfig() {
async loadSetting() {

return await {

false : async () => {return axiosGet({pURL : this.configLink});},
true : async () => {return fileGet({pFile : this.configFilePath});}
false : async () => {return axiosGet({pURL : this.settingLinks});},
true : async () => {return fileGet({pFile : this.settingFilePath});}

}[this.developerMode]();

}


async loadData() {return await fileGet({pFile : this.dataFilePath});}
async setChannel({

pData,
pChannel

}) {

let fPath = `${this.channelsFilePath}/${pChannel}.json`;
let fIn = await fileGet({pFile : fPath, pErrorMessage : {}});

await fileSet({pFile : fPath, pData : {...fIn, ...pData}});

}


async buildDatabase() {

let dir = await dirGet({pDir : ''});

// if (no data) {
if (!(dir.includes(this.dataFilePath))) {

await dirSet({pDir : this.dataFilePath});
await dirSet({pDir : this.reposFilePath});
await dirSet({pDir : this.channelsFilePath});

}

// >

}

}

Expand Down
Loading

0 comments on commit c3600af

Please sign in to comment.