From 0a10d91f8de59a1b3b25b9cd2a698248c0d6e9e6 Mon Sep 17 00:00:00 2001 From: Isaac Date: Sat, 6 Aug 2022 21:52:08 +0100 Subject: [PATCH] Closes #288 --- src/listeners/client/guildCreate.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/listeners/client/guildCreate.js b/src/listeners/client/guildCreate.js index 5cfbb4c..6867f0f 100644 --- a/src/listeners/client/guildCreate.js +++ b/src/listeners/client/guildCreate.js @@ -9,7 +9,22 @@ module.exports = class extends Listener { }); } - run(guild) { + /** + * @param {import("discord.js").Guild} guild + */ + async run(guild) { + /** @type {import("client")} */ + const client = this.client; + this.client.log.success(`Added to guild "${guild.name}"`); + let settings = await client.prisma.guild.findUnique({ where: { id: guild.id } }); + if (!settings) { + settings = await client.prisma.guild.create({ + data: { + id: guild.id, + locale: client.i18n.locales.includes(guild.preferredLocale) ? guild.preferredLocale : 'en-GB', + }, + }); + } } };