Repository navigation
Conversation
Fixes permission descriptions (such as "Mention @everyone") being cut off to the first letter.
There was a problem hiding this comment.
Code Review
This pull request updates the PermissionSpecification interface to allow description to be a plain string, and updates the getDefinitions function to handle this new type. The reviewer suggests using the nullish coalescing operator (?? "") across the entire ternary expression to guarantee a string is returned, preventing potential undefined values when arrays are empty.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| id: Object.keys(DiscordPermissions).find(key => DiscordPermissions[key as keyof IDiscordPermissions] === perm.flag) ?? "", | ||
| name: perm.title, | ||
| description: typeof perm.description === "function" ? perm.description(BdApi.Webpack.Stores.LocaleStore.locale).ast[0] : perm.description[0] | ||
| description: typeof perm.description === "function" ? perm.description(BdApi.Webpack.Stores.LocaleStore.locale).ast[0] : (Array.isArray(perm.description) ? perm.description[0] : (perm.description || "")) |
There was a problem hiding this comment.
The current fallback logic (perm.description || "") is good, but it doesn't protect against cases where perm.description is a function that returns an empty ast array, or when perm.description is an empty array itself. In those cases, ast[0] or description[0] will be undefined, which violates the PermissionDefinition interface requiring description to be a string. Using the nullish coalescing operator (?? "") at the end of the entire ternary expression ensures that a string is always returned in all scenarios.
| description: typeof perm.description === "function" ? perm.description(BdApi.Webpack.Stores.LocaleStore.locale).ast[0] : (Array.isArray(perm.description) ? perm.description[0] : (perm.description || "")) | |
| description: (typeof perm.description === "function" ? perm.description(BdApi.Webpack.Stores.LocaleStore.locale).ast[0] : (Array.isArray(perm.description) ? perm.description[0] : perm.description)) ?? "" |
Fixes permission descriptions (such as "Mention @ everyone") being cut off to the first letter.

