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);
|
||||
}
|
||||
client.disconnect();
|
||||
const db = require("./utils/database.js");
|
||||
if (process.env.DB_DRIVER=== "mongo") {
|
||||
db.connection.disconnect(() => {
|
||||
require("./utils/database.js").stop();
|
||||
process.exit(0);
|
||||
});
|
||||
} else if (process.env.DB_DRIVER=== "postgres") {
|
||||
db.connection.end();
|
||||
process.exit(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// launch the bot
|
||||
|
|
|
@ -23,7 +23,7 @@ module.exports = async () => {
|
|||
// set activity (a.k.a. the gamer code)
|
||||
(async function activityChanger() {
|
||||
client.editStatus("dnd", {
|
||||
name: `${misc.random(messages)} | @esmBot help`,
|
||||
name: `${misc.random(messages)} | @${client.user.username} help`,
|
||||
});
|
||||
setTimeout(activityChanger, 900000);
|
||||
})();
|
||||
|
|
|
@ -23,7 +23,7 @@ const globalSchema = new mongoose.Schema({
|
|||
});
|
||||
const Global = mongoose.model("Global", globalSchema);
|
||||
|
||||
exports.connection = mongoose.connection;
|
||||
const connection = mongoose.connection;
|
||||
|
||||
exports.getGuild = async (query) => {
|
||||
return await Guild.findOne({ id: query });
|
||||
|
@ -135,3 +135,7 @@ exports.setup = async () => {
|
|||
await global.save();
|
||||
}
|
||||
};
|
||||
|
||||
exports.stop = async () => {
|
||||
await connection.disconnect();
|
||||
};
|
|
@ -105,3 +105,7 @@ exports.setup = async () => {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.stop = async () => {
|
||||
await connection.end();
|
||||
};
|
Loading…
Reference in a new issue