|
@ -2,7 +2,7 @@ |
|
|
|
|
|
|
|
|
module Main where |
|
|
module Main where |
|
|
|
|
|
|
|
|
import Control.Monad |
|
|
|
|
|
|
|
|
import Control.Monad (when, void) |
|
|
|
|
|
|
|
|
import qualified Data.Text as T |
|
|
import qualified Data.Text as T |
|
|
import qualified Data.Text.IO as TIO |
|
|
import qualified Data.Text.IO as TIO |
|
@ -13,8 +13,8 @@ import Discord |
|
|
import Discord.Types |
|
|
import Discord.Types |
|
|
import qualified Discord.Requests as R |
|
|
import qualified Discord.Requests as R |
|
|
|
|
|
|
|
|
cmdPrefix :: T.Text |
|
|
|
|
|
cmdPrefix = "%" |
|
|
|
|
|
|
|
|
import Commands |
|
|
|
|
|
import Discord.Internal.Rest (Activity(Activity)) |
|
|
|
|
|
|
|
|
main :: IO () |
|
|
main :: IO () |
|
|
main = do |
|
|
main = do |
|
@ -29,22 +29,12 @@ main = do |
|
|
TIO.putStrLn err |
|
|
TIO.putStrLn err |
|
|
|
|
|
|
|
|
onDiscordStart :: DiscordHandler () |
|
|
onDiscordStart :: DiscordHandler () |
|
|
onDiscordStart = undefined |
|
|
|
|
|
|
|
|
onDiscordStart = do |
|
|
|
|
|
let activity = |
|
|
|
|
|
Activity |
|
|
|
|
|
{ |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
onDiscordEvent :: Event -> DiscordHandler () |
|
|
onDiscordEvent :: Event -> DiscordHandler () |
|
|
onDiscordEvent (MessageCreate m) = when (not (fromBot m) && isCommand m) $ do |
|
|
|
|
|
let content = messageContent m |
|
|
|
|
|
let elements = T.words content |
|
|
|
|
|
case head elements of |
|
|
|
|
|
_ -> unknownCommand m elements |
|
|
|
|
|
return () |
|
|
|
|
|
onDiscordEvent _ = return () |
|
|
onDiscordEvent _ = return () |
|
|
|
|
|
|
|
|
fromBot :: Message -> Bool |
|
|
|
|
|
fromBot = userIsBot . messageAuthor |
|
|
|
|
|
|
|
|
|
|
|
unknownCommand :: Message -> [Text] -> DiscordHandler () |
|
|
|
|
|
unknownCommand = |
|
|
|
|
|
|
|
|
|
|
|
isCommand :: Message ->Bool |
|
|
|
|
|
isCommand = (cmdPrefix `T.isPrefixOf`) . messageContent |
|
|
|