modified docker image structure
This commit is contained in:
parent
a02979522f
commit
933d03ff13
6 changed files with 38 additions and 20 deletions
|
@ -12,4 +12,6 @@ RUN apt-get update && apt-get install -y \
|
||||||
libgif-dev \
|
libgif-dev \
|
||||||
librsvg2-dev
|
librsvg2-dev
|
||||||
|
|
||||||
CMD ["npm", "start"]
|
RUN npm i -g typescript && npm i && npm run build
|
||||||
|
|
||||||
|
CMD npm start
|
||||||
|
|
|
@ -4,9 +4,6 @@ services:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: DOCKERFILE
|
dockerfile: DOCKERFILE
|
||||||
network: host
|
network: host
|
||||||
|
image: chaisebot
|
||||||
restart: always
|
restart: always
|
||||||
volumes:
|
container_name: chaisebot
|
||||||
- /home/lucien/chaisebot:/app
|
|
||||||
dns:
|
|
||||||
- 1.1.1.1
|
|
||||||
- 1.0.0.1
|
|
|
@ -1 +0,0 @@
|
||||||
1709247600
|
|
|
@ -11,7 +11,7 @@ export default {
|
||||||
|
|
||||||
setInterval(async () => {
|
setInterval(async () => {
|
||||||
await checkReset();
|
await checkReset();
|
||||||
}, 1000); //10 * 60 *
|
}, 1000);
|
||||||
|
|
||||||
setInterval(async () => {
|
setInterval(async () => {
|
||||||
client.user?.setPresence({ activities: [{ name: '/ask | Bot fixed !', type: 3 }] });
|
client.user?.setPresence({ activities: [{ name: '/ask | Bot fixed !', type: 3 }] });
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import * as mysql from "mysql";
|
import * as mysql from "mysql";
|
||||||
|
import { rejects } from "node:assert";
|
||||||
|
import { resolve } from "node:path";
|
||||||
|
|
||||||
export interface User {
|
export interface User {
|
||||||
id: number,
|
id: number,
|
||||||
|
@ -157,3 +159,27 @@ export function setWelcomePropertiy(connection: mysql.Connection, guild_id: Stri
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getLastReset(connection: mysql.Connection) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
connection.query("SELECT MAX(date) FROM resets", (error, result) => {
|
||||||
|
if (error) {
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve(result)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function addReset(connection: mysql.Connection, date: number) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
connection.query(`INSERT INTO resets (date) VALUES (${date})`, (error, result) => {
|
||||||
|
if (error) {
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve(result)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -1,21 +1,15 @@
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { connectToDb, resetQuota } from "./mysql.js";
|
import { connectToDb, resetQuota, getLastReset, addReset } from "./mysql.js";
|
||||||
|
|
||||||
function getLastResetDate(): number {
|
|
||||||
const data: string = fs.readFileSync("./src/data/lastreset.txt", "utf8");
|
|
||||||
return parseInt(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function checkReset() {
|
export async function checkReset() {
|
||||||
const lastResetDate = getLastResetDate();
|
const connection = await connectToDb();
|
||||||
|
const lastReset = await getLastReset(connection);
|
||||||
const now = Date.now() / 1000;
|
const now = Date.now() / 1000;
|
||||||
|
|
||||||
if (now - lastResetDate > 1000 * 60 * 60 * 24 * 30) {
|
// @ts-ignore
|
||||||
fs.writeFileSync("./src/data/lastreset.txt", now.toString());
|
if (lastReset[0] && now - lastReset[0].date > 1000 * 60 * 60 * 24 * 30) {
|
||||||
|
|
||||||
const connection = await connectToDb();
|
|
||||||
|
|
||||||
await resetQuota(connection);
|
await resetQuota(connection);
|
||||||
|
await addReset(connection, now)
|
||||||
|
|
||||||
connection.end();
|
connection.end();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue