calamity-0.1.28.4: A library for writing discord bots in haskell
Safe HaskellNone
LanguageHaskell2010

Calamity.Commands.Check

Description

Command invokation preconditions

Synopsis

Documentation

data Check Source #

A check for a command.

Every check for a command must return Nothing for the command to be run.

Constructors

MkCheck 

Fields

  • name :: Text

    The name of the check.

  • callback :: Context -> IO (Maybe Text)

    The callback for the check, returns Nothing if it passes, otherwise returns the reason for it not passing.

Instances

Instances details
Generic Check Source # 
Instance details

Defined in Calamity.Commands.Check

Associated Types

type Rep Check :: Type -> Type #

Methods

from :: Check -> Rep Check x #

to :: Rep Check x -> Check #

type Rep Check Source # 
Instance details

Defined in Calamity.Commands.Check

type Rep Check = D1 ('MetaData "Check" "Calamity.Commands.Check" "calamity-0.1.28.4-FqOhVhDjHpX2rPyeyr2m7C" 'False) (C1 ('MetaCons "MkCheck" 'PrefixI 'True) (S1 ('MetaSel ('Just "name") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Just "callback") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Context -> IO (Maybe Text)))))

buildCheck :: Member (Final IO) r => Text -> (Context -> Sem r (Maybe Text)) -> Sem r Check Source #

Given the name of a check and a callback in the Sem monad, build a check by transforming the Polysemy action into an IO action.

buildCheckPure :: Text -> (Context -> Maybe Text) -> Check Source #

Given the name of a check and a pure callback function, build a check.

runCheck :: Member (Embed IO) r => Context -> Check -> Sem r (Either CommandError ()) Source #

Given an invokation Context, run a check and transform the result into an Either CommandError ().