|
|
@ -12,8 +12,9 @@ import Discord.Types |
|
|
|
import Discord.Interactions |
|
|
|
import qualified Discord.Requests as R |
|
|
|
import Commands |
|
|
|
import Discord.Internal.Rest.Guild (ModifyGuildOpts(modifyGuildOptsIcon)) |
|
|
|
import UnliftIO.Directory (renameDirectory) |
|
|
|
import qualified Data.ByteString as BS |
|
|
|
import qualified Data.Yaml as YAML |
|
|
|
import qualified Data.HashMap.Strict as Map |
|
|
|
|
|
|
|
testServer :: Snowflake |
|
|
|
testServer = 740862954454646814 |
|
|
@ -21,17 +22,19 @@ testServer = 740862954454646814 |
|
|
|
main :: IO () |
|
|
|
main = do |
|
|
|
tok <- TIO.readFile "./auth.secret" |
|
|
|
conf <- YAML.decodeFileThrow "./conf.yaml" :: IO YAML.Value |
|
|
|
putStrLn $ show conf |
|
|
|
err <- runDiscord $ def { discordToken = tok |
|
|
|
, discordOnStart = onDiscordStart |
|
|
|
, discordOnStart = onDiscordStart conf |
|
|
|
, discordOnEnd = liftIO $ putStrLn "Ended" |
|
|
|
, discordOnEvent = onDiscordEvent |
|
|
|
, discordOnEvent = onDiscordEvent conf |
|
|
|
, discordOnLog = |
|
|
|
\s -> TIO.putStrLn s >> TIO.putStrLn "" |
|
|
|
} |
|
|
|
TIO.putStrLn err |
|
|
|
|
|
|
|
onDiscordStart :: DiscordHandler () |
|
|
|
onDiscordStart = do |
|
|
|
onDiscordStart :: YAML.Value -> DiscordHandler () |
|
|
|
onDiscordStart conf = do |
|
|
|
let activity = Activity { activityName = "Doing stuff" |
|
|
|
, activityType = ActivityTypeGame |
|
|
|
, activityUrl = Nothing |
|
|
@ -44,8 +47,8 @@ onDiscordStart = do |
|
|
|
sendCommand (UpdateStatus opts) |
|
|
|
|
|
|
|
|
|
|
|
onDiscordEvent :: Event -> DiscordHandler () |
|
|
|
onDiscordEvent (Ready _ _ _ _ _ _ (PartialApplication i _)) = |
|
|
|
onDiscordEvent :: YAML.Value -> Event -> DiscordHandler () |
|
|
|
onDiscordEvent conf (Ready _ _ _ _ _ _ (PartialApplication i _)) = |
|
|
|
mapM_ (maybe ( return () ) |
|
|
|
( void |
|
|
|
. restCall |
|
|
@ -55,7 +58,8 @@ onDiscordEvent (Ready _ _ _ _ _ _ (PartialApplication i _)) = |
|
|
|
[ Just pingCommand |
|
|
|
, Just edtCommand |
|
|
|
] |
|
|
|
onDiscordEvent ( InteractionCreate InteractionApplicationCommand |
|
|
|
onDiscordEvent conf |
|
|
|
( InteractionCreate InteractionApplicationCommand |
|
|
|
{ interactionDataApplicationCommand = |
|
|
|
Just InteractionDataApplicationCommandChatInput |
|
|
|
{ interactionDataApplicationCommandName = name |
|
|
@ -70,6 +74,7 @@ onDiscordEvent ( InteractionCreate InteractionApplicationCommand |
|
|
|
where |
|
|
|
response = case name of |
|
|
|
"ping" -> pingResponse |
|
|
|
"edt" -> edtResponse opts |
|
|
|
_ -> interactionResponseBasic $ "Unhandled Command: " `T.append` name |
|
|
|
onDiscordEvent _ = return () |
|
|
|
onDiscordEvent _ _ = return () |
|
|
|
|