{-# LANGUAGE TemplateHaskell #-}

-- | Discord tokens
module Calamity.Types.Token (
  Token (..),
  formatToken,
  rawToken,
) where

import Data.Text (Text)
import Optics.TH
import TextShow.TH (deriveTextShow)

data Token
  = BotToken Text
  | UserToken Text
  deriving (Int -> Token -> ShowS
[Token] -> ShowS
Token -> String
(Int -> Token -> ShowS)
-> (Token -> String) -> ([Token] -> ShowS) -> Show Token
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Token -> ShowS
showsPrec :: Int -> Token -> ShowS
$cshow :: Token -> String
show :: Token -> String
$cshowList :: [Token] -> ShowS
showList :: [Token] -> ShowS
Show)

formatToken :: Token -> Text
formatToken :: Token -> Text
formatToken (BotToken Text
t) = Text
"Bot " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
t
formatToken (UserToken Text
t) = Text
t

rawToken :: Token -> Text
rawToken :: Token -> Text
rawToken (BotToken Text
t) = Text
t
rawToken (UserToken Text
t) = Text
t

$(deriveTextShow ''Token)
$(makeFieldLabelsNoPrefix ''Token)