From 13dea1346b68f2825762c00bfce27ee9a9340a0c Mon Sep 17 00:00:00 2001 From: Ricardo Signes Date: Wed, 25 Oct 2023 19:48:52 -0400 Subject: [PATCH] SlackID: do not try to reload over not-slack --- lib/Synergy/Reactor/SlackID.pm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/Synergy/Reactor/SlackID.pm b/lib/Synergy/Reactor/SlackID.pm index e6a62b69..12a972d6 100644 --- a/lib/Synergy/Reactor/SlackID.pm +++ b/lib/Synergy/Reactor/SlackID.pm @@ -59,14 +59,20 @@ responder reload_slack => { } => async sub ($self, $event, $what) { $event->mark_handled; + my $channel = $event->from_channel; + + unless ($channel->can('slack')) { + return await $event->error_reply("Sorry, you can't use *slackid* outside Slack"); + } + if ($what eq 'users') { - $event->from_channel->slack->load_users; - $event->from_channel->slack->load_dm_channels; + $channel->slack->load_users; + $channel->slack->load_dm_channels; return $event->reply('Slack users reloaded'); } if ($what eq 'channels') { - $event->from_channel->slack->load_channels; + $channel->slack->load_channels; return $event->reply('Slack channels reloaded'); }