🌟 feat: add DM notification for repel action#41
Merged
Conversation
wiktoriavh
approved these changes
Nov 26, 2025
Comment on lines
+118
to
+126
| try { | ||
| await target.send({ | ||
| flags: MessageFlags.IsComponentsV2, | ||
| components: [containerComponent], | ||
| }); | ||
| return true; | ||
| } catch { | ||
| return false; | ||
| } |
Member
There was a problem hiding this comment.
personally i would not return anything, and instead throw an error on catch, as well as console.log the error
Suggested change
| 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
Comment on lines
+503
to
+510
| if (shouldDMUser) { | ||
| dmSent = await sendReasonToTarget({ | ||
| target, | ||
| reason, | ||
| guildName: interaction.guild.name, | ||
| timeoutDuration: timeout, | ||
| }); | ||
| } |
Member
There was a problem hiding this comment.
and then (2/2) we do this here
Suggested change
| 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; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).