refactor: ♻️ improve checkPermission function

Made use of optional chaining (?.) to get rid of a if statement
This commit is contained in:
Axel Olausson Holtenäs 2023-10-01 17:15:38 +02:00
parent db93f72127
commit 83c0af64c9

View file

@ -1,9 +1,6 @@
import { Interaction, PermissionResolvable } from "discord.js";
export default (interaction: Interaction, permission: PermissionResolvable) => {
if (!interaction.memberPermissions)
throw new Error("Failed to check your permissions");
if (!interaction.memberPermissions.has(permission))
if (!interaction.memberPermissions?.has(permission))
throw new Error(`You do not have the required permission: ${permission}`);
};