@pipedream/slack 0.5.2 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/actions/add-emoji-reaction/add-emoji-reaction.mjs +11 -8
  2. package/actions/archive-channel/archive-channel.mjs +14 -4
  3. package/actions/common/build-blocks.mjs +5 -4
  4. package/actions/common/send-message.mjs +1 -23
  5. package/actions/create-channel/create-channel.mjs +10 -5
  6. package/actions/create-reminder/create-reminder.mjs +8 -8
  7. package/actions/delete-file/delete-file.mjs +6 -4
  8. package/actions/delete-message/delete-message.mjs +10 -5
  9. package/actions/find-message/find-message.mjs +21 -13
  10. package/actions/find-user-by-email/find-user-by-email.mjs +8 -4
  11. package/actions/get-file/get-file.mjs +6 -11
  12. package/actions/invite-user-to-channel/invite-user-to-channel.mjs +6 -4
  13. package/actions/kick-user/kick-user.mjs +17 -4
  14. package/actions/list-channels/list-channels.mjs +8 -4
  15. package/actions/list-files/list-files.mjs +21 -13
  16. package/actions/{list-user-groups-users/list-user-groups-users.mjs → list-group-members/list-group-members.mjs} +12 -6
  17. package/actions/list-members-in-channel/list-members-in-channel.mjs +22 -4
  18. package/actions/list-replies/list-replies.mjs +12 -5
  19. package/actions/list-users/list-users.mjs +8 -4
  20. package/actions/reply-to-a-message/reply-to-a-message.mjs +10 -10
  21. package/actions/send-custom-message/send-custom-message.mjs +27 -8
  22. package/actions/send-large-message/send-large-message.mjs +8 -4
  23. package/actions/{send-message-private-channel/send-message-private-channel.mjs → send-message/send-message.mjs} +13 -7
  24. package/actions/set-channel-description/set-channel-description.mjs +32 -0
  25. package/actions/set-channel-topic/set-channel-topic.mjs +6 -4
  26. package/actions/set-status/set-status.mjs +44 -0
  27. package/actions/update-group-members/update-group-members.mjs +67 -0
  28. package/actions/update-message/update-message.mjs +10 -5
  29. package/actions/update-profile/update-profile.mjs +70 -13
  30. package/actions/upload-file/upload-file.mjs +6 -4
  31. package/actions/verify-slack-signature/verify-slack-signature.mjs +2 -2
  32. package/package.json +3 -2
  33. package/slack.app.mjs +72 -71
  34. package/sources/common/base.mjs +9 -0
  35. package/sources/new-channel-created/new-channel-created.mjs +1 -1
  36. package/sources/new-direct-message/new-direct-message.mjs +3 -1
  37. package/sources/new-direct-message/test-event.mjs +28 -0
  38. package/sources/new-interaction-event-received/README.md +13 -13
  39. package/sources/new-interaction-event-received/new-interaction-event-received.mjs +7 -8
  40. package/sources/new-interaction-event-received/test-event.mjs +86 -0
  41. package/sources/{new-mention/new-mention.mjs → new-keyword-mention/new-keyword-mention.mjs} +8 -30
  42. package/sources/new-keyword-mention/test-event.mjs +28 -0
  43. package/sources/new-message-in-channels/new-message-in-channels.mjs +1 -1
  44. package/sources/new-reaction-added/new-reaction-added.mjs +4 -1
  45. package/sources/new-reaction-added/test-event.mjs +193 -0
  46. package/sources/new-user-mention/new-user-mention.mjs +117 -0
  47. package/sources/new-user-mention/test-event.mjs +28 -0
  48. package/actions/add-star/add-star.mjs +0 -43
  49. package/actions/complete-reminder/complete-reminder.mjs +0 -23
  50. package/actions/delete-reminder/delete-reminder.mjs +0 -23
  51. package/actions/get-channel/get-channel.mjs +0 -23
  52. package/actions/get-reminder/get-reminder.mjs +0 -23
  53. package/actions/join-channel/join-channel.mjs +0 -23
  54. package/actions/leave-channel/leave-channel.mjs +0 -23
  55. package/actions/list-reminders/list-reminders.mjs +0 -24
  56. package/actions/remove-star/remove-star.mjs +0 -40
  57. package/actions/send-block-kit-message/send-block-kit-message.mjs +0 -43
  58. package/actions/send-direct-message/send-direct-message.mjs +0 -32
  59. package/actions/send-group-message/send-group-message.mjs +0 -32
  60. package/actions/send-message-public-channel/send-message-public-channel.mjs +0 -38
  61. package/actions/set-channel-purpose/set-channel-purpose.mjs +0 -30
  62. package/actions/unarchive-channel/unarchive-channel.mjs +0 -23
  63. package/actions/update-user-groups-users/update-user-groups-users.mjs +0 -45
  64. package/sources/new-star-added/new-star-added.mjs +0 -45
@@ -3,8 +3,8 @@ import slack from "../../slack.app.mjs";
3
3
  export default {
4
4
  key: "slack-add-emoji-reaction",
5
5
  name: "Add Emoji Reaction",
6
- description: "Add an emoji reaction to a message. [See docs here](https://api.slack.com/methods/reactions.add)",
7
- version: "0.0.7",
6
+ description: "Add an emoji reaction to a message. [See the documentation](https://api.slack.com/methods/reactions.add)",
7
+ version: "0.0.8",
8
8
  type: "action",
9
9
  props: {
10
10
  slack,
@@ -13,15 +13,16 @@ export default {
13
13
  slack,
14
14
  "conversation",
15
15
  ],
16
- optional: false,
17
- description: "Channel to add reaction to, or channel where the message to add reaction to was posted (used with timestamp).",
16
+ description: "Channel where the message to add reaction to was posted.",
18
17
  },
19
18
  timestamp: {
20
19
  propDefinition: [
21
20
  slack,
22
- "timestamp",
21
+ "messageTs",
22
+ (c) => ({
23
+ channel: c.conversation,
24
+ }),
23
25
  ],
24
- optional: false,
25
26
  description: "Timestamp of the message to add reaction to.",
26
27
  },
27
28
  icon_emoji: {
@@ -33,11 +34,13 @@ export default {
33
34
  optional: false,
34
35
  },
35
36
  },
36
- async run() {
37
- return await this.slack.sdk().reactions.add({
37
+ async run({ $ }) {
38
+ const response = await this.slack.sdk().reactions.add({
38
39
  channel: this.conversation,
39
40
  timestamp: this.timestamp,
40
41
  name: this.icon_emoji,
41
42
  });
43
+ $.export("$summary", `Successfully added ${this.icon_emoji} emoji reaction.`);
44
+ return response;
42
45
  },
43
46
  };
@@ -1,10 +1,11 @@
1
1
  import slack from "../../slack.app.mjs";
2
+ import constants from "../../common/constants.mjs";
2
3
 
3
4
  export default {
4
5
  key: "slack-archive-channel",
5
6
  name: "Archive Channel",
6
- description: "Archive a channel. [See docs here](https://api.slack.com/methods/conversations.archive)",
7
- version: "0.0.15",
7
+ description: "Archive a channel. [See the documentation](https://api.slack.com/methods/conversations.archive)",
8
+ version: "0.0.16",
8
9
  type: "action",
9
10
  props: {
10
11
  slack,
@@ -12,12 +13,21 @@ export default {
12
13
  propDefinition: [
13
14
  slack,
14
15
  "conversation",
16
+ () => ({
17
+ types: [
18
+ constants.CHANNEL_TYPE.PUBLIC,
19
+ constants.CHANNEL_TYPE.PRIVATE,
20
+ constants.CHANNEL_TYPE.MPIM,
21
+ ],
22
+ }),
15
23
  ],
16
24
  },
17
25
  },
18
- async run() {
19
- return await this.slack.sdk().conversations.archive({
26
+ async run({ $ }) {
27
+ const response = await this.slack.sdk().conversations.archive({
20
28
  channel: this.conversation,
21
29
  });
30
+ $.export("$summary", "Successfully archived channel.");
31
+ return response;
22
32
  },
23
33
  };
@@ -1,13 +1,10 @@
1
1
  import common from "./send-message.mjs";
2
2
 
3
- /* eslint-disable pipedream/required-properties-key, pipedream/required-properties-name,
4
- pipedream/required-properties-version, pipedream/required-properties-description */
5
3
  export default {
6
- type: "action",
7
4
  props: {
8
5
  passArrayOrConfigure: {
9
6
  type: "string",
10
- label: "Reference Existing Blocks Array or Configure Manually?",
7
+ label: "Add Blocks - Reference Existing Blocks Array or Configure Manually?",
11
8
  description: "Would you like to reference an array of blocks from a previous step (for example, `{{steps.blocks.$return_value}}`), or configure them in this action?",
12
9
  options: [
13
10
  {
@@ -19,6 +16,7 @@ export default {
19
16
  value: "configure",
20
17
  },
21
18
  ],
19
+ optional: true,
22
20
  reloadProps: true,
23
21
  },
24
22
  },
@@ -92,6 +90,9 @@ export default {
92
90
  const propsContext = this.createBlockProp("string[]", "Context Block Text", contextDescription);
93
91
  const propsLinkButton = this.createBlockProp("object", "Link Button", linkButtonDescription);
94
92
 
93
+ if (!this.passArrayOrConfigure) {
94
+ return props;
95
+ }
95
96
  if (this.passArrayOrConfigure == "array") {
96
97
  props.blocks = {
97
98
  type: common.props.slack.propDefinitions.blocks.type,
@@ -1,9 +1,6 @@
1
1
  import slack from "../../slack.app.mjs";
2
2
 
3
- /* eslint-disable pipedream/required-properties-key, pipedream/required-properties-name,
4
- pipedream/required-properties-version, pipedream/required-properties-description */
5
3
  export default {
6
- type: "action",
7
4
  props: {
8
5
  slack,
9
6
  as_user: {
@@ -156,27 +153,8 @@ export default {
156
153
  metadata: this.metadata || null,
157
154
  };
158
155
 
159
- console.log({
160
- text: this.text,
161
- channel: this.conversation ?? this.reply_channel,
162
- attachments: this.attachments,
163
- unfurl_links: this.unfurl_links,
164
- unfurl_media: this.unfurl_media,
165
- parse: this.parse,
166
- as_user: this.as_user,
167
- username: this.username,
168
- icon_emoji: this.icon_emoji,
169
- icon_url: this.icon_url,
170
- mrkdwn: this.mrkdwn,
171
- blocks,
172
- link_names: this.link_names,
173
- reply_broadcast: this.reply_broadcast,
174
- thread_ts: this.thread_ts,
175
- metadata: this.metadata || null,
176
- });
177
-
178
156
  if (this.post_at) {
179
- obj.post_at = this.post_at;
157
+ obj.post_at = Math.floor(new Date(this.post_at).getTime() / 1000);
180
158
  return await this.slack.sdk().chat.scheduleMessage(obj);
181
159
  }
182
160
  const resp = await this.slack.sdk().chat.postMessage(obj);
@@ -3,8 +3,8 @@ import slack from "../../slack.app.mjs";
3
3
  export default {
4
4
  key: "slack-create-channel",
5
5
  name: "Create a Channel",
6
- description: "Create a new channel. [See docs here](https://api.slack.com/methods/conversations.create)",
7
- version: "0.0.16",
6
+ description: "Create a new channel. [See the documentation](https://api.slack.com/methods/conversations.create)",
7
+ version: "0.0.17",
8
8
  type: "action",
9
9
  props: {
10
10
  slack,
@@ -21,10 +21,15 @@ export default {
21
21
  optional: true,
22
22
  },
23
23
  },
24
- async run() {
25
- return await this.slack.sdk().conversations.create({
26
- name: this.channelName,
24
+ async run({ $ }) {
25
+ // parse name
26
+ const name = this.channelName.replace(/\s+/g, "-").toLowerCase();
27
+
28
+ const response = await this.slack.sdk().conversations.create({
29
+ name,
27
30
  is_private: this.isPrivate,
28
31
  });
32
+ $.export("$summary", `Successfully created channel ${this.channelName}`);
33
+ return response;
29
34
  },
30
35
  };
@@ -3,8 +3,8 @@ import slack from "../../slack.app.mjs";
3
3
  export default {
4
4
  key: "slack-create-reminder",
5
5
  name: "Create Reminder",
6
- description: "Create a reminder. [See docs here](https://api.slack.com/methods/reminders.add)",
7
- version: "0.0.16",
6
+ description: "Create a reminder. [See the documentation](https://api.slack.com/methods/reminders.add)",
7
+ version: "0.0.17",
8
8
  type: "action",
9
9
  props: {
10
10
  slack,
@@ -15,10 +15,8 @@ export default {
15
15
  ],
16
16
  },
17
17
  timestamp: {
18
- propDefinition: [
19
- slack,
20
- "timestamp",
21
- ],
18
+ type: "string",
19
+ label: "Timestamp",
22
20
  description: "When this reminder should happen: the Unix timestamp (up to five years from now), the number of seconds until the reminder (if within 24 hours), or a natural language description (Ex. in 15 minutes, or every Thursday)",
23
21
  },
24
22
  team_id: {
@@ -36,12 +34,14 @@ export default {
36
34
  optional: true,
37
35
  },
38
36
  },
39
- async run() {
40
- return await this.slack.sdk().reminders.add({
37
+ async run({ $ }) {
38
+ const response = await this.slack.sdk().reminders.add({
41
39
  text: this.text,
42
40
  team_id: this.team_id,
43
41
  time: this.timestamp,
44
42
  user: this.user,
45
43
  });
44
+ $.export("$summary", `Successfully created reminder with ID ${response.reminder.id}`);
45
+ return response;
46
46
  },
47
47
  };
@@ -3,8 +3,8 @@ import slack from "../../slack.app.mjs";
3
3
  export default {
4
4
  key: "slack-delete-file",
5
5
  name: "Delete File",
6
- description: "Delete a file. [See docs here](https://api.slack.com/methods/files.delete)",
7
- version: "0.0.15",
6
+ description: "Delete a file. [See the documentation](https://api.slack.com/methods/files.delete)",
7
+ version: "0.0.16",
8
8
  type: "action",
9
9
  props: {
10
10
  slack,
@@ -15,9 +15,11 @@ export default {
15
15
  ],
16
16
  },
17
17
  },
18
- async run() {
19
- return await this.slack.sdk().files.delete({
18
+ async run({ $ }) {
19
+ const response = await this.slack.sdk().files.delete({
20
20
  file: this.file,
21
21
  });
22
+ $.export("$summary", `Successfully deleted file with ID ${this.file}`);
23
+ return response;
22
24
  },
23
25
  };
@@ -3,8 +3,8 @@ import slack from "../../slack.app.mjs";
3
3
  export default {
4
4
  key: "slack-delete-message",
5
5
  name: "Delete Message",
6
- description: "Delete a message. [See docs here](https://api.slack.com/methods/chat.delete)",
7
- version: "0.0.15",
6
+ description: "Delete a message. [See the documentation](https://api.slack.com/methods/chat.delete)",
7
+ version: "0.0.16",
8
8
  type: "action",
9
9
  props: {
10
10
  slack,
@@ -17,7 +17,10 @@ export default {
17
17
  timestamp: {
18
18
  propDefinition: [
19
19
  slack,
20
- "timestamp",
20
+ "messageTs",
21
+ (c) => ({
22
+ channel: c.conversation,
23
+ }),
21
24
  ],
22
25
  },
23
26
  as_user: {
@@ -28,11 +31,13 @@ export default {
28
31
  description: "Pass true to update the message as the authed user. Bot users in this context are considered authed users.",
29
32
  },
30
33
  },
31
- async run() {
32
- return await this.slack.sdk().chat.delete({
34
+ async run({ $ }) {
35
+ const response = await this.slack.sdk().chat.delete({
33
36
  channel: this.conversation,
34
37
  ts: this.timestamp,
35
38
  as_user: this.as_user,
36
39
  });
40
+ $.export("$summary", "Successfully deleted message.");
41
+ return response;
37
42
  },
38
43
  };
@@ -3,8 +3,8 @@ import slack from "../../slack.app.mjs";
3
3
  export default {
4
4
  key: "slack-find-message",
5
5
  name: "Find Message",
6
- description: "Find a Slack message. [See docs here](https://api.slack.com/methods/search.messages)",
7
- version: "0.0.15",
6
+ description: "Find a Slack message. [See the documentation](https://api.slack.com/methods/search.messages)",
7
+ version: "0.0.16",
8
8
  type: "action",
9
9
  props: {
10
10
  slack,
@@ -14,13 +14,6 @@ export default {
14
14
  "query",
15
15
  ],
16
16
  },
17
- count: {
18
- propDefinition: [
19
- slack,
20
- "count",
21
- ],
22
- optional: true,
23
- },
24
17
  teamId: {
25
18
  propDefinition: [
26
19
  slack,
@@ -29,11 +22,26 @@ export default {
29
22
  optional: true,
30
23
  },
31
24
  },
32
- async run() {
33
- return this.slack.searchMessages({
25
+ async run({ $ }) {
26
+ const matches = [];
27
+ const params = {
34
28
  query: this.query,
35
- count: this.count,
36
29
  team_id: this.teamId,
37
- });
30
+ page: 1,
31
+ };
32
+ let hasMore;
33
+
34
+ do {
35
+ const { messages } = await this.slack.searchMessages(params);
36
+ matches.push(...messages.matches);
37
+ hasMore = messages?.length;
38
+ params.page++;
39
+ } while (hasMore);
40
+
41
+ $.export("$summary", `Found ${matches.length} matching message${matches.length === 1
42
+ ? ""
43
+ : "s"}`);
44
+
45
+ return matches;
38
46
  },
39
47
  };
@@ -3,8 +3,8 @@ import slack from "../../slack.app.mjs";
3
3
  export default {
4
4
  key: "slack-find-user-by-email",
5
5
  name: "Find User by Email",
6
- description: "Find a user by matching against their email. [See docs here](https://api.slack.com/methods/users.lookupByEmail)",
7
- version: "0.0.15",
6
+ description: "Find a user by matching against their email. [See the documentation](https://api.slack.com/methods/users.lookupByEmail)",
7
+ version: "0.0.16",
8
8
  type: "action",
9
9
  props: {
10
10
  slack,
@@ -15,9 +15,13 @@ export default {
15
15
  ],
16
16
  },
17
17
  },
18
- async run() {
19
- return await this.slack.sdk().users.lookupByEmail({
18
+ async run({ $ }) {
19
+ const response = await this.slack.sdk().users.lookupByEmail({
20
20
  email: this.email,
21
21
  });
22
+ if (response.ok) {
23
+ $.export("$summary", `Successfully found user with ID ${response.user.id}`);
24
+ }
25
+ return response;
22
26
  },
23
27
  };
@@ -3,8 +3,8 @@ import slack from "../../slack.app.mjs";
3
3
  export default {
4
4
  key: "slack-get-file",
5
5
  name: "Get File",
6
- description: "Return information about a file. [See docs here](https://api.slack.com/methods/files.info)",
7
- version: "0.0.15",
6
+ description: "Return information about a file. [See the documentation](https://api.slack.com/methods/files.info)",
7
+ version: "0.0.16",
8
8
  type: "action",
9
9
  props: {
10
10
  slack,
@@ -14,17 +14,12 @@ export default {
14
14
  "file",
15
15
  ],
16
16
  },
17
- count: {
18
- propDefinition: [
19
- slack,
20
- "count",
21
- ],
22
- },
23
17
  },
24
- async run() {
25
- return await this.slack.sdk().files.info({
18
+ async run({ $ }) {
19
+ const response = await this.slack.sdk().files.info({
26
20
  file: this.file,
27
- count: this.count,
28
21
  });
22
+ $.export("$summary", `Successfully retrieved file with ID ${this.file}`);
23
+ return response;
29
24
  },
30
25
  };
@@ -3,8 +3,8 @@ import slack from "../../slack.app.mjs";
3
3
  export default {
4
4
  key: "slack-invite-user-to-channel",
5
5
  name: "Invite User to Channel",
6
- description: "Invite a user to an existing channel. [See docs here](https://api.slack.com/methods/conversations.invite)",
7
- version: "0.0.15",
6
+ description: "Invite a user to an existing channel. [See the documentation](https://api.slack.com/methods/conversations.invite)",
7
+ version: "0.0.16",
8
8
  type: "action",
9
9
  props: {
10
10
  slack,
@@ -21,10 +21,12 @@ export default {
21
21
  ],
22
22
  },
23
23
  },
24
- async run() {
25
- return await this.slack.sdk().conversations.invite({
24
+ async run({ $ }) {
25
+ const response = await this.slack.sdk().conversations.invite({
26
26
  channel: this.conversation,
27
27
  users: this.user,
28
28
  });
29
+ $.export("$summary", `Successfully invited user ${this.user} to channel with ID ${this.conversation}`);
30
+ return response;
29
31
  },
30
32
  };
@@ -1,10 +1,11 @@
1
1
  import slack from "../../slack.app.mjs";
2
+ import constants from "../../common/constants.mjs";
2
3
 
3
4
  export default {
4
5
  key: "slack-kick-user",
5
6
  name: "Kick User",
6
- description: "Remove a user from a conversation. [See docs here](https://api.slack.com/methods/conversations.kick)",
7
- version: "0.0.15",
7
+ description: "Remove a user from a conversation. [See the documentation](https://api.slack.com/methods/conversations.kick)",
8
+ version: "0.0.16",
8
9
  type: "action",
9
10
  props: {
10
11
  slack,
@@ -12,19 +13,31 @@ export default {
12
13
  propDefinition: [
13
14
  slack,
14
15
  "conversation",
16
+ () => ({
17
+ types: [
18
+ constants.CHANNEL_TYPE.PUBLIC,
19
+ constants.CHANNEL_TYPE.PRIVATE,
20
+ constants.CHANNEL_TYPE.MPIM,
21
+ ],
22
+ }),
15
23
  ],
16
24
  },
17
25
  user: {
18
26
  propDefinition: [
19
27
  slack,
20
28
  "user",
29
+ (c) => ({
30
+ channelId: c.conversation,
31
+ }),
21
32
  ],
22
33
  },
23
34
  },
24
- async run() {
25
- return await this.slack.sdk().conversations.kick({
35
+ async run({ $ }) {
36
+ const response = await this.slack.sdk().conversations.kick({
26
37
  channel: this.conversation,
27
38
  user: this.user,
28
39
  });
40
+ $.export("$summary", `Successfully kicked user ${this.user} from channel with ID ${this.conversation}`);
41
+ return response;
29
42
  },
30
43
  };
@@ -3,13 +3,17 @@ import slack from "../../slack.app.mjs";
3
3
  export default {
4
4
  key: "slack-list-channels",
5
5
  name: "List Channels",
6
- description: "Return a list of all channels in a workspace. [See docs here](https://api.slack.com/methods/conversations.list)",
7
- version: "0.0.15",
6
+ description: "Return a list of all channels in a workspace. [See the documentation](https://api.slack.com/methods/conversations.list)",
7
+ version: "0.0.16",
8
8
  type: "action",
9
9
  props: {
10
10
  slack,
11
11
  },
12
- async run() {
13
- return await this.slack.sdk().conversations.list();
12
+ async run({ $ }) {
13
+ const response = await this.slack.sdk().conversations.list();
14
+ $.export("$summary", `Successfully found ${response.length} channel${response.length === 1
15
+ ? ""
16
+ : "s"}`);
17
+ return response;
14
18
  },
15
19
  };
@@ -3,8 +3,8 @@ import slack from "../../slack.app.mjs";
3
3
  export default {
4
4
  key: "slack-list-files",
5
5
  name: "List Files",
6
- description: "Return a list of files within a team. [See docs here](https://api.slack.com/methods/files.list)",
7
- version: "0.0.43",
6
+ description: "Return a list of files within a team. [See the documentation](https://api.slack.com/methods/files.list)",
7
+ version: "0.0.44",
8
8
  type: "action",
9
9
  props: {
10
10
  slack,
@@ -14,13 +14,6 @@ export default {
14
14
  "conversation",
15
15
  ],
16
16
  },
17
- count: {
18
- propDefinition: [
19
- slack,
20
- "count",
21
- ],
22
- optional: true,
23
- },
24
17
  team_id: {
25
18
  propDefinition: [
26
19
  slack,
@@ -36,12 +29,27 @@ export default {
36
29
  optional: true,
37
30
  },
38
31
  },
39
- async run() {
40
- return await this.slack.sdk().files.list({
32
+ async run({ $ }) {
33
+ const allFiles = [];
34
+ const params = {
41
35
  channel: this.conversation,
42
- count: this.count,
43
36
  user: this.user,
44
37
  team_id: this.team_id,
45
- });
38
+ page: 1,
39
+ };
40
+ let hasMore;
41
+
42
+ do {
43
+ const { files } = await this.slack.sdk().files.list(params);
44
+ allFiles.push(...files);
45
+ hasMore = files.length;
46
+ params.page++;
47
+ } while (hasMore);
48
+
49
+ $.export("$summary", `Successfully retrieved ${allFiles.length} file${allFiles.length === 1
50
+ ? ""
51
+ : "s"}`);
52
+
53
+ return allFiles;
46
54
  },
47
55
  };
@@ -1,10 +1,10 @@
1
1
  import slack from "../../slack.app.mjs";
2
2
 
3
3
  export default {
4
- key: "slack-list-user-groups-users",
5
- name: "List User Groups Users",
6
- description: "List all users in a User Group. [See docs here](https://api.slack.com/methods/usergroups.users.list)",
7
- version: "0.0.8",
4
+ key: "slack-list-group-members",
5
+ name: "List Group Members",
6
+ description: "List all users in a User Group. [See the documentation](https://api.slack.com/methods/usergroups.users.list)",
7
+ version: "0.0.1",
8
8
  type: "action",
9
9
  props: {
10
10
  slack,
@@ -23,14 +23,20 @@ export default {
23
23
  description: "Encoded team id where the user group exists, required if org token is used.",
24
24
  },
25
25
  },
26
- async run() {
26
+ async run({ $ }) {
27
27
  const {
28
28
  userGroup,
29
29
  team,
30
30
  } = this;
31
- return await this.slack.sdk().usergroups.users.list({
31
+ const response = await this.slack.sdk().usergroups.users.list({
32
32
  usergroup: userGroup,
33
33
  team_id: team,
34
34
  });
35
+ if (response.users?.length) {
36
+ $.export("$summary", `Successfully retrieved ${response.users.length} user${response.users.length === 1
37
+ ? ""
38
+ : "s"}`);
39
+ }
40
+ return response;
35
41
  },
36
42
  };
@@ -3,8 +3,8 @@ import slack from "../../slack.app.mjs";
3
3
  export default {
4
4
  key: "slack-list-members-in-channel",
5
5
  name: "List Members in Channel",
6
- description: "Retrieve members of a channel. [See docs here](https://api.slack.com/methods/conversations.members)",
7
- version: "0.0.15",
6
+ description: "Retrieve members of a channel. [See the documentation](https://api.slack.com/methods/conversations.members)",
7
+ version: "0.0.16",
8
8
  type: "action",
9
9
  props: {
10
10
  slack,
@@ -14,10 +14,28 @@ export default {
14
14
  "conversation",
15
15
  ],
16
16
  },
17
+ returnUsernames: {
18
+ type: "boolean",
19
+ label: "Return Usernames",
20
+ description: "Optionally, return usernames in addition to IDs",
21
+ optional: true,
22
+ },
17
23
  },
18
- async run() {
19
- return await this.slack.sdk().conversations.members({
24
+ async run({ $ }) {
25
+ const { members } = await this.slack.sdk().conversations.members({
20
26
  channel: this.conversation,
21
27
  });
28
+ let channelMembers = members;
29
+ if (this.returnUsernames) {
30
+ const usernames = await this.slack.userNames();
31
+ channelMembers = channelMembers?.map((id) => ({
32
+ id,
33
+ username: usernames[id],
34
+ })) || [];
35
+ }
36
+ $.export("$summary", `Successfully retrieved ${channelMembers.length} member${channelMembers.length === 1
37
+ ? ""
38
+ : "s"}`);
39
+ return channelMembers;
22
40
  },
23
41
  };