Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

Commit

Permalink
Also fix function passing for discord
Browse files Browse the repository at this point in the history
  • Loading branch information
J0B10 committed Jul 13, 2019
1 parent 70956ce commit 2b80cc3
Showing 1 changed file with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,18 @@ class DiscordChatInputImpl extends EventInputImpl[DiscordEvent, DiscordChatConne
private val privateMessages = ListBuffer[DiscordChatMessage]()
private var channelId: Option[String] = None

private val onMessageFn = onMessage _
private val onMessageUpdateFn = onMessageUpdate _
private val onMessageDeleteFn = onMessageDelete _
private val onReactionAddedFn = onReactionAdded _
private val onReactionRemovedFn = onReactionRemoved _

override def start(): Boolean = {
sourceConnector.get.addMessageReceivedListener(onMessage)
sourceConnector.get.addMessageUpdateListener(onMessageUpdate)
sourceConnector.get.addMessageDeleteListener(onMessageDelete)
sourceConnector.get.addReactionAddEventListener(onReactionAdded)
sourceConnector.get.addReactionDelEventListener(onReactionRemoved)
sourceConnector.get.addMessageReceivedListener(onMessageFn)
sourceConnector.get.addMessageUpdateListener(onMessageUpdateFn)
sourceConnector.get.addMessageDeleteListener(onMessageDeleteFn)
sourceConnector.get.addReactionAddEventListener(onReactionAddedFn)
sourceConnector.get.addReactionDelEventListener(onReactionRemovedFn)
true
}

Expand Down Expand Up @@ -82,11 +88,11 @@ class DiscordChatInputImpl extends EventInputImpl[DiscordEvent, DiscordChatConne
* @return true if stopping was successful
*/
override def stop(): Boolean = {
sourceConnector.get.removeMessageReceivedListener(onMessage)
sourceConnector.get.removeMessageUpdateListener(onMessageUpdate)
sourceConnector.get.removeMessageDeleteListener(onMessageDelete)
sourceConnector.get.removeReactionAddEventListener(onReactionAdded)
sourceConnector.get.removeReactionDelEventListener(onReactionRemoved)
sourceConnector.get.removeMessageReceivedListener(onMessageFn)
sourceConnector.get.removeMessageUpdateListener(onMessageUpdateFn)
sourceConnector.get.removeMessageDeleteListener(onMessageDeleteFn)
sourceConnector.get.removeReactionAddEventListener(onReactionAddedFn)
sourceConnector.get.removeReactionDelEventListener(onReactionRemovedFn)
true
}

Expand Down

0 comments on commit 2b80cc3

Please sign in to comment.