Skip to content

Commit

Permalink
eslint
Browse files Browse the repository at this point in the history
Signed-off-by: GitHub <[email protected]>
  • Loading branch information
web-flow authored Oct 14, 2023
1 parent d159fc3 commit 7e18cb3
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 33 deletions.
18 changes: 9 additions & 9 deletions commands/approve.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
const { SlashCommandBuilder } = require('discord.js');
const { approvUser } = require('../modules/approvUser.js');
const { approvUser } = require('../modules/approvUser.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('approve')
.setDescription('Erlaubt einen User für 10min gespeerte Links zu posten.')
.setDefaultMemberPermissions(0)
.setDMPermission(false)
.addUserOption(option =>
option.setName('user')
.setDescription('Der User der Freigeschaltet werden soll.')
.setRequired(true)),
.setDefaultMemberPermissions(0)
.setDMPermission(false)
.addUserOption((option) =>
option.setName('user')
.setDescription('Der User der Freigeschaltet werden soll.')
.setRequired(true)),
async execute(interaction) {
approvUser(interaction.options.getUser("user").id);
approvUser(interaction.options.getUser('user').id);
await interaction.reply({
content: 'Erlaube ' + interaction.options.getUser("user").username + ' für 10min gespeerte Links zu posten.',
content: 'Erlaube ' + interaction.options.getUser('user').username + ' für 10min gespeerte Links zu posten.',
ephemeral: true,
});
}
Expand Down
2 changes: 1 addition & 1 deletion events/messageCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ module.exports = {
if (message.channelId === config.gh_feed) {
message.crosspost();
}
checkMessageForDomains(message, config);
checkMessageForDomains(message, config);
},
};
4 changes: 2 additions & 2 deletions events/messageUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { checkMessageForDomains } = require('../modules/domainCheck.js');
module.exports = {
name: 'messageUpdate',
async execute(messageOld, messageNew, client, config) {
checkMessageForDomains(messageOld, config);
checkMessageForDomains(messageNew, config);
checkMessageForDomains(messageOld, config);
checkMessageForDomains(messageNew, config);
},
};
20 changes: 10 additions & 10 deletions modules/approvUser.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const approvedUser = new Set();

module.exports = {
async approvUser(user) {
approvedUser.add(user)
setTimeout(() => {
approvedUser.delete(user)
}, 10 * 60 * 1000);
},
async ifUserApproved(user) {
return await approvedUser.has(user)
}
}
async approvUser(user) {
approvedUser.add(user);
setTimeout(() => {
approvedUser.delete(user);
}, 10 * 60 * 1000);
},
async ifUserApproved(user) {
return await approvedUser.has(user);
}
};
22 changes: 11 additions & 11 deletions modules/domainCheck.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const { WebhookClient } = require('discord.js');
const dns = require('node:dns');
const { WebhookClient } = require('discord.js');
const dns = require('node:dns');
const { ifUserApproved } = require('./approvUser.js');

module.exports = {
async checkMessageForDomains(message, config) {
const teamServerClient = new WebhookClient({ id: config.log_webhook_id, token: config.log_webhook_token });
async checkMessageForDomains(message, config) {
const teamServerClient = new WebhookClient({ id: config.log_webhook_id, token: config.log_webhook_token });
if (message.content.toLowerCase().match(/discord[^\s]*gg|discord[^\s]*invite/g) != null) {
if(message.member.permissions.has('ADMINISTRATOR')) return
if (message.member.permissions.has('ADMINISTRATOR')) return;
message.delete();
teamServerClient.send({
content: message.author.username + ' hat folgende Nachricht gesendet, welche automatisch gelöscht wurde "' + message.content + '"',
Expand All @@ -16,10 +16,10 @@ module.exports = {
return;
}

var urls = message.content.toLowerCase().replace(/[.,]+/g,'.').match(/([^\s:/@]+\.)+[^\s:/@]+/g);
var urls = message.content.toLowerCase().replace(/[.,]+/g, '.').match(/([^\s:/@]+\.)+[^\s:/@]+/g);
if (!urls) return;
if(await ifUserApproved(message.author.id)) {
message.react('✅')
if (await ifUserApproved(message.author.id)) {
message.react('✅');
return;
}

Expand All @@ -28,7 +28,7 @@ module.exports = {
family: 0,
hints: dns.ADDRCONFIG | dns.V4MAPPED,
};
console.log("Check URL " + urls[i] + " from " + message.author.username);
console.log('Check URL ' + urls[i] + ' from ' + message.author.username);
if (urls[i].match(/^([a-z0-9-]+\.)+[a-z0-9-]+$/g) == null) {
message.delete();
teamServerClient.send({
Expand All @@ -49,5 +49,5 @@ module.exports = {
});
}
}
}
}
}
};

0 comments on commit 7e18cb3

Please sign in to comment.