| import { getCommandMentionByName } from './../utils/getCommandDataByName.js'; |
| import type { NucleusClient } from "../utils/client.js"; |
| import convertCurlyBracketString from "../utils/convertCurlyBracketString.js"; |
| import client from "../utils/client.js"; |
| import EmojiEmbed from "../utils/generateEmojiEmbed.js"; |
| import { GuildChannel, GuildMember, BaseGuildTextChannel } from "discord.js"; |
| import singleNotify from "../utils/singleNotify.js"; |
| |
| export async function callback(_client: NucleusClient, member: GuildMember) { |
| if (member.user.bot) return; |
| const config = await client.database.guilds.read(member.guild.id); |
| if (!config.welcome.enabled) return; |
| |
| if (config.welcome.channel) { |
| let string = config.welcome.message; |
| if (string) { |
| string = await convertCurlyBracketString( |
| string, |
| member.id, |
| member.displayName, |
| member.guild.name, |
| member.guild.members |
| ); |
| if (config.welcome.channel === "dm") { |
| await member.send({ |
| embeds: [new EmojiEmbed().setDescription(string).setStatus("Success")] |
| }); |
| } else { |
| const channel: GuildChannel | null = await member.guild.channels.fetch(config.welcome.channel) as GuildChannel | null; |
| if (!channel) return await singleNotify("welcomeChannelDeleted", member.guild.id, `The welcome channel has been deleted or is no longer accessible. Use ${getCommandMentionByName("settings/welcome")} to set a new one`, "Warning") |
| if (!(channel instanceof BaseGuildTextChannel)) return; |
| if (channel.guild.id !== member.guild.id) return; |
| try { |
| await channel.send({ |
| embeds: [new EmojiEmbed().setDescription(string).setStatus("Success")], |
| content: (config.welcome.ping ? `<@${config.welcome.ping}>` : "") + `<@${member.id}>` |
| }); |
| } catch (err) { |
| singleNotify( |
| "welcomeChannelDeleted", |
| member.guild.id, |
| `The welcome channel has been deleted or is no longer accessible. Use ${getCommandMentionByName("settings/welcome")} to set a new one`, |
| "Warning" |
| ) |
| } |
| } |
| } |
| } |
| } |