The discord services module has useful discord related functions.
These functions are helper, discord related functions.
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 |
# 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 |
# async inner deleteChannel(channel)
Delete the given channel if it is not deleted already
Parameters:
Name | Type | Description |
---|---|---|
channel |
TextChannel |
# 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 |
# 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 |
# 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 |
# 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 |
# 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 |
# 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? |
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 |
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 |
Promise.<Message>
# inner validateEmail(email) → {Boolean}
Validates an email using a reg exp.
Parameters:
Name | Type | Description |
---|---|---|
email |
String | the email to validate |
true if valid email, false otherwise
Boolean