blob: 56391ec28621d39332a50a90913eb8de5a39d3b7 [file] [log] [blame]
import convertCurlyBracketString from "../utils/convertCurlyBracketString.js";
import client from "../utils/client.js";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";
export async function callback(_, member) {
if (member.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 = await member.guild.channels.fetch(config.welcome.channel);
if (channel.guild.id !== member.guild.id) return;
if (!channel) return;
try {
await channel.send({
embeds: [new EmojiEmbed().setDescription(string).setStatus("Success")],
content: (config.welcome.ping ? `<@${config.welcome.ping}>` : "") + `<@${member.id}>`
});
} catch (err) {
console.error(err); // TODO: SEN
}
}
}
}
}