-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #143 from L0neGamer/minortweaks
Minor Tweaks for backend stuff
- Loading branch information
Showing
12 changed files
with
227 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module ExampleUtils where | ||
|
||
import qualified Data.Text as T | ||
import qualified Data.Text.IO as TIO | ||
import Discord | ||
import qualified Discord.Requests as R | ||
import Discord.Types | ||
import Text.Read (readMaybe) | ||
|
||
getToken :: IO T.Text | ||
getToken = TIO.readFile "./examples/auth-token.secret" | ||
|
||
getGuildId :: IO GuildId | ||
getGuildId = do | ||
gids <- readFile "./examples/guildid.secret" | ||
case readMaybe gids of | ||
Just g -> pure g | ||
Nothing -> error "could not read guild id from `guildid.secret`" | ||
|
||
-- | Given the test server and an action operating on a channel id, get the | ||
-- first text channel of that server and use the action on that channel. | ||
actionWithChannelId :: GuildId -> (ChannelId -> DiscordHandler a) -> DiscordHandler a | ||
actionWithChannelId testserverid f = do | ||
Right chans <- restCall $ R.GetGuildChannels testserverid | ||
(f . channelId) (head (filter isTextChannel chans)) | ||
where | ||
isTextChannel :: Channel -> Bool | ||
isTextChannel ChannelText {} = True | ||
isTextChannel _ = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.