add workflows

This commit is contained in:
Stanislaw
2022-06-15 22:28:18 +02:00
parent ffc034dbdd
commit 089e13b9ff
8 changed files with 102 additions and 43 deletions

View File

@@ -1,5 +1,3 @@
const { ReactionUserManager } = require("discord.js");
module.exports = {
name: "profile",
async execute(cl, msg, args, connect) {

View File

@@ -26,17 +26,22 @@ class Postgres {
});
}
async msg_state(userID) {
return await this.client.users.findUnique({
where: {
user_id: userID,
},
});
}
async addExp(userID, min, max) {
await this.#ifExist(userID).then(async () => {
await this.#ifUserExist(userID).then(async () => {
const rExp = randomExp(min, max);
return await this.client.users.update({
where: {
user_id: userID,
},
data: {
msg_count: {
increment: 1,
},
exp: {
increment: rExp,
},
@@ -56,13 +61,28 @@ class Postgres {
});
});
}
async #ifExist(userID) {
if ((await !this.profile(userID)) == null) {
async #ifUserExist(userID) {
if ((await this.profile(userID)) == null) {
console.log("Account");
await this.client.users.create({
data: {
user_id: userID,
msg_count: 0,
lvl: 0,
exp: 0,
},
});
}
}
async #ifMsgsExist(userID, channelID) {
if ((await this.profile(userID)) == null) {
console.log("Account");
await this.client.users.create({
data: {
user_id: userID,
lvl: 0,
exp: 0,
},
});
}