Slight adjustments.
This commit is contained in:
@@ -16,7 +16,6 @@ module.exports = {
|
||||
}
|
||||
],
|
||||
run: async (client, interaction) => {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
const user = interaction.options.getString('user');
|
||||
|
||||
await getUserData(user).then(async (userData) => {
|
||||
|
||||
@@ -24,7 +24,6 @@ module.exports = {
|
||||
run: async (client, interaction) => {
|
||||
const guildId = interaction.guild.id;
|
||||
|
||||
await interaction.deferReply({ ephemeral: true});
|
||||
const user = interaction.options.getUser('user');
|
||||
const member = await interaction.guild.members.fetch(user.id);
|
||||
if (!member) return interaction.editReply({ content: 'User not found.' });
|
||||
|
||||
+17
-268
@@ -1,6 +1,8 @@
|
||||
const { ApplicationCommandType, ApplicationCommandOptionType, EmbedBuilder } = require('discord.js');
|
||||
const cfg = require('../../config/config.js');
|
||||
const { getActionDuration, convertActionDurationFromMsToTime, convertActionDurationFromTimeToMs } = require('../../functions/utils.js');
|
||||
const { getActionDuration, convertActionDurationFromTimeToMs } = require('../../functions/utils.js');
|
||||
const ModerationUtils = require('../../database/models/ModerationUtils.js');
|
||||
const { automodChanger } = require('../../functions/autostuff.js');
|
||||
|
||||
module.exports = {
|
||||
name: 'settings',
|
||||
@@ -8,8 +10,8 @@ module.exports = {
|
||||
type: ApplicationCommandType.ChatInput,
|
||||
options: [
|
||||
{
|
||||
name: 'change',
|
||||
description: 'Set the settings of the bot.',
|
||||
name: 'automod',
|
||||
description: 'Set the settings of the automod.',
|
||||
type: ApplicationCommandOptionType.Subcommand,
|
||||
options: [
|
||||
{
|
||||
@@ -32,7 +34,7 @@ module.exports = {
|
||||
name: 'enable-or-disable',
|
||||
description: 'Enable or disable the setting.',
|
||||
type: ApplicationCommandOptionType.String,
|
||||
required: false,
|
||||
required: true,
|
||||
choices: [
|
||||
{
|
||||
name: 'Enable',
|
||||
@@ -132,7 +134,6 @@ module.exports = {
|
||||
],
|
||||
default_member_permissions: ["Administrator"],
|
||||
run: async (client, interaction) => {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
const filter = {
|
||||
guildId: interaction.guild.id
|
||||
}
|
||||
@@ -145,7 +146,7 @@ module.exports = {
|
||||
const automodActionDuration = interaction.options.get('automod-action-duration')?.value;
|
||||
const checksettings = interaction.options.get('settings')?.value;
|
||||
|
||||
const GuildSettings = require('../../database/models/GuildSettings');
|
||||
const GuildSettings = require('../../database/models/GuildSettings.js');
|
||||
const NewUserAction = require('../../database/models/NewUserAction.js');
|
||||
const VerifyFailAction = require('../../database/models/VerifyFailAction.js');
|
||||
const guildSettings = await GuildSettings.findOne(filter);
|
||||
@@ -153,143 +154,16 @@ module.exports = {
|
||||
const verifyFailAction = await VerifyFailAction.findOne(filter);
|
||||
|
||||
switch (subcommand) {
|
||||
case 'change':
|
||||
switch (settings) {
|
||||
case 'verification':
|
||||
switch (automodAction) {
|
||||
case undefined:
|
||||
console.log('a')
|
||||
switch (enableOrDisable) {
|
||||
case 'true': case 'false':
|
||||
console.log(enableOrDisable)
|
||||
switch (guildSettings) {
|
||||
case null:
|
||||
const newGuildSettings = new GuildSettings({
|
||||
guildId: interaction.guild.id,
|
||||
verifyEnabled: enableOrDisable
|
||||
});
|
||||
await newGuildSettings.save();
|
||||
break;
|
||||
default:
|
||||
guildSettings.verifyEnabled = enableOrDisable;
|
||||
await guildSettings.save();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'none':
|
||||
console.log('b')
|
||||
await VerifyFailAction.find(filter).deleteMany();
|
||||
break;
|
||||
default:
|
||||
console.log('c')
|
||||
switch (enableOrDisable) {
|
||||
case 'true': case 'false':
|
||||
switch (guildSettings) {
|
||||
case null:
|
||||
const newGuildSettings = new GuildSettings({
|
||||
guildId: interaction.guild.id,
|
||||
verifyEnabled: enableOrDisable
|
||||
});
|
||||
await newGuildSettings.save();
|
||||
break;
|
||||
default:
|
||||
guildSettings.verifyEnabled = enableOrDisable;
|
||||
await guildSettings.save();
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
switch (verifyFailAction) {
|
||||
case null:
|
||||
const newVerifyFailAction = new VerifyFailAction({
|
||||
guildId: interaction.guild.id,
|
||||
action: automodAction,
|
||||
reason: automodActionReason || 'User failed to verify.',
|
||||
threshold: automodActionThreshold || 3,
|
||||
duration: automodActionDuration || '7d'
|
||||
});
|
||||
await newVerifyFailAction.save();
|
||||
break;
|
||||
default:
|
||||
verifyFailAction.action = automodAction || verifyFailAction?.action;
|
||||
verifyFailAction.reason = `${automodActionReason?.toString()}` || verifyFailAction?.reason || 'User failed to verify.';
|
||||
verifyFailAction.threshold = automodActionThreshold || verifyFailAction?.threshold || 3;
|
||||
verifyFailAction.duration = automodActionDuration || verifyFailAction?.duration || '7d';
|
||||
await verifyFailAction.save();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'anti-new-user':
|
||||
switch (automodAction) {
|
||||
case undefined:
|
||||
switch (enableOrDisable) {
|
||||
case 'true': case 'false':
|
||||
switch (guildSettings) {
|
||||
case null:
|
||||
const newGuildSettings = new GuildSettings({
|
||||
guildId: interaction.guild.id,
|
||||
antiNewUserEnabled: enableOrDisable
|
||||
});
|
||||
await newGuildSettings.save();
|
||||
break;
|
||||
default:
|
||||
guildSettings.antiNewUserEnabled = enableOrDisable;
|
||||
await guildSettings.save();
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'none':
|
||||
await NewUserAction.find(filter).deleteMany();
|
||||
break;
|
||||
default:
|
||||
switch (enableOrDisable) {
|
||||
case 'true': case 'false':
|
||||
switch (guildSettings) {
|
||||
case null:
|
||||
const newGuildSettings = new GuildSettings({
|
||||
guildId: interaction.guild.id,
|
||||
antiNewUserEnabled: enableOrDisable
|
||||
});
|
||||
await newGuildSettings.save();
|
||||
break;
|
||||
default:
|
||||
guildSettings.antiNewUserEnabled = enableOrDisable;
|
||||
await guildSettings.save();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
switch (newUserAction) {
|
||||
case null:
|
||||
const newNewUserAction = new NewUserAction({
|
||||
guildId: interaction.guild.id,
|
||||
action: automodAction,
|
||||
reason: automodActionReason || 'User account age is way too low.',
|
||||
threshold: automodActionThreshold || 3,
|
||||
duration: automodActionDuration || '7d'
|
||||
});
|
||||
await newNewUserAction.save();
|
||||
break;
|
||||
default:
|
||||
newUserAction.action = automodAction || newUserAction?.action;
|
||||
newUserAction.reason = `${automodActionReason?.toString()}` || newUserAction?.reason || 'User account age is way too low.';
|
||||
newUserAction.threshold = automodActionThreshold || newUserAction?.threshold || 3;
|
||||
newUserAction.duration = automodActionDuration || newUserAction?.duration || '7d';
|
||||
await newUserAction.save();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'automod':
|
||||
await automodChanger(
|
||||
interaction.guild,
|
||||
settings,
|
||||
enableOrDisable,
|
||||
automodAction,
|
||||
automodActionReason,
|
||||
automodActionThreshold,
|
||||
automodActionDuration
|
||||
)
|
||||
await interaction.editReply({ content: 'Settings have been updated.' });
|
||||
break;
|
||||
case 'check':
|
||||
@@ -336,9 +210,6 @@ module.exports = {
|
||||
})
|
||||
.setColor("Gold");
|
||||
|
||||
console.log(verifyFailAction?.duration, await getActionDuration(verifyFailAction?.duration), await convertActionDurationFromTimeToMs(verifyFailAction?.duration));
|
||||
console.log(newUserAction?.duration, await getActionDuration(newUserAction?.duration), await convertActionDurationFromTimeToMs(newUserAction?.duration));
|
||||
|
||||
switch (checksettings) {
|
||||
case 'general':
|
||||
await interaction.editReply({ embeds: [embed] });
|
||||
@@ -364,127 +235,5 @@ module.exports = {
|
||||
await interaction.editReply({ content: 'Check the console.' });
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
if (settings === 'verification') {
|
||||
console.log('a')
|
||||
if (automodAction === undefined) {
|
||||
console.log('i')
|
||||
if (enableOrDisable !== undefined) {
|
||||
if (guildSettings === null) {
|
||||
const newGuildSettings = new GuildSettings({
|
||||
guildId: interaction.guild.id,
|
||||
verifyEnabled: enableOrDisable
|
||||
});
|
||||
await newGuildSettings.save();
|
||||
} else {
|
||||
guildSettings.verifyEnabled = enableOrDisable;
|
||||
await guildSettings.save();
|
||||
}
|
||||
} else if (enableOrDisable === undefined) {
|
||||
if (verifyFailAction === null) {
|
||||
const newVerifyFailAction = new VerifyFailAction({
|
||||
guildId: interaction.guild.id,
|
||||
action: automodAction,
|
||||
reason: `${automodActionReason.toString()}` || 'No reason provided.',
|
||||
threshold: automodActionThreshold || 3,
|
||||
duration: automodActionDuration || 7
|
||||
});
|
||||
await newVerifyFailAction.save();
|
||||
} else if (verifyFailAction !== null) {
|
||||
verifyFailAction.action = automodAction;
|
||||
verifyFailAction.reason = `${automodActionReason.toString()}` || 'No reason provided.';
|
||||
verifyFailAction.threshold = automodActionThreshold || 3;
|
||||
verifyFailAction.duration = automodActionDuration || 7;
|
||||
await verifyFailAction.save();
|
||||
} else if (verifyFailAction?.action !== 'none' && automodAction === 'none') {
|
||||
await VerifyFailAction.find(filter).deleteMany();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (settings === 'anti-new-user') {
|
||||
if (enableOrDisable !== undefined && automodAction === undefined) {
|
||||
if (guildSettings === null) {
|
||||
const newGuildSettings = new GuildSettings({
|
||||
guildId: interaction.guild.id,
|
||||
antiNewUserEnabled: enableOrDisable
|
||||
});
|
||||
await newGuildSettings.save();
|
||||
} else {
|
||||
guildSettings.antiNewUserEnabled = enableOrDisable;
|
||||
await guildSettings.save();
|
||||
}
|
||||
} else if (enableOrDisable !== undefined && automodAction !== 'none') {
|
||||
if (guildSettings === null) {
|
||||
const newGuildSettings = new GuildSettings({
|
||||
guildId: interaction.guild.id,
|
||||
antiNewUserEnabled: enableOrDisable
|
||||
});
|
||||
await newGuildSettings.save();
|
||||
} else {
|
||||
guildSettings.antiNewUserEnabled = enableOrDisable;
|
||||
await guildSettings.save();
|
||||
}
|
||||
if (newUserAction === null) {
|
||||
const newNewUserAction = new NewUserAction({
|
||||
guildId: interaction.guild.id,
|
||||
action: automodAction,
|
||||
reason: `${automodActionReason}` || 'No reason provided.',
|
||||
threshold: automodActionThreshold || 3,
|
||||
duration: automodActionDuration || 0
|
||||
});
|
||||
await newNewUserAction.save();
|
||||
} else {
|
||||
newUserAction.action = automodAction;
|
||||
newUserAction.reason = `${automodActionReason}` || 'No reason provided.';
|
||||
newUserAction.threshold = automodActionThreshold || 3;
|
||||
newUserAction.duration = automodActionDuration || 0;
|
||||
await newUserAction.save();
|
||||
}
|
||||
} else if (enableOrDisable !== undefined && automodAction === 'none') {
|
||||
if (guildSettings === null) {
|
||||
const newGuildSettings = new GuildSettings({
|
||||
guildId: interaction.guild.id,
|
||||
antiNewUserEnabled: enableOrDisable
|
||||
});
|
||||
await newGuildSettings.save();
|
||||
} else {
|
||||
guildSettings.antiNewUserEnabled = enableOrDisable;
|
||||
await guildSettings.save();
|
||||
}
|
||||
if (newUserAction?.action !== 'none') {
|
||||
await NewUserAction.find(filter).deleteMany();
|
||||
}
|
||||
}
|
||||
}
|
||||
await interaction.editReply({ content: 'Settings have been updated.' });
|
||||
} else if (subcommand === 'check') {
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle('Settings')
|
||||
.addFields({
|
||||
name: 'Verification',
|
||||
value: `${guildSettings?.verifyEnabled ? 'Enabled' : 'Disabled'}`,
|
||||
},
|
||||
{
|
||||
name: 'Verification Auto Action',
|
||||
value: `${verifyFailAction ? `Action: ${verifyFailAction?.action.toUpperCase()}\nReason: ${verifyFailAction?.reason}\nThreshold: ${verifyFailAction?.threshold}\nDuration: ${verifyFailAction?.duration}` : "None"}`,
|
||||
},
|
||||
{
|
||||
name: 'Anti New User',
|
||||
value: `${guildSettings?.antiNewUserEnabled ? 'Enabled' : 'Disabled'}`,
|
||||
},
|
||||
{
|
||||
name: 'Anti New User Auto Action',
|
||||
value: `${newUserAction ? `Action: ${newUserAction?.action.toUpperCase()}\nReason: ${newUserAction?.reason}\nThreshold: ${newUserAction?.threshold}\nDuration: ${newUserAction?.duration}` : "None"}`,
|
||||
})
|
||||
.setColor("Gold");
|
||||
await interaction.editReply({ embeds: [embed] });
|
||||
} else if (subcommand === 'reset') {
|
||||
await GuildSettings.find(filter).deleteMany();
|
||||
await NewUserAction.find(filter).deleteMany();
|
||||
await VerifyFailAction.find(filter).deleteMany();
|
||||
await interaction.editReply({ content: 'Settings have been reset.' });
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@ module.exports = {
|
||||
type: ApplicationCommandType.ChatInput,
|
||||
run: async (client, interaction) => {
|
||||
const guildSettings = await GuildSettings.findOne({ guildId: interaction.guild.id });
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
const guildId = interaction.guild.id;
|
||||
|
||||
async function generateCaptcha(count) {
|
||||
|
||||
Reference in New Issue
Block a user