Fixed some issues with the sound player, search images in original message first, add max limit to dice
This commit is contained in:
parent
a82341ea4f
commit
95846d32d4
5 changed files with 55 additions and 70 deletions
|
@ -1,4 +1,3 @@
|
|||
const cron = require("cron");
|
||||
const client = require("../utils/client.js");
|
||||
const database = require("../utils/database.js");
|
||||
const collections = require("../utils/collections.js");
|
||||
|
@ -11,7 +10,6 @@ const helpGenerator =
|
|||
const twitter =
|
||||
process.env.TWITTER === "true" ? require("../utils/twitter.js") : null;
|
||||
const first = process.env.PMTWO === "true" ? process.env.NODE_APP_INSTANCE === "0" : true;
|
||||
let run = false;
|
||||
|
||||
// run when ready
|
||||
module.exports = async () => {
|
||||
|
@ -44,21 +42,6 @@ module.exports = async () => {
|
|||
}
|
||||
}
|
||||
|
||||
if (!run && first) {
|
||||
const job = new cron.CronJob("0 0 * * 0", async () => {
|
||||
logger.log("Deleting stale guild entries in database...");
|
||||
const guildDB = await database.guilds.find({});
|
||||
for (const { id } of guildDB) {
|
||||
if (!client.guilds.get(id)) {
|
||||
await database.guilds.deleteMany({ id: id });
|
||||
logger.log(`Deleted entry for guild ID ${id}.`);
|
||||
}
|
||||
}
|
||||
logger.log("Finished deleting stale entries.");
|
||||
});
|
||||
job.start();
|
||||
}
|
||||
|
||||
const global = await database.global.findOne({});
|
||||
if (!global) {
|
||||
const countObject = {};
|
||||
|
@ -146,5 +129,4 @@ module.exports = async () => {
|
|||
|
||||
if (process.env.PMTWO === "true") process.send("ready");
|
||||
logger.log(`Successfully started ${client.user.username}#${client.user.discriminator} with ${client.users.size} users in ${client.guilds.size} servers.`);
|
||||
run = true;
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const soundPlayer = require("../utils/soundplayer.js");
|
||||
const client = require("../utils/client.js");
|
||||
const AwaitRejoin = require("../utils/awaitrejoin.js");
|
||||
const { random } = require("../utils/misc.js");
|
||||
|
||||
module.exports = async (member, oldChannel) => {
|
||||
const connection = soundPlayer.players.get(oldChannel.guild.id);
|
||||
|
@ -29,11 +30,10 @@ module.exports = async (member, oldChannel) => {
|
|||
waitMessage.delete();
|
||||
connection.player.stop(connection.originalChannel.guild.id);
|
||||
} else {
|
||||
const randomMember = members.random();
|
||||
const randomMember = random(members);
|
||||
soundPlayer.players.set(connection.voiceChannel.guild.id, { player: connection.player, type: connection.type, host: randomMember.id, voiceChannel: connection.voiceChannel, originalChannel: connection.originalChannel });
|
||||
waitMessage.edit(`🔊 ${randomMember.mention} is the new voice channel host.`);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue