Updating applicaitons

This commit is contained in:
2023-03-19 22:11:53 +01:00
parent fa3be9473d
commit fc974dbf08
7 changed files with 151 additions and 176 deletions

View File

@@ -1,28 +0,0 @@
const fs = require('fs');
const path = require('path');
module.exports = {
name: 'applicationdelete',
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/guild/${applicantId}`);
fs.rmSync(filePath, { force: true });
await channel.delete();
}, 5000);
}
};

View File

@@ -12,12 +12,12 @@ module.exports = {
async execute(interaction) {
await interaction.deferReply();
const channel = interaction.channel;
const applicantId = await channel.topic
const message = interaction.message;
const embed = message.embeds[0];
const applicantId = embed.footer.text.split(" ")[1]
const filePath = path.join(__dirname, `../../apps/guild/${applicantId}`);
const uuid = fs.readFileSync(filePath, 'utf8');
const mojang = "https://api.mojang.com/user/profile/"

View File

@@ -1,7 +1,7 @@
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 { applicationsChannel } = require('../../config/options.json');
const { qu1, qu2, qu3, qu4, qu5, qu6, qu7, qu8 } = require('../../config/questions.json');
const { rq1, rq2, rq3, rq4, rq5, rq6, rq7, rq8 } = require('../../config/questions.json');
const { guildRole } = require('../../config/roles.json')
@@ -26,12 +26,12 @@ module.exports = {
if (interaction.customId === 'guildapply') {
await interaction.deferReply();
await interaction.deferReply({ ephemeral: true });
if (userRoles.includes(guildRole)) {
await interaction.editReply({ content: "You are already a member of the guild.", ephemeral: true });
return
}
// if (userRoles.includes(guildRole)) {
// await interaction.editReply({ content: "You are already a member of the guild.", ephemeral: true });
// return
// }
const applicationFile = path.join(__dirname, '../../apps/guild/' + user.id);
if (fs.existsSync(applicationFile)) {
@@ -446,89 +446,73 @@ module.exports = {
});
await user.deleteDM();
const channel = guild.channels.cache.get(applicationsChannel);
await guild.channels.create({
name: `guild-app-${user.username}`,
type: ChannelType.GuildText,
topic: user.id,
permissionOverwrites: [
{
id: guild.roles.everyone,
deny: [PermissionFlagsBits.ViewChannel]
}
]
}).then(async channel => {
await channel.send({
embeds: [{
title: user.username + "#" + user.discriminator + " - Guild Application",
color: embedColor,
thumbnail: {
url: user.avatarURL()
await channel.send({
embeds: [{
title: user.username + "#" + user.discriminator + " - Guild Application",
color: embedColor,
thumbnail: {
url: user.avatarURL()
},
fields: [
{
name: rq1,
value: "```" + answer1_1 + "```"
},
fields: [
{
name: rq1,
value: "```" + answer1_1 + "```"
},
{
name: rq2,
value: "```" + answer2_1 + "```"
},
{
name: rq3,
value: "```" + answer3_1 + "```"
},
{
name: rq4,
value: "```" + answer4_1 + "```"
},
{
name: rq5,
value: "```" + answer5_1 + "```"
},
{
name: rq6,
value: "```" + answer6_1 + "```"
},
{
name: rq7,
value: "```" + answer7_1 + "```"
},
{
name: rq8,
value: "```" + answer8_1 + "```"
}
],
footer: {
iconURL: guild.iconURL(),
text: "ID: " + user.id
{
name: rq2,
value: "```" + answer2_1 + "```"
},
{
name: rq3,
value: "```" + answer3_1 + "```"
},
{
name: rq4,
value: "```" + answer4_1 + "```"
},
{
name: rq5,
value: "```" + answer5_1 + "```"
},
{
name: rq6,
value: "```" + answer6_1 + "```"
},
{
name: rq7,
value: "```" + answer7_1 + "```"
},
{
name: rq8,
value: "```" + answer8_1 + "```"
}
}],
components: [
new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId("guildapplicationaccept")
.setLabel("Accept")
.setStyle(ButtonStyle.Primary)
),
new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId("guildapplicationdeny")
.setLabel("Deny")
.setStyle(ButtonStyle.Danger)
),
new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId("checkstats")
.setLabel("Check Stats")
.setStyle(ButtonStyle.Secondary)
)
]
});
],
footer: {
iconURL: guild.iconURL(),
text: "ID: " + user.id
}
}],
components: [
new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId("guildapplicationaccept")
.setLabel("Accept")
.setStyle(ButtonStyle.Primary),
new ButtonBuilder()
.setCustomId("guildapplicationdeny")
.setLabel("Deny")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId("checkstats")
.setLabel("Check Stats")
.setStyle(ButtonStyle.Secondary)
)
]
});
})
}
}
}

View File

@@ -1,5 +1,7 @@
const { ActionRowBuilder, ButtonStyle, ButtonBuilder } = require('discord.js');
const { color } = require('../../config/options.json');
const fs = require('fs');
const path = require('path');
module.exports = {
name: 'guildapplicationaccept',
@@ -8,14 +10,41 @@ module.exports = {
async execute(interaction) {
await interaction.deferReply();
const user = interaction.user;
const channel = interaction.channel;
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;
const applicationFile = require(`../../apps/guild/${applicantId}`);
await message.edit({
components: [
new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId("guildapplicationaccept")
.setLabel("Accept")
.setStyle(ButtonStyle.Primary)
.setDisabled(true),
new ButtonBuilder()
.setCustomId("guildapplicationdeny")
.setLabel("Deny")
.setStyle(ButtonStyle.Danger)
.setDisabled(true),
new ButtonBuilder()
.setCustomId("checkstats")
.setLabel("Check Stats")
.setStyle(ButtonStyle.Secondary)
.setDisabled(true)
)
]
});
await applicant.send({
embeds: [{
@@ -24,43 +53,12 @@ module.exports = {
}]
});
const message = await channel.messages.fetch({ limit: 1 });
const messageID = message.first().id;
fs.rmSync(applicationFile)
await channel.messages.fetch(messageID).then(async (message) => {
await message.edit({
components: [
new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId("guildapplicationaccept")
.setLabel("Accept")
.setStyle(ButtonStyle.Primary)
.setDisabled(true)
),
new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId("guildapplicationdeny")
.setLabel("Deny")
.setStyle(ButtonStyle.Danger)
.setDisabled(true)
),
new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId("checkstats")
.setLabel("Check Stats")
.setStyle(ButtonStyle.Secondary)
.setDisabled(true)
)
]
});
});
await interaction.reply({
await interaction.editReply({
embeds: [{
title: applicantUsername + " - Guild Application",
description: "Application accepted by <@" + user.id + ">.\n\nPress the button below to delete this channel.\n**When the user is added to the guild.**",
description: "Application has been accepted by <@" + user.id + ">.",
color: embedColor,
thumbnail: {
url: applicant.avatarURL()
@@ -69,15 +67,7 @@ module.exports = {
iconURL: guild.iconURL(),
text: "ID: " + applicant.id
}
}],
components: [
new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId("applicationdelete")
.setLabel("Delete channel")
.setStyle(ButtonStyle.Danger)
)
]
}]
});
}

View File

@@ -14,8 +14,7 @@ module.exports = {
const guild = interaction.guild;
const embedColor = Number(color.replace("#", "0x"));
const applicantId = await channel.topic
const applicant = await guild.members.fetch(applicantId)
const message = interaction.message;
const modal = new ModalBuilder()
.setTitle('Deny Reason')