Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: attempt rework for pre-component / pre-command checks #14

Open
sudojunior opened this issue May 9, 2022 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@sudojunior
Copy link
Member

sudojunior commented May 9, 2022

// current
if (condition) {
  // run code
}

// proposed
try {
  check(condition, failReason);
} catch (error) {
  await ctx.send(error?.message || error);
  return;
}

Approach to testing condition is derived from test framework assertions assert(condition, reason).

Currently used for the setup wizard when checking for channel permissions.

try {
checkPermissions({
channelEntity: lobbyChannel,
targetID: this.client.user.id,
permissions: managerPermissions,
action: 'lobby channel'
});
checkPermissions({
channelEntity: lobbyCategory,
targetID: this.client.user.id,
permissions: managerPermissions,
action: 'lobby category'
});
} catch (err) {
await ctx.send(err.message || JSON.stringify(err), { ephemeral: true });
return;
}

@sudojunior sudojunior added the enhancement New feature or request label May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant