tiltmesenpai / discord.hs Goto Github PK
View Code? Open in Web Editor NEWHave you heard of our lord and savior Haskell?
License: MIT License
Have you heard of our lord and savior Haskell?
License: MIT License
As per the title, the version on Hackage appears to not match the version on the default branch, which makes using this library confusing.
I want to write a one-time fetcher which runs gets of one's OAuth user and then quits. Is this library appropriate, or is it just bots?
If so, will I have to run a bot for a keepalive and then quit it with a close command, or can I just run a one-off command?
Ta!
I’m working on a fork of this library called discord-haskell. I’ve changed the core of the library to use Chan
s instead of a monad transformer stack. Opening an issue is my best method of direct communication.
It’s in limbo between a fork and a entirely separate project. I’m using the types from discord-types
and discord-rest
and discord-gateway
as starting points for my fork. I have rewritten discord-rest/Rest.hs
and discord-gateway/Gateway.hs
.
I started my own project instead of making pull requests because I reformatted all the code and then introduced massive breaking changes to the gateway and rest files. From the user perspective this is an entirely different library.
Feel free to open issues/pull requests on my fork with any suggestions.
I was asked by Jamieλ on discord to open a issue about this
Hey,
I just deployed my bot using discord-hs and it seemed to work perfectly fine. However, after about 3 hours, the bot disconnected and kept spamming BotDied
in console many times a second.
It took me quite a while to notice, so this inflated our log files quite a bit.
What exactly happened here and how can I prevent this? (Not just the log file inflation, but also to keep it online. After restarting, it seemed to reconnect just fine)
The following steps need to be taken:
Please add a Setup.hs
file to the distribution to make sure that build systems that don't rely on cabal-install
or stack
can compile this package.
And so is the current master:
https://hackage.haskell.org/package/discord-hs-0.3.2/src/src/Network/Discord/Rest/Prelude.hs
Fetched
has kind *
, and, AFAIK, can't be a Functor or a Comonad.
current build-depends:
build-depends: base==4.*
, aeson>=1.0 && <1.2
, bytestring==0.10.*
, case-insensitive==1.2.*
, comonad==5.*
, containers==0.5.*
, data-default==0.7.*
, hashable==1.2.*
, hslogger==1.2.*
, http-client==0.5.*
, mmorph==1.0.*
, mtl==2.2.*
, pipes==4.3.*
, stm-conduit==3.0.*
, stm==2.4.*
, text==1.2.*
, time>=1.6 && <1.9
, transformers==0.5.*
, unordered-containers==0.2.*
, url==2.1.*
, vector>=0.10 && <0.13
, websockets==0.10.*
, req==0.2.*
, wuss==1.1.*
Could you update req==0.2.*
to req==0.4.*
?
The documentation of Network.Discord.Rest
makes it seem like there is a much better way to make requests than just using fetch
and fetch'
. However, all examples currently use fetch'
.
Could you make at least one example showing how to use Network.Discord.Rest.Channel
and similar?
The documentation is also outdated by a couple versions.
Using this as compared to the example in the README.md file I still get some errors.
{-# LANGUAGE OverloadedStrings, RecordWildCards #-}
import Data.Text
import Pipes
-- import Language.Discord -- Not included with the package anymore.
import Network.Discord
reply :: Message -> Text -> Effect DiscordM ()
reply Message{messageChannel=chan} cont = fetch' $ CreateMessage chan cont
main :: IO ()
main = runBot "TOKEN" $ do
with ReadyEvent $ \(Init v u _ _ _) ->
liftIO . putStrLn $ "Connected to gateway v" ++ show v ++ " as user " ++ show u
with MessageCreateEvent $ \msg@Message{..} -> do
when ("Ping" `isPrefixOf` messageContent && (not . userIsBot $ messageAuthor)) $
reply msg "Pong!"
and the error
tak@moon ~/dev/projects/sodimm/dimmy % sb :(
dimmy-0.1.0: build (exe)
Preprocessing executable 'dimmy' for dimmy-0.1.0...
[1 of 1] Compiling Main ( Dimmy.lhs, .stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/dimmy/dimmy-tmp/Main.o )
/home/tak/dev/projects/sodimm/dimmy/Dimmy.lhs:9:45: error:
• No instance for (DoFetch (Maybe Embed -> ChannelRequest Message))
arising from a use of ‘fetch'’
(maybe you haven't applied a function to enough arguments?)
• In the expression: fetch' $ CreateMessage chan cont
In an equation for ‘reply’:
reply (Message {messageChannel = chan}) cont
= fetch' $ CreateMessage chan cont
/home/tak/dev/projects/sodimm/dimmy/Dimmy.lhs:12:17: error:
• No instance for (Data.String.IsString Auth)
arising from the literal ‘"TOKEN"’
• In the first argument of ‘runBot’, namely ‘"TOKEN"’
In the expression: runBot "TOKEN"
In the expression:
runBot "TOKEN"
$ do { with ReadyEvent
$ \ (Init v u _ _ _)
-> liftIO . putStrLn
$ "Connected to gateway v" ++ show v ++ " as user " ++ show u;
with MessageCreateEvent $ \ msg@(Message {..}) -> do { ... } }
-- While building package dimmy-0.1.0 using:
/home/tak/.stack/setup-exe-cache/x86_64-linux/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-linux/Cabal-1.24.2.0 build exe:dimmy --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
I'll play around with it and submit a PR if I figure it out, but it may just be a simple fix.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.