owenbot-0.1.0.0
Safe HaskellNone
LanguageHaskell2010

Utils

Description

 
Synopsis

Documentation

emojiToUsableText :: Emoji -> Text Source #

emojiToUsableText converts a given emoji to a text which can be used to display it in Discord.

sendMessageChan :: MonadDiscord m => ChannelId -> Text -> m () Source #

sendMessageChan attempts to send the given Text in the channel with the given channelID. Surpesses any error message(s), returning ().

sendReply :: MonadDiscord m => Message -> Bool -> Text -> m () Source #

sendReply attempts to send a reply to the given Message. Suppresses any error message(s), returning ().

sendMessageChanEmbed :: MonadDiscord m => ChannelId -> Text -> CreateEmbed -> m () Source #

sendMessageChanEmbed attempts to send the given embed with the given Text in the channel with the given channelID. Surpesses any error message(s), returning ().

sendMessageChanPingsDisabled :: MonadDiscord m => ChannelId -> Text -> m () Source #

sendMessageChanPingsDisabled acts in the same way as sendMessageChan, but disables all pings (everyone, user, @role) pings from the message.

sendMessageDM :: MonadDiscord m => UserId -> Text -> m () Source #

sendMessageDM attempts to send the given Text as a direct message to the user with the given UserId. Surpresses any error message(s), returning ().

sendFileChan :: (MonadDiscord m, MonadIO m) => ChannelId -> Text -> FilePath -> m () Source #

sendFileChan attempts to send the file at the provided FilePath in the channel with the provided ChannelId. The file attachment is annotated by the given Text.

sendAssetChan :: (MonadDiscord m, MonadIO m) => ChannelId -> Text -> FilePath -> m () Source #

sendAssetChan is simply a wrapper for sendFileChan that perpends the data storage dir to the provided file path.

addReaction :: ChannelId -> MessageId -> Text -> DiscordHandler () Source #

addReaction attempts to add a reaction to the given message ID. Supresses any error message(s), returning ().

messageFromReaction :: MonadDiscord m => ReactionInfo -> m Message Source #

messageFromReaction attempts to get the Message instance from a reaction.

pingUser :: User -> Text Source #

pingUser constructs a minimal Text pinging the given user.

pingRole :: RoleId -> Text Source #

pingRole constructs a minimal Text pinging the given role id.

pingAuthorOf :: Message -> Text Source #

pingAuthorOf constructs a minimal Text pinging the author of a given message.

pingWithUsername :: Text -> GuildId -> DiscordHandler Text Source #

pingWithUsername constructs a minimal Text pinging the the user with the given username from the given guild. On failure, returns an empty Text. On multiple such users, returns an empty Text.

stripAllPings :: Text -> Text Source #

stripAllPings removes all pings from a given Text message.

newCommand Source #

Arguments

:: Message

a message that needs to be handled

-> Text

the new command regex

-> ([Text] -> DiscordHandler ())

a function used to handle each message portion captured by the command regex

-> DiscordHandler ()

the over-all result of handling the message

newCommand should be used in the creation of a new Owen command. Given a Text command regex (lacking the : prefix and the trailing whitespace), along with a function that can handle the regex captures, the command can be used to create `Message -> DiscordHandler ()` message receivers.

newDevCommand :: Message -> Text -> ([Text] -> DiscordHandler ()) -> DiscordHandler () Source #

newDevCommand should be used in the creation of a new Owen dev command. Acts in the same way as newCommand, with the distinction that it constructs handlers that require the message author to be a developer. If they are not, the message author is messaged directly and reprimanded so harshly that they will never attempt to use a dev command ever again.

newModCommand :: Message -> Text -> ([Text] -> DiscordHandler ()) -> DiscordHandler () Source #

Similar to newDev command, however looks up the Moderator role name instead of using ID to determine the message authors role.

linkChannel :: ChannelId -> Text Source #

linkChannel constructs a minimal Text linking the channel with the provided ID.

getMessageLink :: Message -> DiscordHandler Text Source #

getMessageLink attempts to construct the Discord URL of the given message, as a Text.

hasRoleByName :: MonadDiscord m => Message -> Text -> m Bool Source #

hasRoleByName checks whether the provided message was sent by a user that has a role matching the provided Text exactly.

hasRoleByID :: MonadDiscord m => Message -> RoleId -> m Bool Source #

hasRoleByID checks whether the provided message was sent by a user that has a role matching the provided RoleId.

channelRequirement :: MonadDiscord m => String -> Message -> m (Maybe Text) Source #

channelRequirement is a requirement for a Command to be in a certain channel.

roleNameRequirement :: MonadDiscord m => [Text] -> Message -> m (Maybe Text) Source #

Command requirement for role names, matched with OR. For and, just compose multiple of this.

developerRequirement :: (MonadDiscord m, MonadIO m) => Message -> m (Maybe Text) Source #

Command requirement for sender being a registered developer.

isMod :: Message -> DiscordHandler Bool Source #

isMod checks whether the provided message was sent by a user with the Moderator role.

devIDs :: FilePath Source #

The FilePath to the configuration file listing OwenDev role IDs.

assetDir :: IO FilePath Source #

The FilePath representing the location of the assets. TODO: Move into a saner place than Utils

(=~=) :: Text -> Text -> Bool Source #

The (=~=) function matches a given Text again a regex. Case-less in terms of owoifying.

getTimestampFromMessage :: Message -> Text Source #

getTimestampFromMessages returns the given message's timestamp as Text, in the format `yyyy-mm-dd | hh:mm:ss`.

captureCommandOutput :: String -> IO Text Source #

captureCommandOutput creates a new process from the desired command provided as a String. Then, it waits for the command to finish executing, returning its output as a Text.

update :: IO Bool Source #

update calls a shell script that updates the bot's repo

snowflakeToInt :: Snowflake -> Integer Source #

Converts Discord-Haskells Snowflake type to an integer

moveChannel :: GuildId -> ChannelId -> Int -> DiscordHandler () Source #

Moves channel position in guild

isEmojiValid :: Text -> GuildId -> DiscordHandler Bool Source #

isEmojiValid determines whether an emoji (provided in Discord ::0-9 format) exists in the guild (or is a default emoji). Case insensitive.

isRoleInGuild :: MonadDiscord m => Text -> GuildId -> m (Maybe RoleId) Source #

isRoleInGuild determines whether a role containing the given text exists in the guild (case insensitive). If it does, then it returns the role's ID. Otherwise, Nothing is returned.