Fixed database stop crash, made playing status use the current bot username
This commit is contained in:
		
							parent
							
								
									5fa5f21289
								
							
						
					
					
						commit
						9b4861ae4a
					
				
					 4 changed files with 12 additions and 11 deletions
				
			
		
							
								
								
									
										9
									
								
								app.js
									
										
									
									
									
								
							
							
						
						
									
										9
									
								
								app.js
									
										
									
									
									
								
							| 
						 | 
					@ -59,16 +59,9 @@ async function init() {
 | 
				
			||||||
      handler.unload(command);
 | 
					      handler.unload(command);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    client.disconnect();
 | 
					    client.disconnect();
 | 
				
			||||||
    const db = require("./utils/database.js");
 | 
					    require("./utils/database.js").stop();
 | 
				
			||||||
    if (process.env.DB_DRIVER=== "mongo") {
 | 
					 | 
				
			||||||
      db.connection.disconnect(() => {
 | 
					 | 
				
			||||||
    process.exit(0);
 | 
					    process.exit(0);
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
    } else if (process.env.DB_DRIVER=== "postgres") {
 | 
					 | 
				
			||||||
      db.connection.end();
 | 
					 | 
				
			||||||
      process.exit(0);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  });
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// launch the bot
 | 
					// launch the bot
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,7 +23,7 @@ module.exports = async () => {
 | 
				
			||||||
  // set activity (a.k.a. the gamer code)
 | 
					  // set activity (a.k.a. the gamer code)
 | 
				
			||||||
  (async function activityChanger() {
 | 
					  (async function activityChanger() {
 | 
				
			||||||
    client.editStatus("dnd", {
 | 
					    client.editStatus("dnd", {
 | 
				
			||||||
      name: `${misc.random(messages)} | @esmBot help`,
 | 
					      name: `${misc.random(messages)} | @${client.user.username} help`,
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    setTimeout(activityChanger, 900000);
 | 
					    setTimeout(activityChanger, 900000);
 | 
				
			||||||
  })();
 | 
					  })();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,7 +23,7 @@ const globalSchema = new mongoose.Schema({
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
const Global = mongoose.model("Global", globalSchema);
 | 
					const Global = mongoose.model("Global", globalSchema);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.connection = mongoose.connection;
 | 
					const connection = mongoose.connection;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.getGuild = async (query) => {
 | 
					exports.getGuild = async (query) => {
 | 
				
			||||||
  return await Guild.findOne({ id: query });
 | 
					  return await Guild.findOne({ id: query });
 | 
				
			||||||
| 
						 | 
					@ -135,3 +135,7 @@ exports.setup = async () => {
 | 
				
			||||||
    await global.save();
 | 
					    await global.save();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					exports.stop = async () => {
 | 
				
			||||||
 | 
					  await connection.disconnect();
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
| 
						 | 
					@ -105,3 +105,7 @@ exports.setup = async () => {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					exports.stop = async () => {
 | 
				
			||||||
 | 
					  await connection.end();
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue