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