From 1eaf5bc2dadd9f811685038941479192345c6494 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Sun, 13 Mar 2022 21:25:02 -0400 Subject: fix: move join log errors to guild --- src/listeners/guild/guildMemberAdd.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/listeners/guild') diff --git a/src/listeners/guild/guildMemberAdd.ts b/src/listeners/guild/guildMemberAdd.ts index 262cde3..adbca0f 100644 --- a/src/listeners/guild/guildMemberAdd.ts +++ b/src/listeners/guild/guildMemberAdd.ts @@ -21,6 +21,13 @@ export default class GuildMemberAddListener extends BushListener { const welcome = client.channels.cache.get(welcomeChannel) as BushTextChannel | undefined; if (!welcome) return; if (member.guild.id !== welcome?.guild.id) throw new Error('Welcome channel must be in the guild.'); + + if (!welcome.guild.me) return; + + if (!welcome.permissionsFor(welcome.guild.me).has('SendMessages')) + // eslint-disable-next-line @typescript-eslint/no-base-to-string + return welcome.guild.error('Send Welcome Message', `I do not have permission to send messages in ${welcome}.`); + const embed = new Embed() .setDescription( `${util.emojis.join} ${util.format.input( @@ -28,6 +35,7 @@ export default class GuildMemberAddListener extends BushListener { )} joined the server. There are now ${member.guild.memberCount.toLocaleString()} members.` ) .setColor(util.colors.green); + await welcome .send({ embeds: [embed] }) .then(() => @@ -37,8 +45,8 @@ export default class GuildMemberAddListener extends BushListener { ) ) .catch(() => - client.console.warn( - 'guildMemberAdd', + welcome.guild.error( + 'Welcome Message', `Failed to send message for ${util.format.inputLog(member.user.tag)} in ${util.format.inputLog(member.guild.name)}.` ) ); -- cgit