Closed ashkan18 closed 3 years ago
When listening on channel_joined event, the code crashes before even getting to the method on Slack.State when trying to access channel.members.
channel_joined
Slack.State
channel.members
20:49:31.040 [error] ** Websocket client Slack.Bot terminating in :websocket_handle/3 for the reason :error:{:badkey, :members,
Looking at what channel is at that point, there is no member attribute:
channel
member
%{ reated: 1605533620, creator: "***", id: "***", is_archived: false, is_channel: true, is_ext_shared: false, is_frozen: false, is_general: false, is_group: false, is_im: false, is_member: true, is_mpim: false, is_org_shared: false, is_pending_ext_shared: false, is_private: false, is_shared: false, last_read: "1605664021.022400", latest: %{subtype: "channel_leave", text: "<@"***"> has left the channel", ts: ""***",", type: "message", user: "***"}, name: "fikabot-support", name_normalized: "fikabot-support", parent_conversation: nil, pending_connected_team_ids: [], pending_shared: [], previous_names: [], priority: 0, purpose: %{creator: "***", last_set: 1605533621, value: "Join if you have questions about fikabot or you’d like to contribute"}, shared_team_ids: ["***"], topic: %{creator: "", last_set: 0, value: ""}, unlinked: 0, unread_count: 0, unread_count_display: 0 }
Ended up taking members out and also since this bot just joined the channel, added channel before setting is_member to true.
members
is_member
true
Problem
When listening on
channel_joined
event, the code crashes before even getting to the method onSlack.State
when trying to accesschannel.members
.Cause
Looking at what
channel
is at that point, there is nomember
attribute:Possible Solution
Ended up taking
members
out and also since this bot just joined the channel, addedchannel
before settingis_member
totrue
.