Caption now supports more unicode characters, more api work, fixed multiple bugs
This commit is contained in:
parent
a03d3a5e79
commit
0600cf230f
11 changed files with 174 additions and 50 deletions
|
@ -1,11 +1,10 @@
|
|||
const db = require("../utils/database.js");
|
||||
const logger = require("../utils/logger.js");
|
||||
const misc = require("../utils/misc.js");
|
||||
const client = require("../utils/client.js");
|
||||
|
||||
// run when the bot is added to a guild
|
||||
module.exports = async (guild) => {
|
||||
logger.log("info", `[GUILD JOIN] ${guild.name} (${guild.id}) added the bot. Owner: ${client.users.get(guild.ownerID).username}#${client.users.get(guild.ownerID).discriminator} (${guild.ownerID})`);
|
||||
logger.log("info", `[GUILD JOIN] ${guild.name} (${guild.id}) added the bot.`);
|
||||
const guildDB = new db.guilds({
|
||||
id: guild.id,
|
||||
tags: misc.tagDefaults,
|
||||
|
@ -15,4 +14,5 @@ module.exports = async (guild) => {
|
|||
tagsDisabled: false
|
||||
});
|
||||
await guildDB.save();
|
||||
return guildDB;
|
||||
};
|
||||
|
|
|
@ -3,6 +3,7 @@ const client = require("../utils/client.js");
|
|||
const database = require("../utils/database.js");
|
||||
const logger = require("../utils/logger.js");
|
||||
const collections = require("../utils/collections.js");
|
||||
const guildCreate = require("./guildCreate.js");
|
||||
const commands = [...collections.aliases.keys(), ...collections.commands.keys()];
|
||||
|
||||
// run when someone sends a message
|
||||
|
@ -24,7 +25,10 @@ module.exports = async (message) => {
|
|||
if (!valid) return;
|
||||
|
||||
// prefix can be a mention or a set of special characters
|
||||
const guildDB = message.channel.guild ? await database.guilds.findOne({ id: message.channel.guild.id }).lean().exec() : null;
|
||||
let guildDB = message.channel.guild ? await database.guilds.findOne({ id: message.channel.guild.id }).lean().exec() : null;
|
||||
if (message.channel.guild && !guildDB) {
|
||||
guildDB = await guildCreate(message.channel.guild);
|
||||
}
|
||||
// there's a bit of a workaround here due to member.mention not accounting for both mention types
|
||||
const prefix = message.channel.guild ? (message.content.startsWith(message.channel.guild.members.get(client.user.id).mention) ? `${message.channel.guild.members.get(client.user.id).mention} ` : (message.content.startsWith(`<@${client.user.id}>`) ? `<@${client.user.id}> ` : guildDB.prefix)) : "";
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ module.exports = async () => {
|
|||
tagsDisabled: false
|
||||
});
|
||||
await newGuild.save();
|
||||
} else if (guildDB) {
|
||||
} else {
|
||||
if (!guildDB.warns) {
|
||||
logger.log(`Creating warn object for guild ${id}...`);
|
||||
guildDB.set("warns", {});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue