Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
akpi816218 committed Apr 4, 2024
1 parent 1c08a19 commit 86dc86c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
8 changes: 1 addition & 7 deletions src/events/a.getGuildConf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 4 additions & 6 deletions src/events/guildMemberAdd.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import {
BaseGuildTextChannel,
EmbedBuilder,
Events,
GuildMember,
NewsChannel,
TextChannel,
userMention
} from 'discord.js';
import { getGuildGreetingData } from './a.getGuildConf';
Expand All @@ -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()
Expand Down

0 comments on commit 86dc86c

Please sign in to comment.