Fixed db for groups

main
Killian 4 years ago
parent f58632dc2b
commit 4a1eeed31c

@ -14,7 +14,7 @@ module.exports = class extends Command {
}
async run(message, args, data) {
if (parseInt(message.author.id) !== parseInt(data.config.ownerID)) return message.chat.sendMessage("Vous n'avez pas la permission d'utiliser cette commande.")
if (parseInt(message.author.id) !== parseInt(data.config.ownerID)) return message.chat.sendMessage("You do not have the permission to use this command")
let result = new Promise((resolve) => resolve(eval(args.join(` `))));
return result.then((output) => {

@ -14,7 +14,7 @@ module.exports = class extends Command {
}
async run(message, args) {
message.chat.sendMessage('Calcul du ping...').then(m => {
message.chat.sendMessage('Fetching ping...').then(m => {
m.delete();
message.chat.sendMessage(`My ping is currently at ${(m.timestamp - message.timestamp) / 1000}ms\nI use ${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)}mb of RAM`)
})

@ -55,7 +55,7 @@ class InstaBot extends Client {
if (this.databaseCache.users.get(userID)) {
return isLean ? this.databaseCache.users.get(userID).toJSON() : this.databaseCache.users.get(userID);
} else {
let userData = (isLean ? await this.usersData.findOne({ id: userID }).populate(`members`).lean() : await this.usersData.findOne({ id: userID }).populate(`members`));
let userData = (isLean ? await this.usersData.findOne({ id: userID }).populate(`users`).lean() : await this.usersData.findOne({ id: userID }).populate(`users`));
if (userData) {
if (!isLean) this.databaseCache.users.set(userID, userData);
return userData;
@ -87,16 +87,16 @@ class InstaBot extends Client {
async findOrCreateGroup({ groupID: groupID }, isLean) {
if (this.databaseCache.groups.get(groupID)) {
return isLean ? this.databaseCache.groupMembers.get(groupID).toJSON() : this.databaseCache.groupMembers.get(groupID);
return isLean ? this.databaseCache.groups.get(groupID).toJSON() : this.databaseCache.groups.get(groupID);
} else {
let groupData = (isLean ? await this.groupMembersData.findOne({ groupID: groupID }).populate(`members`).lean() : await this.groupMembersData.findOne({ groupID: groupID }).populate(`members`));
let groupData = (isLean ? await this.groupsData.findOne({ groupID: groupID }).populate(`groups`).lean() : await this.groupsData.findOne({ groupID: groupID }).populate(`groups`));
if (groupData) {
if (!isLean) this.databaseCache.groupMembers.set(groupID, groupData);
if (!isLean) this.databaseCache.groups.set(groupID, groupData);
return groupData;
} else {
groupData = new this.groupMembersData({ groupID: groupID });
groupData = new this.groupsData({ groupID: groupID });
await groupData.save();
this.databaseCache.groupMembers.set(groupID, groupData);
this.databaseCache.groups.set(groupID, groupData);
return isLean ? groupData.toJSON() : groupData;
}
}

@ -1,6 +1,6 @@
{
"name": "instabot",
"version": "1.1.9",
"version": "1.2.0",
"description": "A fully working instagram bot using Insta.js by androz2091",
"main": "index.js",
"scripts": {

Loading…
Cancel
Save