diff --git a/config.js b/config.js index 6b72a9f..cd595ff 100644 --- a/config.js +++ b/config.js @@ -1,10 +1,3 @@ globalThis.packname = "Hedystia Bot"; globalThis.author = "Hedystia"; globalThis.db = require("./db"); - -/** - * @description You need to generate a token you can use the dashboard or the api discord. - * @link https://strangeapi.hostz.me/dashboard - * @link https://discord.gg/f7ADs3Ncu3 - */ -globalThis.imageToken = ""; diff --git a/package.json b/package.json index 0745fef..0b0e33c 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,11 @@ { "name": "hedystiamd", - "version": "3.2.0", + "version": "3.2.1", "description": "A whatsapp bot that can be used to play music", "main": "index.js", "type": "commonjs", "scripts": { "start": "node index.js", - "dev": "nodemon index.js", "check": "biome ci .", "lint": "biome lint --apply .", "format": "biome format --write .", @@ -16,25 +15,24 @@ "author": "contact@hedystia.com", "license": "ISC", "dependencies": { - "@hedystia/db": "^1.9.0", + "@hedystia/db": "^1.11.1", "awesome-phonenumber": "2.68.0", - "baileys": "^6.7.6", + "baileys": "^6.7.8", "file-type": "16.5.3", "fluent-ffmpeg": "^2.1.3", "formdata-node": "4.4.1", "jimp": "^0.22.12", - "moment-timezone": "^0.5.45", + "moment-timezone": "^0.5.46", "node-webpmux": "^3.2.0", - "pino": "^9.3.2", + "pino": "^9.5.0", "qrcode-terminal": "0.12.0", "soundcloud.ts": "^0.5.5", "wa-sticker-formatter": "4.4.4" }, "devDependencies": { - "@biomejs/biome": "^1.8.3", - "@types/jsonwebtoken": "^9.0.6", + "@biomejs/biome": "^1.9.4", "@types/node": "^20.14.2", - "husky": "^9.1.4" + "husky": "^9.1.6" }, "directories": { "src": "src" diff --git a/src/commands/images/3000years.js b/src/commands/images/3000years.js index 9164933..ab1e766 100644 --- a/src/commands/images/3000years.js +++ b/src/commands/images/3000years.js @@ -14,7 +14,7 @@ module.exports = { ? bot.user.jid : message.sender; const response = await fetch( - `https://strangeapi.hostz.me/api/generators/3000-years?image=${encodeURIComponent( + `https://gens.hedystia.com/generators/3000years?image=${encodeURIComponent( await bot .profilePictureUrl(user) .catch( @@ -24,7 +24,7 @@ module.exports = { )}}`, { headers: { - Authorization: `Bearer ${global.imageToken}`, + Authorization: "Hedystia", }, }, ); diff --git a/src/commands/images/ad.js b/src/commands/images/ad.js index 46acaee..e7e74eb 100644 --- a/src/commands/images/ad.js +++ b/src/commands/images/ad.js @@ -14,7 +14,7 @@ module.exports = { ? bot.user.jid : message.sender; const response = await fetch( - `https://strangeapi.hostz.me/api/generators/ad?image=${encodeURIComponent( + `https://gens.hedystia.com/generators/ad?image=${encodeURIComponent( await bot .profilePictureUrl(user) .catch( @@ -24,7 +24,7 @@ module.exports = { )}}`, { headers: { - Authorization: `Bearer ${global.imageToken}`, + Authorization: "Hedystia", }, }, ); diff --git a/src/commands/images/affect.js b/src/commands/images/affect.js index 38dd902..b668626 100644 --- a/src/commands/images/affect.js +++ b/src/commands/images/affect.js @@ -14,7 +14,7 @@ module.exports = { ? bot.user.jid : message.sender; const response = await fetch( - `https://strangeapi.hostz.me/api/generators/affect?image=${encodeURIComponent( + `https://gens.hedystia.com/generators/affect?image=${encodeURIComponent( await bot .profilePictureUrl(user) .catch( @@ -24,7 +24,7 @@ module.exports = { )}}`, { headers: { - Authorization: `Bearer ${global.imageToken}`, + Authorization: "Hedystia", }, }, ); diff --git a/src/commands/images/approved.js b/src/commands/images/approved.js index 3e5eded..d30ca5f 100644 --- a/src/commands/images/approved.js +++ b/src/commands/images/approved.js @@ -14,7 +14,7 @@ module.exports = { ? bot.user.jid : message.sender; const response = await fetch( - `https://strangeapi.hostz.me/api/overlays/approved?image=${encodeURIComponent( + `https://gens.hedystia.com/generators/approved?image=${encodeURIComponent( await bot .profilePictureUrl(user) .catch( @@ -24,7 +24,7 @@ module.exports = { )}}`, { headers: { - Authorization: `Bearer ${global.imageToken}`, + Authorization: "Hedystia", }, }, ); diff --git a/src/commands/images/batslap.js b/src/commands/images/batslap.js index 10498ec..d19da11 100644 --- a/src/commands/images/batslap.js +++ b/src/commands/images/batslap.js @@ -14,7 +14,7 @@ module.exports = { ? bot.user.jid : message.sender; const response = await fetch( - `https://strangeapi.hostz.me/api/generators/batslap?image1=${encodeURIComponent( + `https://gens.hedystia.com/generators/batslap?image1=${encodeURIComponent( await bot .profilePictureUrl(message.sender ?? message.quoted.sender) .catch( @@ -31,7 +31,7 @@ module.exports = { )}`, { headers: { - Authorization: `Bearer ${global.imageToken}`, + Authorization: "Hedystia", }, }, ); diff --git a/src/commands/images/beautiful.js b/src/commands/images/beautiful.js index e18af21..d840237 100644 --- a/src/commands/images/beautiful.js +++ b/src/commands/images/beautiful.js @@ -14,7 +14,7 @@ module.exports = { ? bot.user.jid : message.sender; const response = await fetch( - `https://strangeapi.hostz.me/api/generators/beautiful?image=${encodeURIComponent( + `https://gens.hedystia.com/generators/beautiful?image=${encodeURIComponent( await bot .profilePictureUrl(user) .catch( @@ -24,7 +24,7 @@ module.exports = { )}}`, { headers: { - Authorization: `Bearer ${global.imageToken}`, + Authorization: "Hedystia", }, }, ); diff --git a/src/commands/images/bed.js b/src/commands/images/bed.js index c1b9fa1..3f4bc5b 100644 --- a/src/commands/images/bed.js +++ b/src/commands/images/bed.js @@ -14,7 +14,7 @@ module.exports = { ? bot.user.jid : message.sender; const response = await fetch( - `https://strangeapi.hostz.me/api/generators/bed?image1=${encodeURIComponent( + `https://gens.hedystia.com/generators/bed?image1=${encodeURIComponent( await bot .profilePictureUrl(message.sender ?? message.quoted.sender) .catch( @@ -31,7 +31,7 @@ module.exports = { )}`, { headers: { - Authorization: `Bearer ${global.imageToken}`, + Authorization: "Hedystia", }, }, ); diff --git a/src/commands/images/blur.js b/src/commands/images/blur.js index 8b259c0..6d3d324 100644 --- a/src/commands/images/blur.js +++ b/src/commands/images/blur.js @@ -14,7 +14,7 @@ module.exports = { ? bot.user.jid : message.sender; const response = await fetch( - `https://strangeapi.hostz.me/api/filters/blur?image=${encodeURIComponent( + `https://gens.hedystia.com/filters/blur?image=${encodeURIComponent( await bot .profilePictureUrl(user) .catch( @@ -24,7 +24,7 @@ module.exports = { )}}`, { headers: { - Authorization: `Bearer ${global.imageToken}`, + Authorization: "Hedystia", }, }, ); diff --git a/src/commands/images/bobross.js b/src/commands/images/bobross.js index 03ed3cf..87d4f73 100644 --- a/src/commands/images/bobross.js +++ b/src/commands/images/bobross.js @@ -14,7 +14,7 @@ module.exports = { ? bot.user.jid : message.sender; const response = await fetch( - `https://strangeapi.hostz.me/api/generators/bobross?image=${encodeURIComponent( + `https://gens.hedystia.com/generators/bobross?image=${encodeURIComponent( await bot .profilePictureUrl(user) .catch( @@ -24,7 +24,7 @@ module.exports = { )}}`, { headers: { - Authorization: `Bearer ${global.imageToken}`, + Authorization: "Hedystia", }, }, ); diff --git a/src/commands/images/circle.js b/src/commands/images/circle.js index e6a51d7..72cf3d3 100644 --- a/src/commands/images/circle.js +++ b/src/commands/images/circle.js @@ -14,7 +14,7 @@ module.exports = { ? bot.user.jid : message.sender; const response = await fetch( - `https://strangeapi.hostz.me/api/utils/circle?image=${encodeURIComponent( + `https://gens.hedystia.com/utils/circle?image=${encodeURIComponent( await bot .profilePictureUrl(user) .catch( @@ -24,7 +24,7 @@ module.exports = { )}}`, { headers: { - Authorization: `Bearer ${global.imageToken}`, + Authorization: "Hedystia", }, }, ); diff --git a/src/commands/images/clown.js b/src/commands/images/clown.js index 6778afd..70aded1 100644 --- a/src/commands/images/clown.js +++ b/src/commands/images/clown.js @@ -14,7 +14,7 @@ module.exports = { ? bot.user.jid : message.sender; const response = await fetch( - `https://strangeapi.hostz.me/api/generators/clown?image=${encodeURIComponent( + `https://gens.hedystia.com/generators/clown?image=${encodeURIComponent( await bot .profilePictureUrl(user) .catch( @@ -24,7 +24,7 @@ module.exports = { )}}`, { headers: { - Authorization: `Bearer ${global.imageToken}`, + Authorization: "Hedystia", }, }, ); diff --git a/src/commands/images/delete.js b/src/commands/images/delete.js index 43964bf..19159b5 100644 --- a/src/commands/images/delete.js +++ b/src/commands/images/delete.js @@ -14,7 +14,7 @@ module.exports = { ? bot.user.jid : message.sender; const response = await fetch( - `https://strangeapi.hostz.me/api/generators/delete?image=${encodeURIComponent( + `https://gens.hedystia.com/generators/delete?image=${encodeURIComponent( await bot .profilePictureUrl(user) .catch( @@ -24,7 +24,7 @@ module.exports = { )}}`, { headers: { - Authorization: `Bearer ${global.imageToken}`, + Authorization: "Hedystia", }, }, ); diff --git a/src/commands/images/dexter.js b/src/commands/images/dexter.js index f58f475..6c4917b 100644 --- a/src/commands/images/dexter.js +++ b/src/commands/images/dexter.js @@ -14,7 +14,7 @@ module.exports = { ? bot.user.jid : message.sender; const response = await fetch( - `https://strangeapi.hostz.me/api/generators/dexter?image=${encodeURIComponent( + `https://gens.hedystia.com/generators/dexter?image=${encodeURIComponent( await bot .profilePictureUrl(user) .catch( @@ -24,7 +24,7 @@ module.exports = { )}}`, { headers: { - Authorization: `Bearer ${global.imageToken}`, + Authorization: "Hedystia", }, }, ); diff --git a/src/commands/images/facepalm.js b/src/commands/images/facepalm.js index e9fd15b..985fa1b 100644 --- a/src/commands/images/facepalm.js +++ b/src/commands/images/facepalm.js @@ -14,7 +14,7 @@ module.exports = { ? bot.user.jid : message.sender; const response = await fetch( - `https://strangeapi.hostz.me/api/generators/facepalm?image=${encodeURIComponent( + `https://gens.hedystia.com/generators/facepalm?image=${encodeURIComponent( await bot .profilePictureUrl(user) .catch( @@ -24,7 +24,7 @@ module.exports = { )}}`, { headers: { - Authorization: `Bearer ${global.imageToken}`, + Authorization: "Hedystia", }, }, ); diff --git a/src/commands/images/invert.js b/src/commands/images/invert.js index cdf63f1..b02d14d 100644 --- a/src/commands/images/invert.js +++ b/src/commands/images/invert.js @@ -14,7 +14,7 @@ module.exports = { ? bot.user.jid : message.sender; const response = await fetch( - `https://strangeapi.hostz.me/api/filters/invert?image=${encodeURIComponent( + `https://gens.hedystia.com/filters/invert?image=${encodeURIComponent( await bot .profilePictureUrl(user) .catch( @@ -24,7 +24,7 @@ module.exports = { )}}`, { headers: { - Authorization: `Bearer ${global.imageToken}`, + Authorization: "Hedystia", }, }, ); diff --git a/src/commands/images/mms.js b/src/commands/images/mms.js index 66a31bd..ec873f6 100644 --- a/src/commands/images/mms.js +++ b/src/commands/images/mms.js @@ -14,7 +14,7 @@ module.exports = { ? bot.user.jid : message.sender; const response = await fetch( - `https://strangeapi.hostz.me/api/generators/mms?image=${encodeURIComponent( + `https://gens.hedystia.com/generators/mms?image=${encodeURIComponent( await bot .profilePictureUrl(user) .catch( @@ -24,7 +24,7 @@ module.exports = { )}}`, { headers: { - Authorization: `Bearer ${global.imageToken}`, + Authorization: "Hedystia", }, }, ); diff --git a/src/commands/images/rejected.js b/src/commands/images/rejected.js index 37f7328..fd92521 100644 --- a/src/commands/images/rejected.js +++ b/src/commands/images/rejected.js @@ -14,7 +14,7 @@ module.exports = { ? bot.user.jid : message.sender; const response = await fetch( - `https://strangeapi.hostz.me/api/overlays/rejected?image=${encodeURIComponent( + `https://gens.hedystia.com/generators/rejected?image=${encodeURIComponent( await bot .profilePictureUrl(user) .catch( @@ -24,7 +24,7 @@ module.exports = { )}}`, { headers: { - Authorization: `Bearer ${global.imageToken}`, + Authorization: "Hedystia", }, }, ); diff --git a/src/commands/images/wanted.js b/src/commands/images/wanted.js index baefd9b..2d829c3 100644 --- a/src/commands/images/wanted.js +++ b/src/commands/images/wanted.js @@ -14,7 +14,7 @@ module.exports = { ? bot.user.jid : message.sender; const response = await fetch( - `https://strangeapi.hostz.me/api/generators/wanted?image=${encodeURIComponent( + `https://gens.hedystia.com/generators/wanted?image=${encodeURIComponent( await bot .profilePictureUrl(user) .catch( @@ -24,7 +24,7 @@ module.exports = { )}}`, { headers: { - Authorization: `Bearer ${global.imageToken}`, + Authorization: "Hedystia", }, }, ); diff --git a/src/commands/images/wasted.js b/src/commands/images/wasted.js index 143c196..3b2a80b 100644 --- a/src/commands/images/wasted.js +++ b/src/commands/images/wasted.js @@ -14,7 +14,7 @@ module.exports = { ? bot.user.jid : message.sender; const response = await fetch( - `https://strangeapi.hostz.me/api/overlays/wasted?image=${encodeURIComponent( + `https://gens.hedystia.com/generators/wasted?image=${encodeURIComponent( await bot .profilePictureUrl(user) .catch( @@ -24,7 +24,7 @@ module.exports = { )}}`, { headers: { - Authorization: `Bearer ${global.imageToken}`, + Authorization: "Hedystia", }, }, ); diff --git a/src/db/migrations/2024-05-09T00-20-59.327Z.js b/src/db/migrations/2024-05-09T00-20-59.327Z.js index a0349f4..15bcbc4 100644 --- a/src/db/migrations/2024-05-09T00-20-59.327Z.js +++ b/src/db/migrations/2024-05-09T00-20-59.327Z.js @@ -80,30 +80,25 @@ function getLang() { }); } -module.exports = { - date: "2024-05-09T00:20:59.327Z", - type: "config", - run: async (migrations, config) => { - config.deleteTableIfExists("antiLinks"); - config.deleteTableIfExists("owner"); - config.deleteTableIfExists("prefix"); - config.deleteTableIfExists("lang"); - config.createTable("antiLinks", ["id", "enabled", "allowed", "admins_allowed", "action"]); - config.createTable("owner", ["id", "value"]); - config.createTable("prefix", ["id", "value"]); - config.createTable("lang", ["id", "value"]); - config.insert("antiLinks", { - id: "antiLinks", - enabled: false, - allowed: ["https://hedystia.com", "https://zastinian.com"], - admins_allowed: true, - action: "delete", - }); - config.insert("owner", { id: "owner", value: false }); - const p = await getPrefix(); - config.insert("prefix", { id: "prefix", value: p }); - const l = await getLang(); - config.insert("lang", { id: "lang", value: l }); - migrations.insert("version", { date: "2024-05-09T00:20:59.327Z" }); - }, +module.exports = async (config) => { + config.deleteTableIfExists("antiLinks"); + config.deleteTableIfExists("owner"); + config.deleteTableIfExists("prefix"); + config.deleteTableIfExists("lang"); + config.createTable("antiLinks", ["id", "enabled", "allowed", "admins_allowed", "action"]); + config.createTable("owner", ["id", "value"]); + config.createTable("prefix", ["id", "value"]); + config.createTable("lang", ["id", "value"]); + config.insert("antiLinks", { + id: "antiLinks", + enabled: false, + allowed: ["https://hedystia.com", "https://zastinian.com"], + admins_allowed: true, + action: "delete", + }); + config.insert("owner", { id: "owner", value: false }); + const p = await getPrefix(); + config.insert("prefix", { id: "prefix", value: p }); + const l = await getLang(); + config.insert("lang", { id: "lang", value: l }); }; diff --git a/src/db/migrations/index.js b/src/db/migrations/index.js index f01dfd0..7543efe 100644 --- a/src/db/migrations/index.js +++ b/src/db/migrations/index.js @@ -1,15 +1,20 @@ module.exports = async (migrations, config) => { - const m = require("./2024-05-09T00-20-59.327Z"); - if (!migrations.select("version", { date: m.date })[0]) { - console.log("\n"); - console.log(`\x1b[97mCreating the migrations ${m.date}\x1b[0m`); - console.log(""); - switch (m.type) { - case "config": - await m.run(migrations, config); - break; - } - console.log(""); - console.log(`\x1b[95mThe creation of the migrations ${m.date} has been completed\x1b[0m`); - } + migrations.enableMigrations(); + await migrations.createMigration( + { + id: "2024-05-09T00:20:59.327Z", + description: "Initial migration", + timestamp: Date.now(), + }, + async () => { + console.log("\n"); + console.log("\x1b[97mCreating the migrations 2024-05-09T00:20:59.327Z\x1b[0m"); + const migration = require("./2024-05-09T00-20-59.327Z"); + await migration(config); + console.log(""); + console.log( + "\x1b[95mThe creation of the migrations 2024-05-09T00:20:59.327Z has been completed\x1b[0m", + ); + }, + ); };