-
Notifications
You must be signed in to change notification settings - Fork 1
🌟 feat: add DM notification for repel action #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| try { | ||
| await target.send({ | ||
| flags: MessageFlags.IsComponentsV2, | ||
| components: [containerComponent], | ||
| }); | ||
| return true; | ||
| } catch { | ||
| return false; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
personally i would not return anything, and instead throw an error on catch, as well as console.log the error
| try { | |
| await target.send({ | |
| flags: MessageFlags.IsComponentsV2, | |
| components: [containerComponent], | |
| }); | |
| return true; | |
| } catch { | |
| return false; | |
| } | |
| try { | |
| await target.send({ | |
| flags: MessageFlags.IsComponentsV2, | |
| components: [containerComponent], | |
| }); | |
| } catch (error) { | |
| console.log("Unable to send DM to user:\n", error); | |
| throw new Error(""Unable to send DM to user."); | |
| } |
and then ... (see next comment) 1/2
| if (shouldDMUser) { | ||
| dmSent = await sendReasonToTarget({ | ||
| target, | ||
| reason, | ||
| guildName: interaction.guild.name, | ||
| timeoutDuration: timeout, | ||
| }); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and then (2/2) we do this here
| if (shouldDMUser) { | |
| dmSent = await sendReasonToTarget({ | |
| target, | |
| reason, | |
| guildName: interaction.guild.name, | |
| timeoutDuration: timeout, | |
| }); | |
| } | |
| if (shouldDMUser) { | |
| try { | |
| await sendReasonToTarget({ | |
| target, | |
| reason, | |
| guildName: interaction.guild.name, | |
| timeoutDuration: timeout, | |
| }); | |
| } | |
| dmSent = true; // but could also be default to true | |
| } catch { | |
| dmSent = false; | |
| } |
adds a
dm_userboolean option (default: true)if it's true, the bot will attempt to DM the target about the repel and the reason, and in the repel log it will log whether the DM was sent or not (https://discordjs.guide/legacy/popular-topics/errors#cannot-send-messages-to-this-user).