Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
27 changes: 27 additions & 0 deletions modules/auto-react/configs/replies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"filename": "replies.json",
"humanname-de": "Antworten",
"humanname-en": "Replies",
"configElements": true,
"content": [
{
"field_name": "members",
"default": "",
"humanname-de": "Nutzer",
"humanname-en": "User",
"type": "string",
"description-en": "Here you can add a member to be replied on mentions of them",
"description-de": "Du kannst hier einen Nutzer für Antworten auf Erwähnungen dessen eintragen"
},
{
"field_name": "reply",
"default": "",
"humanname-de": "Antwort",
"humanname-en": "Reply",
"type": "string",
"description-en": "Here you can add the reply message",
"description-de": "Du kannst hier die Antwort eintragen",
"allowEmbed": true
}
]
}
22 changes: 22 additions & 0 deletions modules/auto-react/events/messageCreate.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const {embedType} = require('../../../src/functions/helpers');
module.exports.run = async (client, msg) => {
if (!client.botReadyAt) return;
if (msg.interaction || msg.system || !msg.guild || msg.guild.id !== client.config.guildID) return;
await checkChannel(msg);
await checkMembers(msg);
await checkCategory(msg);
await checkAuthor(msg);
await checkMembersReply(msg);
};

/**
Expand Down Expand Up @@ -56,6 +58,26 @@ async function checkCategory(msg) {
});
}

/**
* Checks for member pings in a message and replys with the configured message
* @private
* @param msg
* @returns {Promise<void>}
*/
async function checkMembersReply(msg) {
const moduleConfig = msg.client.configurations['auto-react']['replies'];
if (!msg.mentions.users) return;
if (msg.author.id === msg.client.user.id) return;
for (const m of msg.mentions.users.values()) {
const matches = moduleConfig.filter(c => c.members === m.id);
for (const element of matches) {
await msg.reply(embedType(element.reply, {}, {ephemeral: true})).catch(() => {
});
}
}
}


/**
* Checks if a message need reactions (and reacts if needed) because it was send in a configured channel
* @private
Expand Down
4 changes: 3 additions & 1 deletion modules/auto-react/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "auto-react",
"humanReadableName-de": "Automatisches Reagieren",
"humanReadableName-en": "Automatic reactions",
"fa-icon": "far fa-smile",
"author": {
"scnxOrgID": "1",
"name": "SCDerox (SC Network Team)",
Expand All @@ -12,7 +13,8 @@
"description-de": "Reagiert automatisch mit ausgewählten Emojs in einem ausgewählten Channel und bei Pings",
"events-dir": "/events",
"config-example-files": [
"config.json"
"configs/config.json",
"configs/replies.json"
],
"tags": [
"fun"
Expand Down