Class: Moderation

Moderation


new Moderation()

Handle all moderator related commands and control.
Source:

Extends

Members


<private, constant> _banMsgs :Array.<string>

All of the possible messages to show when using the ban command.
Type:
  • Array.<string>
Source:

<private> _disabledAutoSmite :object.<boolean>

All guilds that have disabled the auto-smite feature. Not actually used at this time.
Type:
  • object.<boolean>
Source:

<private> _disabledBanMessage :object.<boolean>

All guilds that have disabled sending messages when someone is banned. Not actually used at this time.
Type:
  • object.<boolean>
Source:

<private> _mentionAccumulator :object.<object.<string>>

The guilds with auto-smite enabled, and members who have mentioned "@everyone", and the timestamps of these mentions. Not actually used at this time.
Type:
  • object.<object.<string>>
Source:

<private> _settingsUpdated :object.<boolean>

All guilds that have changed their settings since last save.
Type:
  • object.<boolean>
Source:

<private, constant> _smitePerms :number

Permissions for the new Smited role. Bitfield.
Type:
  • number
Source:

<constant> AuditLogActions

From Discord~AuditLogAction.
Default Value:
  • {"ALL":null,"GUILD_UPDATE":1,"CHANNEL_CREATE":10,"CHANNEL_UPDATE":11,"CHANNEL_DELETE":12,"CHANNEL_OVERWRITE_CREATE":13,"CHANNEL_OVERWRITE_UPDATE":14,"CHANNEL_OVERWRITE_DELETE":15,"MEMBER_KICK":20,"MEMBER_PRUNE":21,"MEMBER_BAN_ADD":22,"MEMBER_BAN_REMOVE":23,"MEMBER_UPDATE":24,"MEMBER_ROLE_UPDATE":25,"MEMBER_MOVE":26,"MEMBER_DISCONNECT":27,"BOT_ADD":28,"ROLE_CREATE":30,"ROLE_UPDATE":31,"ROLE_DELETE":32,"INVITE_CREATE":40,"INVITE_UPDATE":41,"INVITE_DELETE":42,"WEBHOOK_CREATE":50,"WEBHOOK_UPDATE":51,"WEBHOOK_DELETE":52,"EMOJI_CREATE":60,"EMOJI_UPDATE":61,"EMOJI_DELETE":62,"MESSAGE_DELETE":72,"MESSAGE_BULK_DELETE":73,"MESSAGE_PIN":74,"MESSAGE_UNPIN":75,"INTEGRATION_CREATE":80,"INTEGRATION_UPDATE":81,"INTEGRATION_DELETE":82}
Source:
See:

<nullable> bot :SpikeyBot

The parent SpikeyBot instance. Defaults to required cache value for autocompletion, updates to current reference at init.
Type:
Inherited From:
Overrides:
Source:

client :Discord~Client

The current bot client. Defaults to require cache value for editor autocompletion, updates to current reference at init.
Type:
  • Discord~Client
Inherited From:
Overrides:
Source:

command :Command

The command object for registering command listeners. Defaults to require cache value for editor autocompletion, updates to current reference at init.
Type:
Inherited From:
Overrides:
Source:

<constant> commit :string

The commit at HEAD at the time this module was loaded. Essentially the version of this submodule.
Type:
  • string
Inherited From:
Overrides:
Source:

common :Common

The common object. Defaults to require cache value for editor autocompletion, updates to current reference at init.
Type:
Inherited From:
Overrides:
Source:

Discord :Discord

The current Discord object instance of the bot. Defaults to require cache value for editor autocompletion, updates to current reference at init.
Type:
  • Discord
Inherited From:
Overrides:
Source:

<abstract> helpMessage :undefined|string|Discord~MessageEmbed

The help message to show the user in the main help message.
Type:
  • undefined | string | Discord~MessageEmbed
Inherited From:
Overrides:
Source:

<protected, readonly> initialized :boolean

Has this subModule been initialized yet (Has begin() been called).
Type:
  • boolean
Inherited From:
Overrides:
Source:

<constant> loadTime :number

The time at which this module was loaded for use in checking if the module needs to be reloaded because the file has been modified since loading.
Type:
  • number
Inherited From:
Overrides:
Source:

<protected> myName :string

The name of this submodule. Used for differentiating in the log. Should be defined before begin().
Type:
  • string
Inherited From:
Overrides:
Source:

<abstract> postPrefix :string

The postfix for the global prefix for this subModule. Must be defined before begin(), otherwise it is ignored.
Type:
  • string
Inherited From:
Overrides:
Source:

Methods


<private> _commandKick(msg)

Kick a mentioed user (or role from ID) and send a message saying they were banned.
Parameters:
Name Type Description
msg Discord~Message Message that triggered command.
Source:
Listens to Events:
  • Command#event:kick

<private> _commandSmite(msg)

Remove all roles from a user and give them a role that prevents them from doing anything. Checks if all parties involved have permission to do this without the bot's help.
This:
Parameters:
Name Type Description
msg Discord~Message Message that triggered command.
Source:
Listens to Events:
  • Command#event:smite

<private> _finalMessageDeleteSend(guild, bot, tag, id, mId, channel, files, content, logs)

Sends message delete to ModLog.
Parameters:
Name Type Argument Description
guild Discord~Guild Guild context.
bot boolean Is the message sent by a bot.
tag string User tag of deleted message.
id string User ID of deleted message.
mId string Message ID of deleted message.
channel string Name of channel of deleted message.
files Array.<string> Array of URLs to deleted files.
content string Message content of deleted message.
logs Discord~GuildAuditLogs <nullable>
Audit logs for more info.
Source:

<private> _formatDelay(msecs)

Format a duration in milliseconds into a human readable string.
Parameters:
Name Type Description
msecs number Duration in milliseconds.
Source:
Returns:
Formatted string.
Type
string

<private> _onGuildMemberAdd(member)

Handle someone joining the guild.
Parameters:
Name Type Description
member Discord~GuildMember The member that joined.
Source:

<private> _onGuildMemberRemove(member)

Handle a guild member leaving the guild.
Parameters:
Name Type Description
member Discord~GuildMember The member that left or was kicked.
Source:

<private> _onMessageDelete(msg)

Handle logging when a message is deleted.
Parameters:
Name Type Description
msg Discord~Message The deleted message.
Source:

<private> _onMessageDeleteBulk(msgs)

Handle logging when multiple messages are deleted.
Parameters:
Name Type Description
msgs Discord~Collection.<Discord~Message> The deleted messages.
Source:

<private> _onMessageUpdate(prev, msg)

Handle logging when a message is edited.
Parameters:
Name Type Description
prev Discord~Message The previous message.
msg Discord~Message The new message.
Source:

<private> _smite(role, member, msg)

Perform the actual smiting of a member.
Parameters:
Name Type Description
role Discord~Role The role to give to the member.
member Discord~GulidMember The member to smite.
msg Discord~Message The message that triggered the smiting.
Source:

begin(Discord, client, command, common, bot)

Initialize this submodule.
Parameters:
Name Type Description
Discord Discord The Discord object for the API library.
client Discord~Client The client that represents this bot.
command Command The command instance in which to register command listeners.
common Common Class storing common functions.
bot SpikeyBot The parent SpikeyBot instance.
Inherited From:
Overrides:
Source:

<protected> debug(msg)

Log using common.logDebug, but automatically set name.
Parameters:
Name Type Description
msg string The message to log.
Inherited From:
Overrides:
Source:

end()

Trigger subModule to shutdown and get ready for process terminating.
Inherited From:
Overrides:
Source:

<protected> error(msg)

Log using common.error, but automatically set name.
Parameters:
Name Type Description
msg string The message to log.
Inherited From:
Overrides:
Source:

<protected> initialize()

The function called at the end of begin() for further initialization specific to the subModule. Must be defined before begin() is called.
Inherited From:
Overrides:
Source:

<protected> log(msg)

Log using common.log, but automatically set name.
Parameters:
Name Type Description
msg string The message to log.
Inherited From:
Overrides:
Source:

muteMember(member, cb)

Give a guild member a muted role that prevents them from talking in any channel in the guild.
Parameters:
Name Type Description
member Discord~GuildMember The member of the guild to mute.
cb function Callback function with a single argument which is a string if there was an error, or null if success.
Source:

<abstract> reloadable()

Check if this module is in a state that is ready to be reloaded. If false is returned, this module should not be unloaded and doing such may risk putting the module into an uncontrollable state. This is different from unloadable, which checks if this module can be stopped completely, this checks if the module can be stopped and restarted.
Inherited From:
Overrides:
Source:
See:
  • SubModule~unloadable
Returns:
True if can be reloaded, false if cannot.
Type
boolean

save( [opt])

Saves all data to files necessary for saving current state.
Parameters:
Name Type Argument Default Description
opt string <optional>
'sync' Can be 'async', otherwise defaults to synchronous.
Inherited From:
Overrides:
Source:

<protected> shutdown()

Shutdown and disable this submodule. Removes all event listeners.
Inherited From:
Overrides:
Source:

<abstract> unloadable()

Check if this module is in a state that is ready to be unloaded. If false is returned, this module should not be unloaded and doing such may risk putting the module into an uncontrollable state.
Inherited From:
Overrides:
Source:
See:
  • SubModule~reloadable
Returns:
True if can be unloaded, false if cannot.
Type
boolean

<protected> warn(msg)

Log using common.logWarning, but automatically set name.
Parameters:
Name Type Description
msg string The message to log.
Inherited From:
Overrides:
Source: