Skip to content

Commit

Permalink
Fix dm on timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
drklee3 committed Aug 9, 2023
1 parent 9cf30fa commit 8155e73
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions packages/sushii-worker/src/events/ModLogHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,30 +294,22 @@ const modLogHandler: EventHandlerFn<Events.GuildAuditLogEntryCreate> = async (
timeoutChange.new || null
);

if (event.target instanceof User) {
try {
await event.target.send({
embeds: [dmEmbed],
});
} catch (err) {
logger.warn(
{
actionType,
timeoutChange,
eventTarget: event.target,
err,
},
"Failed to send timeout DM to user"
);
}
} else {
// event.target is null, only event.targetId exists
const targetUser = await guild.client.users.fetch(event.targetId);

try {
await targetUser.send({
embeds: [dmEmbed],
});
} catch (err) {
logger.warn(
{
actionType,
timeoutChange,
eventTarget: event.target,
err,
},
"Target is not a user"
"Failed to send timeout DM to user"
);
}
} else {
Expand Down

0 comments on commit 8155e73

Please sign in to comment.