Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@
}
}
]
}
}
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
}
]
}
26 changes: 25 additions & 1 deletion modules/auto-react/events/messageCreate.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
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 All @@ -26,6 +29,27 @@ async function checkMembers(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.members) return;
if (msg.author === client.user) return;
msg.mentions.members.forEach(m => {
console.log(moduleConfig);
for (const element of moduleConfig) {
if (element.member === m.id) {
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 Expand Up @@ -69,4 +93,4 @@ async function checkAuthor(msg) {
msg.react(emoji).catch(() => {
});
});
}
}
3 changes: 2 additions & 1 deletion modules/auto-react/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,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