Module

DiscordServices

The discord services module has useful discord related functions. These functions are helper, discord related functions.

View Source discord-services.js, line 5

Methods

# inner addRoleToMember(member, addRole)

Add a role to a member
Parameters:
Name Type Description
member GuildMember the guild member to give a role to
addRole RoleResolvable the role to add to the member

View Source discord-services.js, line 120

# inner checkForRole(member, role)

Checks if the member has a role, returns true if it does
Parameters:
Name Type Description
member GuildMember member to check role
role String role ID to check for

View Source discord-services.js, line 16

# async inner deleteChannel(channel)

Delete the given channel if it is not deleted already
Parameters:
Name Type Description
channel TextChannel

View Source discord-services.js, line 218

# async inner deleteMessage(message, timeout)

Deletes a message if the message hasn't been deleted already
Parameters:
Name Type Default Description
message Message the message to delete
timeout Number 0 the time to wait in milliseconds

View Source discord-services.js, line 201

# async inner discordLog(guild, message)

Log a message on the log channel
Parameters:
Name Type Description
guild Guild the guild being used
message String | MessageEmbed message to send to the log channel

View Source discord-services.js, line 173

# inner randomColor() → {String}

Returns a random color as a hex string.

View Source discord-services.js, line 232

- hex color
String

# inner removeRolToMember(member, removeRole)

Remove a role to a member
Parameters:
Name Type Description
member GuildMember the guild member to give a role to
removeRole RoleResolvable the role to add to the member

View Source discord-services.js, line 141

# inner replaceRoleToMember(member, removeRole, addRole)

Replaces one role for the other
Parameters:
Name Type Description
member GuildMember member to change roles to
removeRole RoleResolvable role to remove
addRole RoleResolvable role to add

View Source discord-services.js, line 161

# async inner replyAndDelete(message, reply)

Reply to message and delete 5 seconds later
Parameters:
Name Type Description
message Message the message to reply to
reply String the string to reply

View Source discord-services.js, line 188

# async inner sendEmbedToMember(member, embedOptions, isDelete) → {Promise.<Message>}

Sends an embed to a user via DM. Title and description are required, color and fields are optional.
Parameters:
Name Type Default Description
member User | GuildMember member to send embed to
embedOptions EmbedOptions embed information
isDelete Boolean false should the message be deleted after some time?

View Source discord-services.js, line 98

Promise.<Message>

# async inner sendMessageToMember(member, message, isDelete) → {Promise.<Message>}

Send a Direct message to a member, option to delete after a few seconds. Helps user fix DM issue if the bot can't reach them over DM.
Parameters:
Name Type Default Description
member User | GuildMember the user or member to send a DM to
message String | MessageEmbed the message to send
isDelete Boolean false weather to delete message after 60 seconds

View Source discord-services.js, line 49

Promise.<Message>

# async inner sendMsgToChannel(channel, userId, message, timeout) → {Promise.<Message>}

Will send a message to a text channel and ping the user, can be deleted after a timeout.
Parameters:
Name Type Default Description
channel TextChannel the channel to send the message to
userId String the user to tag on the message
message String the message to send
timeout Number 0 timeout before delete if any, in seconds

View Source discord-services.js, line 31

Promise.<Message>

# inner validateEmail(email) → {Boolean}

Validates an email using a reg exp.
Parameters:
Name Type Description
email String the email to validate

View Source discord-services.js, line 243

true if valid email, false otherwise
Boolean

Type Definitions

# EmbedOptions

Properties:
Name Type Description
title String embed title
description String embed description
color String embed color
fields Array.<FieldInfo> embed fields

View Source discord-services.js, line 82

# FieldInfo

Properties:
Name Type Description
title String field title
description String field description

View Source discord-services.js, line 76