From 5c40cd70e1e697857eecbec8cccc41d52fb3ad70 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 21 Jun 2022 18:04:04 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=91=20accidently=20pushed=20using=20wr?= =?UTF-8?q?ong=20config=20type,=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +- src/plugins/commands/config/index.ts | 37 +++++ .../commands/config/modules/audits/index.ts | 85 +++++++++++ .../commands/config/modules/cpgg/index.ts | 86 +++++++++++ .../commands/config/modules/credits/index.ts | 134 ++++++++++++++++++ .../embeds/components/getValues/index.ts | 35 +++++ .../commands/config/modules/embeds/index.ts | 98 +++++++++++++ src/plugins/commands/config/modules/index.ts | 9 ++ .../commands/config/modules/points/index.ts | 106 ++++++++++++++ .../commands/config/modules/shop/index.ts | 87 ++++++++++++ .../commands/config/modules/welcome/index.ts | 132 +++++++++++++++++ 11 files changed, 810 insertions(+), 2 deletions(-) create mode 100644 src/plugins/commands/config/index.ts create mode 100644 src/plugins/commands/config/modules/audits/index.ts create mode 100644 src/plugins/commands/config/modules/cpgg/index.ts create mode 100644 src/plugins/commands/config/modules/credits/index.ts create mode 100644 src/plugins/commands/config/modules/embeds/components/getValues/index.ts create mode 100644 src/plugins/commands/config/modules/embeds/index.ts create mode 100644 src/plugins/commands/config/modules/index.ts create mode 100644 src/plugins/commands/config/modules/points/index.ts create mode 100644 src/plugins/commands/config/modules/shop/index.ts create mode 100644 src/plugins/commands/config/modules/welcome/index.ts diff --git a/.gitignore b/.gitignore index 9e1cc15..9fe2862 100644 --- a/.gitignore +++ b/.gitignore @@ -4,8 +4,7 @@ node_modules config.json package-lock.json - -config/ +src/config/ # Build build/ diff --git a/src/plugins/commands/config/index.ts b/src/plugins/commands/config/index.ts new file mode 100644 index 0000000..3e8b585 --- /dev/null +++ b/src/plugins/commands/config/index.ts @@ -0,0 +1,37 @@ +import { SlashCommandBuilder } from "@discordjs/builders"; +import { CommandInteraction } from "discord.js"; + +import modules from "./modules"; + +export const builder = new SlashCommandBuilder() + .setName("config") + .setDescription("Manage guild configurations.") + + .addSubcommand(modules.cpgg.builder) + .addSubcommand(modules.credits.builder) + .addSubcommand(modules.points.builder) + .addSubcommand(modules.welcome.builder) + .addSubcommand(modules.audits.builder) + .addSubcommand(modules.shop.builder) + .addSubcommand(modules.embeds.builder); + +export const moduleData = modules; + +export const execute = async (interaction: CommandInteraction) => { + switch (interaction.options?.getSubcommand()) { + case "cpgg": + return modules.cpgg.execute(interaction); + case "credits": + return modules.credits.execute(interaction); + case "points": + return modules.points.execute(interaction); + case "welcome": + return modules.welcome.execute(interaction); + case "audits": + return modules.audits.execute(interaction); + case "shop": + return modules.shop.execute(interaction); + case "embeds": + return modules.embeds.execute(interaction); + } +}; diff --git a/src/plugins/commands/config/modules/audits/index.ts b/src/plugins/commands/config/modules/audits/index.ts new file mode 100644 index 0000000..f090b45 --- /dev/null +++ b/src/plugins/commands/config/modules/audits/index.ts @@ -0,0 +1,85 @@ +import { CommandInteraction, Permissions } from "discord.js"; + +import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; + +import logger from "../../../../../logger"; + +import guildSchema from "../../../../../models/guild"; +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import { ChannelType } from "discord-api-types/v10"; + +export default { + metadata: { + guildOnly: true, + ephemeral: true, + permissions: [Permissions.FLAGS.MANAGE_GUILD], + }, + + builder: (command: SlashCommandSubcommandBuilder) => { + return command + .setName("audits") + .setDescription("Audits") + .addBooleanOption((option) => + option.setName("status").setDescription("Should audits be enabled?") + ) + .addChannelOption((option) => + option + .setName("channel") + .setDescription("Channel for audit messages.") + .addChannelTypes(ChannelType.GuildText) + ); + }, + execute: async (interaction: CommandInteraction) => { + const { successColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); + + const { guild, options } = interaction; + + const status = options?.getBoolean("status"); + const channel = options?.getChannel("channel"); + + const guildDB = await guildSchema?.findOne({ + guildId: guild?.id, + }); + + if (guildDB === null) { + return logger?.silly(`Guild not found in database.`); + } + + guildDB.audits.status = status !== null ? status : guildDB?.audits?.status; + guildDB.audits.channelId = + channel !== null ? channel.id : guildDB?.audits?.channelId; + + await guildDB?.save()?.then(async () => { + logger?.silly(`Guild audits updated.`); + + return interaction?.editReply({ + embeds: [ + { + title: ":hammer: Settings - Guild [Audits]", + description: `Audits settings updated.`, + color: successColor, + fields: [ + { + name: "🤖 Status", + value: `${guildDB?.audits?.status}`, + inline: true, + }, + { + name: "🌊 Channel", + value: `${guildDB?.audits?.channelId}`, + inline: true, + }, + ], + timestamp: new Date(), + footer: { + iconURL: footerIcon, + text: footerText, + }, + }, + ], + }); + }); + }, +}; diff --git a/src/plugins/commands/config/modules/cpgg/index.ts b/src/plugins/commands/config/modules/cpgg/index.ts new file mode 100644 index 0000000..4ba34e0 --- /dev/null +++ b/src/plugins/commands/config/modules/cpgg/index.ts @@ -0,0 +1,86 @@ +import { CommandInteraction, Permissions } from "discord.js"; + +import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; + +import logger from "../../../../../logger"; + +import apiSchema from "../../../../../models/api"; +import encryption from "../../../../../handlers/encryption"; +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; + +export default { + metadata: { + guildOnly: true, + ephemeral: true, + permissions: [Permissions.FLAGS.MANAGE_GUILD], + }, + + builder: (command: SlashCommandSubcommandBuilder) => { + return command + .setName("cpgg") + .setDescription("Controlpanel.gg") + .addStringOption((option) => + option + .setName("scheme") + .setDescription(`Controlpanel.gg Scheme`) + .setRequired(true) + .setChoices( + { name: "HTTPS (secure)", value: "https" }, + { name: "HTTP (insecure)", value: "http" } + ) + ) + .addStringOption((option) => + option + .setName("domain") + .setDescription(`Controlpanel.gg Domain`) + .setRequired(true) + ) + .addStringOption((option) => + option + .setName("token") + .setDescription(`Controlpanel.gg Application API`) + .setRequired(true) + ); + }, + execute: async (interaction: CommandInteraction) => { + const { successColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); + const { options, guild } = interaction; + + const tokenData = options.getString("token"); + const scheme = options.getString("scheme"); + const domain = options.getString("domain"); + const token = tokenData && encryption.encrypt(tokenData); + const url = scheme && domain && encryption.encrypt(`${scheme}://${domain}`); + + await apiSchema + ?.findOneAndUpdate( + { guildId: guild?.id }, + { url, token }, + { new: true, upsert: true } + ) + .then(async () => { + logger?.silly(`Updated API credentials.`); + + return interaction?.editReply({ + embeds: [ + { + title: "[:tools:] CPGG", + description: `The following configuration will be used. + + **Scheme**: ${scheme} + **Domain**: ${domain} + **Token**: ends with ${tokenData?.slice(-4)}`, + color: successColor, + timestamp: new Date(), + footer: { + iconURL: footerIcon, + text: footerText, + }, + }, + ], + }); + }); + }, +}; diff --git a/src/plugins/commands/config/modules/credits/index.ts b/src/plugins/commands/config/modules/credits/index.ts new file mode 100644 index 0000000..f8b344f --- /dev/null +++ b/src/plugins/commands/config/modules/credits/index.ts @@ -0,0 +1,134 @@ +import { CommandInteraction, Permissions } from "discord.js"; + +import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; + +import logger from "../../../../../logger"; + +import guildSchema from "../../../../../models/guild"; +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; + +export default { + metadata: { + guildOnly: true, + ephemeral: true, + permissions: [Permissions.FLAGS.MANAGE_GUILD], + }, + + builder: (command: SlashCommandSubcommandBuilder) => { + return command + .setName("credits") + .setDescription(`Credits`) + .addBooleanOption((option) => + option.setName("status").setDescription("Should credits be enabled?") + ) + .addNumberOption((option) => + option.setName("rate").setDescription("Amount of credits per message.") + ) + .addNumberOption((option) => + option + .setName("minimum-length") + .setDescription("Minimum length of message to earn credits.") + ) + .addNumberOption((option) => + option + .setName("work-rate") + .setDescription("Maximum amount of credits on work.") + ) + .addNumberOption((option) => + option + .setName("work-timeout") + .setDescription("Timeout between work schedules (seconds).") + ) + .addNumberOption((option) => + option + .setName("timeout") + .setDescription("Timeout between earning credits (seconds).") + ); + }, + execute: async (interaction: CommandInteraction) => { + const { successColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); + const { guild, options } = interaction; + + if (guild == null) return; + + const status = options?.getBoolean("status"); + const rate = options?.getNumber("rate"); + const timeout = options?.getNumber("timeout"); + const minimumLength = options?.getNumber("minimum-length"); + const workRate = options?.getNumber("work-rate"); + const workTimeout = options?.getNumber("work-timeout"); + + const guildDB = await guildSchema?.findOne({ + guildId: guild?.id, + }); + + if (guildDB === null) { + return logger?.silly(`Guild is null`); + } + + guildDB.credits.status = + status !== null ? status : guildDB?.credits?.status; + guildDB.credits.rate = rate !== null ? rate : guildDB?.credits?.rate; + guildDB.credits.timeout = + timeout !== null ? timeout : guildDB?.credits?.timeout; + guildDB.credits.workRate = + workRate !== null ? workRate : guildDB?.credits?.workRate; + guildDB.credits.workTimeout = + workTimeout !== null ? workTimeout : guildDB?.credits?.workTimeout; + guildDB.credits.minimumLength = + minimumLength !== null ? minimumLength : guildDB?.credits?.minimumLength; + + await guildDB?.save()?.then(async () => { + logger?.silly(`Guild saved`); + + return interaction?.editReply({ + embeds: [ + { + title: ":tools: Settings - Guild [Credits]", + description: `Credits settings updated.`, + color: successColor, + fields: [ + { + name: "🤖 Status", + value: `${guildDB?.credits?.status}`, + inline: true, + }, + { + name: "📈 Rate", + value: `${guildDB?.credits?.rate}`, + inline: true, + }, + { + name: "📈 Work Rate", + value: `${guildDB?.credits?.workRate}`, + inline: true, + }, + { + name: "🔨 Minimum Length", + value: `${guildDB?.credits?.minimumLength}`, + inline: true, + }, + { + name: "⏰ Timeout", + value: `${guildDB?.credits?.timeout}`, + inline: true, + }, + { + name: "⏰ Work Timeout", + value: `${guildDB?.credits?.workTimeout}`, + inline: true, + }, + ], + timestamp: new Date(), + footer: { + iconURL: footerIcon, + text: footerText, + }, + }, + ], + }); + }); + }, +}; diff --git a/src/plugins/commands/config/modules/embeds/components/getValues/index.ts b/src/plugins/commands/config/modules/embeds/components/getValues/index.ts new file mode 100644 index 0000000..a61ecb3 --- /dev/null +++ b/src/plugins/commands/config/modules/embeds/components/getValues/index.ts @@ -0,0 +1,35 @@ +import { ColorResolvable, CommandInteraction } from "discord.js"; +import guildSchema from "../../../../../../../models/guild"; +import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; + +export default async (interaction: CommandInteraction) => { + const { options, guild } = interaction; + + if (!guild) throw new Error("Guild not found"); + + const embedConfig = await getEmbedConfig(guild); + if (!embedConfig) throw new Error("Embed config not found"); + + const newSuccessColor = options.getString("success-color") as ColorResolvable; + const newWaitColor = options.getString("wait-color") as ColorResolvable; + const newErrorColor = options.getString("error-color") as ColorResolvable; + const newFooterIcon = options.getString("footer-icon"); + const newFooterText = options.getString("footer-text"); + + const guildData = await guildSchema.findOne({ + guildId: guild.id, + }); + if (!guildData) throw new Error("Guild data not found"); + if (!guildData?.embeds) + throw new Error("Guild embed configuration not found"); + let { successColor, waitColor, errorColor, footerText, footerIcon } = + guildData.embeds; + + successColor = newSuccessColor || successColor; + waitColor = newWaitColor || waitColor; + errorColor = newErrorColor || errorColor; + footerIcon = newFooterIcon || footerIcon; + footerText = newFooterText || footerText; + + return { successColor, waitColor, errorColor, footerText, footerIcon }; +}; diff --git a/src/plugins/commands/config/modules/embeds/index.ts b/src/plugins/commands/config/modules/embeds/index.ts new file mode 100644 index 0000000..db8bef0 --- /dev/null +++ b/src/plugins/commands/config/modules/embeds/index.ts @@ -0,0 +1,98 @@ +import { + ColorResolvable, + CommandInteraction, + MessageEmbed, + Permissions, +} from "discord.js"; + +import logger from "../../../../../logger"; + +import guildSchema from "../../../../../models/guild"; +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; +import getValues from "./components/getValues"; + +export default { + metadata: { + guildOnly: true, + ephemeral: true, + permissions: [Permissions.FLAGS.MANAGE_GUILD], + }, + + builder: (command: SlashCommandSubcommandBuilder) => { + return command + .setName("embeds") + .setDescription(`Embeds`) + .addStringOption((option) => + option + .setName("success-color") + .setDescription("No provided description") + ) + .addStringOption((option) => + option.setName("wait-color").setDescription("No provided description") + ) + .addStringOption((option) => + option.setName("error-color").setDescription("No provided description") + ) + .addStringOption((option) => + option.setName("footer-icon").setDescription("No provided description") + ) + .addStringOption((option) => + option.setName("footer-text").setDescription("No provided description") + ); + }, + execute: async (interaction: CommandInteraction) => { + const { guild } = interaction; + if (!guild) throw new Error("Guild not found"); + + const { successColor, waitColor, errorColor, footerText, footerIcon } = + await getValues(interaction); + + const embed = new MessageEmbed() + .setTitle("[:tools:] Embeds") + .setFooter({ text: footerText, iconURL: footerIcon }) + .setTimestamp(new Date()); + + const guildData = await guildSchema.findOne({ + guildId: guild.id, + }); + if (!guildData) throw new Error("Guild data not found"); + + await guildData.save().then(async () => { + embed + .setDescription("Following embed configuration will be used.") + .setColor(successColor) + .addFields([ + { + name: "🟢 Success Color", + value: `${successColor}`, + inline: true, + }, + { + name: "🟡 Wait Color", + value: `${waitColor}`, + inline: true, + }, + { + name: "🔴 Error Color", + value: `${errorColor}`, + inline: true, + }, + { + name: "🖼️ Footer Icon", + value: `${footerIcon}`, + inline: true, + }, + { + name: "📄 Footer Text", + value: `${footerText}`, + inline: true, + }, + ]); + + return interaction.editReply({ + embeds: [embed], + }); + }); + }, +}; diff --git a/src/plugins/commands/config/modules/index.ts b/src/plugins/commands/config/modules/index.ts new file mode 100644 index 0000000..45d8a9f --- /dev/null +++ b/src/plugins/commands/config/modules/index.ts @@ -0,0 +1,9 @@ +import audits from "./audits"; +import credits from "./credits"; +import points from "./points"; +import cpgg from "./cpgg"; +import shop from "./shop"; +import welcome from "./welcome"; +import embeds from "./embeds"; + +export default { audits, credits, points, cpgg, shop, welcome, embeds }; diff --git a/src/plugins/commands/config/modules/points/index.ts b/src/plugins/commands/config/modules/points/index.ts new file mode 100644 index 0000000..8813cf6 --- /dev/null +++ b/src/plugins/commands/config/modules/points/index.ts @@ -0,0 +1,106 @@ +import { CommandInteraction, Permissions } from "discord.js"; + +import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; + +import logger from "../../../../../logger"; + +import guildSchema from "../../../../../models/guild"; +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; + +export default { + metadata: { + guildOnly: true, + ephemeral: true, + permissions: [Permissions.FLAGS.MANAGE_GUILD], + }, + + builder: (command: SlashCommandSubcommandBuilder) => { + return command + .setName("points") + .setDescription("Points") + .addBooleanOption((option) => + option.setName("status").setDescription("Should credits be enabled?") + ) + .addNumberOption((option) => + option.setName("rate").setDescription("Amount of credits per message.") + ) + .addNumberOption((option) => + option + .setName("minimum-length") + .setDescription("Minimum length of message to earn credits.") + ) + .addNumberOption((option) => + option + .setName("timeout") + .setDescription("Timeout between earning credits (milliseconds).") + ); + }, + execute: async (interaction: CommandInteraction) => { + const { successColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); + + const { options, guild } = interaction; + + const status = options?.getBoolean("status"); + const rate = options?.getNumber("rate"); + const timeout = options?.getNumber("timeout"); + const minimumLength = options?.getNumber("minimum-length"); + + const guildDB = await guildSchema?.findOne({ + guildId: guild?.id, + }); + + if (guildDB === null) { + return logger?.silly(`Guild not found in database.`); + } + + guildDB.points.status = status !== null ? status : guildDB?.points?.status; + guildDB.points.rate = rate !== null ? rate : guildDB?.points?.rate; + guildDB.points.timeout = + timeout !== null ? timeout : guildDB?.points?.timeout; + guildDB.points.minimumLength = + minimumLength !== null ? minimumLength : guildDB?.points?.minimumLength; + + await guildDB?.save()?.then(async () => { + logger?.silly(`Guild points updated.`); + + return interaction?.editReply({ + embeds: [ + { + title: ":hammer: Settings - Guild [Points]", + description: `Points settings updated.`, + color: successColor, + fields: [ + { + name: "🤖 Status", + value: `${guildDB?.points?.status}`, + inline: true, + }, + { + name: "📈 Rate", + value: `${guildDB?.points?.rate}`, + inline: true, + }, + { + name: "🔨 Minimum Length", + value: `${guildDB?.points?.minimumLength}`, + inline: true, + }, + { + name: "⏰ Timeout", + value: `${guildDB?.points?.timeout}`, + inline: true, + }, + ], + timestamp: new Date(), + footer: { + iconURL: footerIcon, + text: footerText, + }, + }, + ], + }); + }); + }, +}; diff --git a/src/plugins/commands/config/modules/shop/index.ts b/src/plugins/commands/config/modules/shop/index.ts new file mode 100644 index 0000000..328b169 --- /dev/null +++ b/src/plugins/commands/config/modules/shop/index.ts @@ -0,0 +1,87 @@ +import { CommandInteraction, Permissions } from "discord.js"; + +import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; + +import logger from "../../../../../logger"; + +import guildSchema from "../../../../../models/guild"; +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; + +export default { + metadata: { + guildOnly: true, + ephemeral: true, + permissions: [Permissions.FLAGS.MANAGE_GUILD], + }, + + builder: (command: SlashCommandSubcommandBuilder) => { + return command + .setName("shop") + .setDescription("Shop") + .addBooleanOption((option) => + option + .setName("roles-status") + .setDescription("Should roles be enabled?") + ) + .addNumberOption((option) => + option + .setName("roles-price-per-hour") + .setDescription("Price per hour for roles.") + ); + }, + execute: async (interaction: CommandInteraction) => { + const { successColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); + const { options, guild } = interaction; + + const rolesStatus = options?.getBoolean("roles-status"); + const rolesPricePerHour = options?.getNumber("roles-price-per-hour"); + + const guildDB = await guildSchema?.findOne({ + guildId: guild?.id, + }); + + if (guildDB === null) { + return logger?.silly(`Guild not found in database.`); + } + + guildDB.shop.roles.status = + rolesStatus !== null ? rolesStatus : guildDB?.shop?.roles?.status; + guildDB.shop.roles.pricePerHour = + rolesPricePerHour !== null + ? rolesPricePerHour + : guildDB?.shop?.roles?.pricePerHour; + + await guildDB?.save()?.then(async () => { + logger?.silly(`Guild shop updated.`); + + return interaction?.editReply({ + embeds: [ + { + title: ":hammer: Settings - Guild [Shop]", + description: `Shop settings updated.`, + color: successColor, + fields: [ + { + name: "🤖 Roles Status", + value: `${guildDB?.shop?.roles.status}`, + inline: true, + }, + { + name: "🌊 Roles Price Per Hour", + value: `${guildDB?.shop?.roles.pricePerHour}`, + inline: true, + }, + ], + timestamp: new Date(), + footer: { + iconURL: footerIcon, + text: footerText, + }, + }, + ], + }); + }); + }, +}; diff --git a/src/plugins/commands/config/modules/welcome/index.ts b/src/plugins/commands/config/modules/welcome/index.ts new file mode 100644 index 0000000..f77dd4e --- /dev/null +++ b/src/plugins/commands/config/modules/welcome/index.ts @@ -0,0 +1,132 @@ +import { CommandInteraction, Permissions } from "discord.js"; + +import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; + +import logger from "../../../../../logger"; + +import guildSchema from "../../../../../models/guild"; +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import { ChannelType } from "discord-api-types/v10"; + +export default { + metadata: { + guildOnly: true, + ephemeral: true, + permissions: [Permissions.FLAGS.MANAGE_GUILD], + }, + + builder: (command: SlashCommandSubcommandBuilder) => { + return command + .setName("welcome") + .setDescription("Welcome") + .addBooleanOption((option) => + option.setName("status").setDescription("Should welcome be enabled?") + ) + .addChannelOption((option) => + option + .setName("join-channel") + .setDescription("Channel for join messages.") + .addChannelTypes(ChannelType.GuildText) + ) + + .addChannelOption((option) => + option + .setName("leave-channel") + .setDescription("Channel for leave messages.") + .addChannelTypes(ChannelType.GuildText) + ) + + .addStringOption((option) => + option + .setName("leave-message") + .setDescription("Message for leave messages.") + ) + .addStringOption((option) => + option + .setName("join-message") + .setDescription("Message for join messages.") + ); + }, + execute: async (interaction: CommandInteraction) => { + const { successColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); + const { options, guild } = interaction; + + const status = options?.getBoolean("status"); + const joinChannel = options?.getChannel("join-channel"); + const leaveChannel = options?.getChannel("leave-channel"); + const joinChannelMessage = options?.getString("join-message"); + const leaveChannelMessage = options?.getString("leave-message"); + + const guildDB = await guildSchema?.findOne({ + guildId: guild?.id, + }); + + if (guildDB === null) { + return logger?.silly(`Guild not found in database.`); + } + + guildDB.welcome.status = + status !== null ? status : guildDB?.welcome?.status; + guildDB.welcome.joinChannel = + joinChannel !== null ? joinChannel.id : guildDB?.welcome?.joinChannel; + guildDB.welcome.leaveChannel = + leaveChannel !== null ? leaveChannel.id : guildDB?.welcome?.leaveChannel; + + guildDB.welcome.joinChannelMessage = + joinChannelMessage !== null + ? joinChannelMessage + : guildDB?.welcome?.joinChannelMessage; + guildDB.welcome.leaveChannelMessage = + leaveChannelMessage !== null + ? leaveChannelMessage + : guildDB?.welcome?.leaveChannelMessage; + + await guildDB?.save()?.then(async () => { + logger?.silly(`Guild welcome updated.`); + + if (!guildDB?.welcome?.status) { + return interaction?.editReply({ + embeds: [ + { + title: "[:tools:] Welcome", + description: `This module is currently disabled, please enable it to continue.`, + color: successColor, + timestamp: new Date(), + footer: { + iconURL: footerIcon, + text: footerText, + }, + }, + ], + }); + } + + return interaction?.editReply({ + embeds: [ + { + title: "[:tools:] Welcome", + description: `The following configuration will be used. + + [👋] **Welcome** + + ㅤ**Channel**: <#${guildDB?.welcome?.joinChannel}> + ㅤ**Message**: ${guildDB?.welcome?.joinChannelMessage} + + [🚪] **Leave** + + ㅤ**Channel**: <#${guildDB?.welcome?.leaveChannel}> + ㅤ**Message**: ${guildDB?.welcome?.leaveChannelMessage}`, + color: successColor, + timestamp: new Date(), + footer: { + iconURL: footerIcon, + text: footerText, + }, + }, + ], + }); + }); + }, +};