refactor: ♻️ improve checkPermission function
Made use of optional chaining (?.) to get rid of a if statement
This commit is contained in:
parent
db93f72127
commit
83c0af64c9
1 changed files with 1 additions and 4 deletions
|
@ -1,9 +1,6 @@
|
||||||
import { Interaction, PermissionResolvable } from "discord.js";
|
import { Interaction, PermissionResolvable } from "discord.js";
|
||||||
|
|
||||||
export default (interaction: Interaction, permission: PermissionResolvable) => {
|
export default (interaction: Interaction, permission: PermissionResolvable) => {
|
||||||
if (!interaction.memberPermissions)
|
if (!interaction.memberPermissions?.has(permission))
|
||||||
throw new Error("Failed to check your permissions");
|
|
||||||
|
|
||||||
if (!interaction.memberPermissions.has(permission))
|
|
||||||
throw new Error(`You do not have the required permission: ${permission}`);
|
throw new Error(`You do not have the required permission: ${permission}`);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue