Experimental stuff. Albeit experimental, it should work.

This commit is contained in:
Kwafuri
2024-02-12 23:31:23 +00:00
parent b93426ca91
commit 121e64427e
2 changed files with 132 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
const { EmbedBuilder } = require('discord.js');
const client = require('..');
const settings = client.db.get(`settings-${member.guild.id}`) || {};
client.on('guildMemberAdd', async member => {
//auto kicker
if (settings.newUserKicker === true) {
if (member.user.createdTimestamp > Date.now() - (settings.newUserKickerThreshold * 24 * 60 * 60 * 1000)) {
member.kick(`Account is too new.`).catch(() => {});
console.log(`Automatically kicked ${member.user.tag} from ${member.guild.name} for being too new.`)
} else {
console.log(`User account age is above the threshold. Not kicking ${member.user.tag} from ${member.guild.name}.`)
}
}
});
+117
View File
@@ -0,0 +1,117 @@
const { ApplicationCommandType, ApplicationCommandOptionType, EmbedBuilder } = require('discord.js');
const cfg = require('../../config/config.js');
module.exports = {
name: 'settings',
description: 'Change the settings for the bot.',
type: ApplicationCommandType.ChatInput,
options: [
{
name: 'verification',
description: 'Enable or disable, or change the settings of verification.',
type: ApplicationCommandOptionType.Subcommand,
options: [
{
name: 'enable-or-disable',
description: 'Enable or disable verification.',
type: ApplicationCommandOptionType.String,
choices: [
{
name: 'Enable',
value: 'true'
},
{
name: 'Disable',
value: 'false'
}
],
required: true
},
]
},
{
name: 'new-user-kicker',
description: 'Enable or disable, or change the settings of new user kicker.',
type: ApplicationCommandOptionType.Subcommand,
options: [
{
name: 'enable-or-disable',
description: 'Enable or disable new user kicker.',
type: ApplicationCommandOptionType.String,
choices: [
{
name: 'Enable',
value: 'true'
},
{
name: 'Disable',
value: 'false'
}
],
required: true
},
{
name: 'threshold',
description: 'Set the amount of days user account age to kick.',
type: ApplicationCommandOptionType.Integer,
required: false
}
]
},
{
name: 'check',
description: 'Check the current settings of the bot.',
type: ApplicationCommandOptionType.Subcommand
}
],
default_member_permissions: ["Administrator"],
run: async (client, interaction) => {
await interaction.deferReply({ ephemeral: true });
const subcommand = interaction.options.getSubcommand();
const guildId = interaction.guild.id;
const settings = await client.db.get(`settings-${guildId}`) || {};
if (subcommand === 'verification') {
const value = interaction.options.getString('enable-or-disable');
client.db.set(`settings-${guildId}`, { verification: value });
return interaction.editReply({ content: `Verification has been ${value ? 'enabled' : 'disabled'}.` });
} else if (subcommand === 'new-user-kicker') {
const value = interaction.options.getString('enable-or-disable');
if (value === 'true') {
const threshold = interaction.options.getInteger('threshold') || 7;
client.db.set(`settings-${guildId}`, { newUserKicker: true });
client.db.set(`settings-${guildId}.newUserKickerThreshold`, threshold);
return interaction.editReply({ content: `New user kicker has been enabled with a threshold of ${threshold} days.` });
} else {
client.db.set(`settings-${guildId}`, { newUserKicker: false });
client.db.delete(`settings-${guildId}.newUserKickerThreshold`);
return interaction.editReply({ content: `New user kicker has been disabled.` });
}
} else if (subcommand === 'check') {
const embed = new EmbedBuilder()
.setTitle('Bot Settings')
.setColor('Green')
.setTimestamp();
if (settings.verification === true) {
embed.addFields({ name: 'Verification', value: 'Enabled' })
} else {
embed.addFields({ name: 'Verification', value: 'Disabled' })
}
if (settings.newUserKicker === true) {
embed.addFields(
{
name: 'New User Kicker',
value: `Enabled with a threshold of ${settings.newUserKickerThreshold} days.`
}
)
} else {
embed.addFields({ name: 'New User Kicker', value: 'Disabled' })
}
return interaction.editReply({ embeds: [embed] });
}
}
}