-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Aura Román <kyradiscord@gmail.com>
- Loading branch information
Showing
22 changed files
with
1,201 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'use strict'; | ||
|
||
const Action = require('./Action'); | ||
const AutoModerationActionExecution = require('../../structures/AutoModerationActionExecution'); | ||
const { Events } = require('../../util/Constants'); | ||
|
||
class AutoModerationActionExecutionAction extends Action { | ||
handle(data) { | ||
const { client } = this; | ||
const guild = client.guilds.cache.get(data.guild_id); | ||
|
||
if (guild) { | ||
/** | ||
* Emitted whenever an auto moderation rule is triggered. | ||
* <info>This event requires the {@link Permissions.FLAGS.MANAGE_GUILD} permission.</info> | ||
* @event Client#autoModerationActionExecution | ||
* @param {AutoModerationActionExecution} autoModerationActionExecution The data of the execution | ||
*/ | ||
client.emit(Events.AUTO_MODERATION_ACTION_EXECUTION, new AutoModerationActionExecution(data, guild)); | ||
} | ||
|
||
return {}; | ||
} | ||
} | ||
|
||
module.exports = AutoModerationActionExecutionAction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use strict'; | ||
|
||
const Action = require('./Action'); | ||
const { Events } = require('../../util/Constants'); | ||
|
||
class AutoModerationRuleCreateAction extends Action { | ||
handle(data) { | ||
const { client } = this; | ||
const guild = client.guilds.cache.get(data.guild_id); | ||
|
||
if (guild) { | ||
const autoModerationRule = guild.autoModerationRules._add(data); | ||
|
||
/** | ||
* Emitted whenever an auto moderation rule is created. | ||
* <info>This event requires the {@link Permissions.FLAGS.MANAGE_GUILD} permission.</info> | ||
* @event Client#autoModerationRuleCreate | ||
* @param {AutoModerationRule} autoModerationRule The created auto moderation rule | ||
*/ | ||
client.emit(Events.AUTO_MODERATION_RULE_CREATE, autoModerationRule); | ||
} | ||
|
||
return {}; | ||
} | ||
} | ||
|
||
module.exports = AutoModerationRuleCreateAction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict'; | ||
|
||
const Action = require('./Action'); | ||
const { Events } = require('../../util/Constants'); | ||
|
||
class AutoModerationRuleDeleteAction extends Action { | ||
handle(data) { | ||
const { client } = this; | ||
const guild = client.guilds.cache.get(data.guild_id); | ||
|
||
if (guild) { | ||
const autoModerationRule = guild.autoModerationRules.cache.get(data.id); | ||
|
||
if (autoModerationRule) { | ||
guild.autoModerationRules.cache.delete(autoModerationRule.id); | ||
|
||
/** | ||
* Emitted whenever an auto moderation rule is deleted. | ||
* <info>This event requires the {@link Permissions.FLAGS.MANAGE_GUILD} permission.</info> | ||
* @event Client#autoModerationRuleDelete | ||
* @param {AutoModerationRule} autoModerationRule The deleted auto moderation rule | ||
*/ | ||
client.emit(Events.AUTO_MODERATION_RULE_DELETE, autoModerationRule); | ||
} | ||
} | ||
|
||
return {}; | ||
} | ||
} | ||
|
||
module.exports = AutoModerationRuleDeleteAction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict'; | ||
|
||
const Action = require('./Action'); | ||
const { Events } = require('../../util/Constants'); | ||
|
||
class AutoModerationRuleUpdateAction extends Action { | ||
handle(data) { | ||
const { client } = this; | ||
const guild = client.guilds.cache.get(data.guild_id); | ||
|
||
if (guild) { | ||
const oldAutoModerationRule = guild.autoModerationRules.cache.get(data.id)?._clone() ?? null; | ||
const newAutoModerationRule = guild.autoModerationRules._add(data); | ||
|
||
/** | ||
* Emitted whenever an auto moderation rule gets updated. | ||
* <info>This event requires the {@link Permissions.FLAGS.MANAGE_GUILD} permission.</info> | ||
* @event Client#autoModerationRuleUpdate | ||
* @param {?AutoModerationRule} oldAutoModerationRule The auto moderation rule before the update | ||
* @param {AutoModerationRule} newAutoModerationRule The auto moderation rule after the update | ||
*/ | ||
client.emit(Events.AUTO_MODERATION_RULE_UPDATE, oldAutoModerationRule, newAutoModerationRule); | ||
} | ||
|
||
return {}; | ||
} | ||
} | ||
|
||
module.exports = AutoModerationRuleUpdateAction; |
5 changes: 5 additions & 0 deletions
5
src/client/websocket/handlers/AUTO_MODERATION_ACTION_EXECUTION.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
module.exports = (client, packet) => { | ||
client.actions.AutoModerationActionExecution.handle(packet.d); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
module.exports = (client, packet) => { | ||
client.actions.AutoModerationRuleCreate.handle(packet.d); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
module.exports = (client, packet) => { | ||
client.actions.AutoModerationRuleDelete.handle(packet.d); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
module.exports = (client, packet) => { | ||
client.actions.AutoModerationRuleUpdate.handle(packet.d); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.