From 86dc86cdcdd799e061adc44ce1c2e7a6aea67873 Mon Sep 17 00:00:00 2001 From: akpi816218 Date: Wed, 3 Apr 2024 19:24:30 -0700 Subject: [PATCH] refactor --- src/events/a.getGuildConf.ts | 8 +------- src/events/guildMemberAdd.ts | 10 ++++------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/events/a.getGuildConf.ts b/src/events/a.getGuildConf.ts index c3ea253..1fe8113 100644 --- a/src/events/a.getGuildConf.ts +++ b/src/events/a.getGuildConf.ts @@ -14,13 +14,7 @@ export async function getGuildAuditLoggingChannel(guild: Guild) { } export async function getGuildGreetingData(guild: Guild) { - const config = await getGuildConfig(guild); - if ( - config.greetings?.channel || - (!config.greetings?.goodbyeEnabled && !config.greetings?.welcomeEnabled) - ) - return; - return config.greetings; + return (await getGuildConfig(guild)).greetings; } async function getGuildConfig(guild: Guild) { diff --git a/src/events/guildMemberAdd.ts b/src/events/guildMemberAdd.ts index 24f390d..0cb4e2d 100644 --- a/src/events/guildMemberAdd.ts +++ b/src/events/guildMemberAdd.ts @@ -1,9 +1,8 @@ import { + BaseGuildTextChannel, EmbedBuilder, Events, GuildMember, - NewsChannel, - TextChannel, userMention } from 'discord.js'; import { getGuildGreetingData } from './a.getGuildConf'; @@ -14,10 +13,9 @@ export const execute = async (member: GuildMember) => { const config = await getGuildGreetingData(member.guild); if (!config?.welcomeEnabled) return; await ( - (await member.guild.channels.fetch(config.channel)) as - | NewsChannel - | TextChannel - | undefined + (await member.guild.channels.fetch( + config.channel + )) as BaseGuildTextChannel | null )?.send({ embeds: [ new EmbedBuilder()