Skip to content

Conversation

@hmd-ali
Copy link
Contributor

@hmd-ali hmd-ali commented Nov 23, 2025

adds a dm_user boolean 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).

@hmd-ali hmd-ali requested a review from wiktoriavh November 23, 2025 12:19
Comment on lines +118 to +126
try {
await target.send({
flags: MessageFlags.IsComponentsV2,
components: [containerComponent],
});
return true;
} catch {
return false;
}
Copy link
Member

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

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,
});
}
Copy link
Member

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

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;
}

@hmd-ali hmd-ali merged commit 9382bf2 into main Nov 26, 2025
1 check passed
@hmd-ali hmd-ali deleted the feat/send-dms-on-repel branch November 26, 2025 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants