From 17e9900092948ddcc44f83a90dcb2114583137a5 Mon Sep 17 00:00:00 2001 From: dev-737 <73829355+dev-737@users.noreply.github.com> Date: Sun, 17 Mar 2024 09:40:14 +0530 Subject: [PATCH] fix(utils): default parameters should be placed after non-default ones (#55) Fixes #53 ---
Generated summary (powered by Graphite) > ## TL;DR > This pull request swaps the order of the `guildId` and `roleId` parameters in the `modifyUserRole` function in `Utils.ts`. > > ## What changed > In the `modifyUserRole` function, the `guildId` parameter was previously set to default to `SUPPORT_SERVER_ID` if no value was provided. This parameter was placed before the `roleId` parameter. This order has been swapped in this pull request, so now `roleId` comes before `guildId`. > > ```diff > - guildId: Snowflake = SUPPORT_SERVER_ID, > roleId: Snowflake, > + guildId: Snowflake = SUPPORT_SERVER_ID, > ``` > > ## How to test > To test this change, call the `modifyUserRole` function with various combinations of parameters. Ensure that the function behaves as expected when `guildId` is not provided, and that it correctly uses the provided `roleId`. > > ## Why make this change > This change improves the readability and usability of the `modifyUserRole` function. By placing the `roleId` parameter before the `guildId` parameter, it is clearer that `roleId` is a required parameter, while `guildId` is optional and will default to `SUPPORT_SERVER_ID` if not provided. This makes the function easier to use and understand.
--- src/utils/Utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index 498f729b..becac876 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -395,8 +395,8 @@ export const modifyUserRole = async ( cluster: ClusterClient | ClusterManager, action: 'add' | 'remove', userId: Snowflake, - guildId: Snowflake = SUPPORT_SERVER_ID, roleId: Snowflake, + guildId: Snowflake = SUPPORT_SERVER_ID, ) => { await cluster.broadcastEval( async (client, ctx) => {