Finalizing applications

This commit is contained in:
2023-03-13 00:11:59 +01:00
parent ad37b8f960
commit 3deec40feb
5 changed files with 35 additions and 1 deletions

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
node_modules/*
applications/*
config.json

View File

@@ -1,3 +1,6 @@
const fs = require('fs');
const path = require('path');
module.exports = {
name: 'applicationdelete',
description: 'Delete an application channel.',
@@ -6,11 +9,17 @@ module.exports = {
async execute(interaction) {
const channel = interaction.channel;
const applicantId = await channel.topic;
await interaction.reply('Application channel will be deleted in 5 seconds');
setTimeout(async () => {
const filePath = path.join(__dirname, `../../applications/${applicantId}`);
fs.rmSync(filePath, { force: true });
await channel.delete();
}, 5000);
}

View File

View File

@@ -1,5 +1,7 @@
const { ChannelType, PermissionFlagsBits, ButtonBuilder, ButtonStyle, ActionRowBuilder, EmbedBuilder } = require('discord.js');
const { color } = require('../../options.json');
const path = require('path');
const fs = require('fs');
module.exports = {
name: 'guildapply',
@@ -14,6 +16,14 @@ module.exports = {
if (interaction.customId === 'guildapply') {
// check if there is a file in the applications folder with the user's id as the name
const applicationFile = path.join(__dirname, '../../applications/' + user.id);
if (fs.existsSync(applicationFile)) {
await interaction.reply({ content: "You already have an application in progress.", ephemeral: true });
return
}
const tooLong = new EmbedBuilder()
.setDescription("You took too long to respond.")
.setColor(embedColor)
@@ -215,6 +225,10 @@ module.exports = {
}]
})
fs.writeFile(`./applications/${user.id}`, answer1_1, function (err) {
if (err) throw err;
});
await guild.channels.create({
name: `Application-${user.username}`,
type: ChannelType.GuildText,
@@ -286,6 +300,12 @@ module.exports = {
.setCustomId("guildapplicationdeny")
.setLabel("Deny")
.setStyle(ButtonStyle.Danger)
),
new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId("checkstats")
.setLabel("Check Stats")
.setStyle(ButtonStyle.Secondary)
)
]
});

View File

@@ -1,3 +1,5 @@
const fs = require('fs');
const path = require('path');
const { color } = require('../../options.json');
module.exports = {
@@ -21,7 +23,9 @@ module.exports = {
}]
});
await channel.delete();
const filePath = path.join(__dirname, `../../applications/${applicantId}`);
fs.rmSync(filePath, { force: true });
await channel.delete();
}
};