Finishing staff applications
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"color": "#eeaadb",
|
||||
"applicationsChannel": "776705352456470550",
|
||||
"staffApplicationsChannel": "1039258641393520700",
|
||||
"hypixelGuildID": "5a353a170cf2e529044f2935"
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
|
||||
const { color } = require('../../config/options.json');
|
||||
const mongoose = require('mongoose');
|
||||
const staffapp = require('../../schemas/staffAppSchema.js');
|
||||
|
||||
module.exports = {
|
||||
name: 'staffapplicationaccept',
|
||||
@@ -13,9 +15,11 @@ module.exports = {
|
||||
const guild = interaction.guild;
|
||||
const embedColor = Number(color.replace("#", "0x"));
|
||||
|
||||
const applicantId = await channel.topic
|
||||
const message = interaction.message;
|
||||
const embed = message.embeds[0];
|
||||
const applicantId = embed.footer.text.split(" ")[1]
|
||||
|
||||
const applicant = await guild.members.fetch(applicantId)
|
||||
const applicantUsername = applicant.user.username + "#" + applicant.user.discriminator;
|
||||
|
||||
await applicant.send({
|
||||
embeds: [{
|
||||
@@ -24,13 +28,6 @@ module.exports = {
|
||||
}]
|
||||
});
|
||||
|
||||
// fetcg the message with the buttons staffapplicationaccept and staffapplicationdeny
|
||||
|
||||
const message = await channel.messages.fetch({ limit: 10 });
|
||||
const messageID = message.first().id;
|
||||
|
||||
await channel.messages.fetch(messageID).then(async (message) => {
|
||||
|
||||
await message.edit({
|
||||
components: [
|
||||
new ActionRowBuilder().addComponents(
|
||||
@@ -49,7 +46,8 @@ module.exports = {
|
||||
)
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
await staffapp.findOneAndDelete({ userId: applicantId });
|
||||
|
||||
await interaction.reply({
|
||||
embeds: [{
|
||||
@@ -65,15 +63,7 @@ module.exports = {
|
||||
iconurl: guild.iconURL(),
|
||||
text: "ID: " + applicantId
|
||||
}
|
||||
}],
|
||||
components: [
|
||||
new ActionRowBuilder().addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId("staffapplicationdelete")
|
||||
.setLabel("Delete channel")
|
||||
.setStyle(ButtonStyle.Danger)
|
||||
)
|
||||
]
|
||||
}]
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
name: 'staffapplicationdelete',
|
||||
description: 'Delete an application channel.',
|
||||
type: 'button',
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
await interaction.deferReply();
|
||||
|
||||
const channel = interaction.channel;
|
||||
const applicantId = await channel.topic;
|
||||
|
||||
await interaction.editReply('Application channel will be deleted in 5 seconds');
|
||||
|
||||
setTimeout(async () => {
|
||||
|
||||
const filePath = path.join(__dirname, `../../apps/staff/${applicantId}`);
|
||||
fs.rmSync(filePath, { force: true });
|
||||
|
||||
await channel.delete();
|
||||
|
||||
}, 5000);
|
||||
|
||||
}
|
||||
};
|
||||
@@ -10,13 +10,6 @@ module.exports = {
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
const channel = interaction.channel;
|
||||
const guild = interaction.guild;
|
||||
const embedColor = Number(color.replace("#", "0x"));
|
||||
|
||||
const applicantId = await channel.topic
|
||||
const applicant = await guild.members.fetch(applicantId)
|
||||
|
||||
const modal = new ModalBuilder()
|
||||
.setTitle('Deny Reason')
|
||||
.setCustomId('staffdenyreasonbox')
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
const { ChannelType, PermissionFlagsBits, ButtonBuilder, ButtonStyle, ActionRowBuilder, EmbedBuilder } = require('discord.js');
|
||||
const { color } = require('../../config/options.json');
|
||||
const { largeM, smallM, ignM } = require('../../config/limitmessages.json')
|
||||
const { applicationsCategory } = require('../../config/options.json');
|
||||
const { staffApplicationsChannel } = require('../../config/options.json');
|
||||
const { sq1, sq2, sq3, sq4, sq5, sq6 } = require('../../config/questions.json');
|
||||
const { rsq1, rsq2, rsq3, rsq4, rsq5, rsq6 } = require('../../config/questions.json');
|
||||
const { guildRole, guildStaff } = require('../../config/roles.json')
|
||||
const mongoose = require('mongoose');
|
||||
const staffapp = require('../../schemas/staffAppSchema.js');
|
||||
const path = require('path');
|
||||
const fetch = require('axios');
|
||||
const fs = require('fs');
|
||||
@@ -34,10 +36,10 @@ module.exports = {
|
||||
// await interaction.editReply({content: "You are already a staff member.", ephemeral: true});
|
||||
// }
|
||||
|
||||
const applicationFile = path.join(__dirname, '../../apps/staff/' + user.id);
|
||||
if (fs.existsSync(applicationFile)) {
|
||||
const application = await staffapp.findOne({ userID: user.id });
|
||||
|
||||
if (application) {
|
||||
await interaction.editReply({ content: "You already have an application in progress.", ephemeral: true });
|
||||
return
|
||||
}
|
||||
|
||||
const tooLong = new EmbedBuilder()
|
||||
@@ -362,26 +364,14 @@ module.exports = {
|
||||
}]
|
||||
})
|
||||
|
||||
const userCheck = await fetch(mojangAPI + answer1_1)
|
||||
const uuid = userCheck.data.id
|
||||
|
||||
fs.writeFile(`./apps/staff/${user.id}`, uuid, function (err) {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
const newStaffApp = new staffapp({
|
||||
_id: new mongoose.Types.ObjectId(),
|
||||
userID: user.id,
|
||||
})
|
||||
newStaffApp.save()
|
||||
await user.deleteDM();
|
||||
|
||||
await guild.channels.create({
|
||||
name: `staff-app-${user.username}`,
|
||||
type: ChannelType.GuildText,
|
||||
topic: user.id,
|
||||
permissionOverwrites: [
|
||||
{
|
||||
id: guild.roles.everyone,
|
||||
deny: [PermissionFlagsBits.ViewChannel]
|
||||
}
|
||||
]
|
||||
}).then(async channel => {
|
||||
const channel = guild.channels.cache.get(staffApplicationsChannel);
|
||||
|
||||
await channel.send({
|
||||
embeds: [{
|
||||
@@ -436,9 +426,8 @@ module.exports = {
|
||||
.setStyle(ButtonStyle.Danger)
|
||||
)
|
||||
]
|
||||
});
|
||||
|
||||
})
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,12 +16,14 @@ module.exports = {
|
||||
interaction.deferReply();
|
||||
|
||||
const channel = interaction.channel;
|
||||
const applicantId = channel.topic;
|
||||
const guild = interaction.guild;
|
||||
const applicant = await guild.members.fetch(applicantId);
|
||||
const reason = interaction.fields.fields.get('staffdenyreason').value || "No reason provided";
|
||||
const embedColor = Number(color.replace("#", "0x"));
|
||||
const filePath = path.join(__dirname, `../../apps/staff/${applicantId}`);
|
||||
|
||||
const message = interaction.message;
|
||||
const embed = message.embeds[0];
|
||||
const applicantId = embed.footer.text.split(" ")[1]
|
||||
const applicant = await guild.members.fetch(applicantId)
|
||||
|
||||
const dmMessage = new EmbedBuilder()
|
||||
.setDescription("Your application for the Illegitimate guild staff has been denied\n" +
|
||||
@@ -32,15 +34,18 @@ module.exports = {
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
description: "Application denied\n" +
|
||||
"Channel will be deleted in 5 seconds...",
|
||||
color: embedColor
|
||||
title: "Application Denied",
|
||||
description: "The application has been denied by <@" + interaction.user.id + ">.\n" +
|
||||
"**Reason:** `" + reason + "`",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: applicant.avatarURL()
|
||||
},
|
||||
footer: {
|
||||
iconURL: guild.iconURL(),
|
||||
text: "ID: " + applicant.id
|
||||
}
|
||||
}],
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
fs.rmSync(filePath, { force: true });
|
||||
channel.delete();
|
||||
}, 5000);
|
||||
});;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user