Adding staff apply
This commit is contained in:
@@ -448,7 +448,7 @@ module.exports = {
|
|||||||
await user.deleteDM();
|
await user.deleteDM();
|
||||||
|
|
||||||
await guild.channels.create({
|
await guild.channels.create({
|
||||||
name: `Application-${user.username}`,
|
name: `guild-app-${user.username}`,
|
||||||
type: ChannelType.GuildText,
|
type: ChannelType.GuildText,
|
||||||
topic: user.id,
|
topic: user.id,
|
||||||
permissionOverwrites: [
|
permissionOverwrites: [
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ module.exports = {
|
|||||||
|
|
||||||
async execute(interaction) {
|
async execute(interaction) {
|
||||||
|
|
||||||
await interaction.deferReply();
|
|
||||||
|
|
||||||
const user = interaction.user;
|
const user = interaction.user;
|
||||||
const channel = interaction.channel;
|
const channel = interaction.channel;
|
||||||
const guild = interaction.guild;
|
const guild = interaction.guild;
|
||||||
@@ -26,8 +24,6 @@ module.exports = {
|
|||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
|
||||||
// fetch the first message in the channel and disable the buttons on it
|
|
||||||
|
|
||||||
const message = await channel.messages.fetch({ limit: 1 });
|
const message = await channel.messages.fetch({ limit: 1 });
|
||||||
const messageID = message.first().id;
|
const messageID = message.first().id;
|
||||||
|
|
||||||
@@ -61,9 +57,9 @@ module.exports = {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await interaction.editReply({
|
await interaction.reply({
|
||||||
embeds: [{
|
embeds: [{
|
||||||
title: applicantUsername + " - Application",
|
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 accepted by <@" + user.id + ">.\n\nPress the button below to delete this channel.\n**When the user is added to the guild.**",
|
||||||
color: embedColor,
|
color: embedColor,
|
||||||
thumbnail: {
|
thumbnail: {
|
||||||
|
|||||||
80
events/buttons/staffapplicationaccept.js
Normal file
80
events/buttons/staffapplicationaccept.js
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
|
||||||
|
const { color } = require('../../config/options.json');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'staffapplicationaccept',
|
||||||
|
description: 'Accept a staff application.',
|
||||||
|
type: 'button',
|
||||||
|
|
||||||
|
async execute(interaction) {
|
||||||
|
|
||||||
|
const user = interaction.user;
|
||||||
|
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 applicantUsername = applicant.user.username + "#" + applicant.user.discriminator;
|
||||||
|
|
||||||
|
await applicant.send({
|
||||||
|
embeds: [{
|
||||||
|
description: `Your application for the Illegitimate staff team has been accepted.`,
|
||||||
|
color: embedColor
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
|
||||||
|
// 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(
|
||||||
|
new ButtonBuilder()
|
||||||
|
.setCustomId("staffapplicationaccept")
|
||||||
|
.setLabel("Accept")
|
||||||
|
.setStyle(ButtonStyle.Primary)
|
||||||
|
.setDisabled(true)
|
||||||
|
),
|
||||||
|
new ActionRowBuilder().addComponents(
|
||||||
|
new ButtonBuilder()
|
||||||
|
.setCustomId("staffapplicationdeny")
|
||||||
|
.setLabel("Deny")
|
||||||
|
.setStyle(ButtonStyle.Danger)
|
||||||
|
.setDisabled(true)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
await interaction.reply({
|
||||||
|
embeds: [{
|
||||||
|
title: applicantUsername + " - Staff Application.",
|
||||||
|
description: "Application accepted by <@" + user.id + ">.\n\n" +
|
||||||
|
"Press the button below to delete this channel.\n" +
|
||||||
|
"**When the user was given their role**",
|
||||||
|
color: embedColor,
|
||||||
|
thumbnail: {
|
||||||
|
url: applicant.avatarURL()
|
||||||
|
},
|
||||||
|
footer: {
|
||||||
|
iconurl: guild.iconURL(),
|
||||||
|
text: "ID: " + applicantId
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
components: [
|
||||||
|
new ActionRowBuilder().addComponents(
|
||||||
|
new ButtonBuilder()
|
||||||
|
.setCustomId("staffapplicationdelete")
|
||||||
|
.setLabel("Delete channel")
|
||||||
|
.setStyle(ButtonStyle.Danger)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
28
events/buttons/staffapplicationdelete.js
Normal file
28
events/buttons/staffapplicationdelete.js
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
35
events/buttons/staffapplicationdeny.js
Normal file
35
events/buttons/staffapplicationdeny.js
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
const { ModalBuilder, ActionRowBuilder, TextInputBuilder, TextInputStyle } = require('discord.js');
|
||||||
|
const { color } = require('../../config/options.json');
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'staffapplicationdeny',
|
||||||
|
description: 'Deny a guild application.',
|
||||||
|
type: 'button',
|
||||||
|
|
||||||
|
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')
|
||||||
|
.setComponents(
|
||||||
|
new ActionRowBuilder().setComponents(
|
||||||
|
new TextInputBuilder()
|
||||||
|
.setLabel('Deny Reason')
|
||||||
|
.setCustomId('staffdenyreason')
|
||||||
|
.setStyle(TextInputStyle.Paragraph)
|
||||||
|
.setPlaceholder('Enter a reason for denying the application')
|
||||||
|
.setRequired(false)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
await interaction.showModal(modal);
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -22,20 +22,21 @@ module.exports = {
|
|||||||
const userRoles = interaction.member.roles.cache;
|
const userRoles = interaction.member.roles.cache;
|
||||||
const mojangAPI = "https://api.mojang.com/users/profiles/minecraft/"
|
const mojangAPI = "https://api.mojang.com/users/profiles/minecraft/"
|
||||||
|
|
||||||
|
|
||||||
if (!userRoles.has(guildRole)) {
|
|
||||||
await interaction.reply({content: "You must be a member of the guild to apply for staff.", ephemeral: true});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (userRoles.has(guildStaff)) {
|
|
||||||
await interaction.reply({content: "You are already a staff member.", ephemeral: true});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (interaction.customId === "staffapply") {
|
if (interaction.customId === "staffapply") {
|
||||||
|
|
||||||
const applicationFile = path.join(__dirname, '../../staffapplications/' + user.id);
|
await interaction.deferReply({ ephemeral: true });
|
||||||
|
|
||||||
|
// if (!userRoles.has(guildRole)) {
|
||||||
|
// await interaction.editReply({content: "You must be a member of the guild to apply for staff.", ephemeral: true});
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (userRoles.has(guildStaff)) {
|
||||||
|
// 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)) {
|
if (fs.existsSync(applicationFile)) {
|
||||||
await interaction.reply({ content: "You already have an application in progress.", ephemeral: true });
|
await interaction.editReply({ content: "You already have an application in progress.", ephemeral: true });
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,11 +63,11 @@ module.exports = {
|
|||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await interaction.reply({ content: "Please enable your DMs.", ephemeral: true });
|
await interaction.editReply({ content: "Please enable your DMs.", ephemeral: true });
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
await interaction.reply({ content: "Please check your DMs.", ephemeral: true})
|
await interaction.editReply({ content: "Please check your DMs.", ephemeral: true})
|
||||||
|
|
||||||
const input = await user.dmChannel.awaitMessages({
|
const input = await user.dmChannel.awaitMessages({
|
||||||
filter: m => m.author.id === user.id,
|
filter: m => m.author.id === user.id,
|
||||||
@@ -364,14 +365,14 @@ module.exports = {
|
|||||||
const userCheck = await fetch(mojangAPI + answer1_1)
|
const userCheck = await fetch(mojangAPI + answer1_1)
|
||||||
const uuid = userCheck.data.id
|
const uuid = userCheck.data.id
|
||||||
|
|
||||||
fs.writeFile(`./applications/${user.id}`, uuid, function (err) {
|
fs.writeFile(`./apps/staff/${user.id}`, uuid, function (err) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
});
|
});
|
||||||
|
|
||||||
await user.deleteDM();
|
await user.deleteDM();
|
||||||
|
|
||||||
await guild.channels.create({
|
await guild.channels.create({
|
||||||
name: `Application-${user.username}`,
|
name: `staff-app-${user.username}`,
|
||||||
type: ChannelType.GuildText,
|
type: ChannelType.GuildText,
|
||||||
topic: user.id,
|
topic: user.id,
|
||||||
permissionOverwrites: [
|
permissionOverwrites: [
|
||||||
|
|||||||
@@ -9,14 +9,12 @@ module.exports = {
|
|||||||
type: 'modal',
|
type: 'modal',
|
||||||
|
|
||||||
async execute(interaction) {
|
async execute(interaction) {
|
||||||
|
|
||||||
if (interaction.type === InteractionType.ApplicationCommand) return;
|
|
||||||
|
|
||||||
interaction.deferReply();
|
|
||||||
|
|
||||||
if (interaction.type !== InteractionType.ModalSubmit) return;
|
if (interaction.type !== InteractionType.ModalSubmit) return;
|
||||||
if (interaction.customId !== "denyreasonbox") return;
|
if (interaction.customId !== "denyreasonbox") return;
|
||||||
|
|
||||||
|
interaction.deferReply();
|
||||||
|
|
||||||
const channel = interaction.channel;
|
const channel = interaction.channel;
|
||||||
const applicantId = channel.topic;
|
const applicantId = channel.topic;
|
||||||
const guild = interaction.guild;
|
const guild = interaction.guild;
|
||||||
|
|||||||
46
events/modals/staffdenyreasonbox.js
Normal file
46
events/modals/staffdenyreasonbox.js
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
const { InteractionType, EmbedBuilder } = require('discord.js');
|
||||||
|
const { color } = require('../../config/options.json');
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'staffdenyreasonbox',
|
||||||
|
description: 'Deny reason box.',
|
||||||
|
type: 'modal',
|
||||||
|
|
||||||
|
async execute(interaction) {
|
||||||
|
|
||||||
|
if (interaction.type !== InteractionType.ModalSubmit) return;
|
||||||
|
if (interaction.customId !== "staffdenyreasonbox") return;
|
||||||
|
|
||||||
|
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 dmMessage = new EmbedBuilder()
|
||||||
|
.setDescription("Your application for the Illegitimate guild staff has been denied\n" +
|
||||||
|
"**Reason:** `" + reason + "`")
|
||||||
|
.setColor(embedColor);
|
||||||
|
|
||||||
|
await applicant.send({ embeds: [dmMessage] });
|
||||||
|
|
||||||
|
await interaction.editReply({
|
||||||
|
embeds: [{
|
||||||
|
description: "Application denied\n" +
|
||||||
|
"Channel will be deleted in 5 seconds...",
|
||||||
|
color: embedColor
|
||||||
|
}],
|
||||||
|
});
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
fs.rmSync(filePath, { force: true });
|
||||||
|
channel.delete();
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user