git.iko.soy/rowtype-yoga/royo
on main help sign in
Only run messageUpdateHandler on code evaluations
commitf4722ce4da02879aa932be8d9baee2099c834639 authorPureFunctor <purefunctor@gmail.com> dateThu 29 Jul 2021, 00:01 (5 years ago) parent172fd4c
2 files changed+7−6
src/Discord/DiscordJS.purs+1 src/Royo/Discord/Bot.purs+6−6
src/Discord/DiscordJS.purs+1
@@ -40,6 +40,7 @@ type Message =
4040 { channel ∷ Channel
4141 , content ∷ String {- not really... -}
4242 , author ∷ User
43+ , id ∷ String {- Snowflake ~ String -}
4344 }
4445
4546foreign import removeAllReactionsImpl ∷ Message -> Effect (Promise Unit)
src/Royo/Discord/Bot.purs+6−6
@@ -12,7 +12,7 @@ import Data.String (Pattern(..), contains, drop, length, stripPrefix, stripSuffi
1212import Data.String.NonEmpty.Internal (NonEmptyString(..))
1313import Data.String.NonEmpty.Internal as NES
1414import Data.String.Utils (startsWith)
15−import Discord.DiscordJS (ChannelType(..), DiscordToken, Message, createDMChannel, getChannelType, login, newClient, onMessage, onMessageUpdate, react, removeAllReactions, sendString)
15+import Discord.DiscordJS (DiscordToken, Message, createDMChannel, login, newClient, onMessage, onMessageUpdate, react, sendString)
1616import Effect.Aff (Aff, attempt, launchAff_, message)
1717import Effect.Class (liftEffect)
1818import Effect.Class.Console (log)
@@ -45,9 +45,9 @@ runBot yogaToken discordToken = do
4545 client # onMessageUpdate (launchAff_ `map map map` messageUpdatedHandler) # liftEffect
4646 where
4747 messageUpdatedHandler _ msg = printErrors msg do
48− when (getChannelType msg.channel == TextChannel) $ removeAllReactions msg
49− msg # react rewindEmoji
50− messageHandler msg
48+ when (isMention msg.content) do
49+ msg # react rewindEmoji
50+ messageHandler msg
5151
5252 messageHandler msg@{ content, channel } = printErrors msg do
5353 when (isMention content) do
@@ -59,10 +59,10 @@ runBot yogaToken discordToken = do
5959 case res of
6060 Left cr -> sendCompileProblem msg code cr
6161 Right rr -> case NES.fromString rr.stdout, NES.fromString rr.stderr of
62− Just stdout, _ -> do
62+ Just _, _ -> do
6363 msg # react robotMuscleEmoji
6464 channel # sendString (NonEmptyString (prepareOutput rr.stdout))
65− Nothing, Just stderr -> do
65+ Nothing, Just _ -> do
6666 msg # react sirenEmoji
6767 sendRunProblem msg code rr.stderr
6868 _, _ -> channel # sendString (NonEmptyString "Something is weird")