MessageMock

MessageMock

Class to provide mocks of discord.js messages for the test environment.

Constructor

new MessageMock()

Version:
  • 1.0
Author:
  • Makim Sandybekov
Source:

Methods

create() → {Object}

Create the final message mock and returns it.
Source:

setUser(id, name, discriminator) → {Object}

Setup a specific user for the message mock or use random values.
Parameters:
Name Type Description
id * The user id
name * The username
discriminator * The discriminator
Source:

setGuild(guildId, channelNames, channelCategory) → {Object}

Creates the guild property with objects in cache to iterate over. Should only be used on mock message sent from a guild channel. Both guildChanels and channelCategory needs to be filled to create channels in the guild cache. If different channel-name/category combinations are needed use the addChannel function.
Parameters:
Name Type Default Description
guildId *
channelNames Array.<string> null An array of channel names.
channelCategory string null The category under which the guild channels to put
Source:

addMember(callback, userId, name, discriminator) → {Object}

Add a guild member to all guild members
Parameters:
Name Type Default Description
callback function A callback function which gets called when the users send method is called
userId number The unique identifier of the user
name string Max Mustermann The name of the user
discriminator string 2342324 The user tag used by discord
Source:

addChannel(channelName, parentName, type) → {Object}

Adding a channel to the guild property cache.
Parameters:
Name Type Default Description
channelName string Name of the channel
parentName string Name of the parrent
type string text The channel type [category | text | ...] (Check discord.js docs for more info)
Source:

setChannel(name, categoryName) → {Object}

Set the current channel configuration.
Parameters:
Name Type Default Description
name string
categoryName string Default
Source:

setDirect() → {Object}

Set the type of message to direct message.
Source:

mockDirectMessage(userId, userName, discriminator) → {Object}

Instantly mocks a direct message to the bot from a specific user.
Parameters:
Name Type Default Description
userId * 234234 The unique user id
userName * Max Mustermann The user name
discriminator * 23423 The user discriminator used by discord (tag)
Source: