Skip to content

Commit

Permalink
fix: OptionsHandler#getMentionable always returning user (#125)
Browse files Browse the repository at this point in the history
* fix: `OptionsHandler#getMentionable` always returning user even when invalid

* chore: add changeset
  • Loading branch information
apteryxxyz committed Sep 18, 2024
1 parent 15e2cf3 commit 3bf77fb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/beige-melons-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@buape/carbon": patch
---

fix: `OptionsHandler#getMentionable` always returning user even when invalid
11 changes: 7 additions & 4 deletions packages/carbon/src/internals/OptionsHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,13 @@ export class OptionsHandler extends Base {
if (!id || typeof id !== "string")
throw new Error(`Missing required option: ${key}`)
} else if (!id || typeof id !== "string") return undefined
const user = new User(this.client, id)
await user.fetch().catch(() => {

try {
const user = new User(this.client, id)
await user.fetch()
return user
} catch {
return new Role(this.client, id)
})
return user
}
}
}

0 comments on commit 3bf77fb

Please sign in to comment.