Adding apply channel
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
const { ChannelType, PermissionFlagsBits, ButtonBuilder, ButtonStyle, ActionRowBuilder } = require('discord.js');
|
||||||
const { color } = require('../../options.json');
|
const { color } = require('../../options.json');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
@@ -13,9 +14,83 @@ module.exports = {
|
|||||||
|
|
||||||
if (interaction.customId === 'guildapply') {
|
if (interaction.customId === 'guildapply') {
|
||||||
|
|
||||||
await interaction.reply({ content: 'Please wait...', ephemeral: true });
|
interaction.guild.channels.create({
|
||||||
|
name: `application-${user.username}`,
|
||||||
|
type: ChannelType.GuildText,
|
||||||
|
permissionOverwrites: [
|
||||||
|
{
|
||||||
|
id: user.id,
|
||||||
|
allow: [PermissionFlagsBits.ViewChannel]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: guild.roles.everyone,
|
||||||
|
deny: [PermissionFlagsBits.ViewChannel]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
}).then(async channel => {
|
||||||
|
|
||||||
|
await channel.send({
|
||||||
|
embeds: [{
|
||||||
|
title: 'Guild Application',
|
||||||
|
description: "Please answer the following questions to apply for the guild.\n" +
|
||||||
|
"If you wish to cancel your application, please press the button below or type `cancel`.",
|
||||||
|
color: embedColor,
|
||||||
|
}],
|
||||||
|
|
||||||
|
components: [
|
||||||
|
new ActionRowBuilder().addComponents(
|
||||||
|
new ButtonBuilder()
|
||||||
|
.setCustomId('guildapplycancel')
|
||||||
|
.setLabel('Cancel')
|
||||||
|
.setStyle(ButtonStyle.Danger)
|
||||||
|
.setEmoji({ name: '❌' })
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
const input = await channel.awaitMessages({
|
||||||
|
filter: m => m.author.id === user.id,
|
||||||
|
max: 1,
|
||||||
|
time: 1000 * 60
|
||||||
|
});
|
||||||
|
|
||||||
|
if (input.size === 0) {
|
||||||
|
await channel.delete();
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (input.first().content.toLowerCase() !== 'yes') {
|
||||||
|
await channel.delete();
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const question1 = await channel.send("1st")
|
||||||
|
const answer1 = await channel.awaitMessages({
|
||||||
|
filter: m => m.author.id === user.id,
|
||||||
|
max: 1,
|
||||||
|
time: 1000 * 60 * 5
|
||||||
|
});
|
||||||
|
|
||||||
|
if (answer1.size === 0) {
|
||||||
|
await channel.delete();
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (answer1.first().content.toLowerCase() === 'cancel') {
|
||||||
|
await channel.delete();
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const answer1_1 = answer1.first().content
|
||||||
|
|
||||||
|
console.log(answer1_1)
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
await interaction.reply({ content: 'Application channel created', ephemeral: true });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
27
events/buttons/guildapplycancel.js
Normal file
27
events/buttons/guildapplycancel.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
const { color } = require('../../options.json');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'guildapplycancel',
|
||||||
|
description: 'Guild application cancel button.',
|
||||||
|
type: 'button',
|
||||||
|
|
||||||
|
async execute(interaction) {
|
||||||
|
|
||||||
|
const user = interaction.user;
|
||||||
|
const guild = interaction.guild;
|
||||||
|
const embedColor = Number(color.replace("#", "0x"));
|
||||||
|
|
||||||
|
if (interaction.customId === 'guildapplycancel') {
|
||||||
|
|
||||||
|
const channel = interaction.channel;
|
||||||
|
|
||||||
|
await interaction.reply({ content: 'Application channel will be deleted in 5 seconds', ephemeral: true });
|
||||||
|
|
||||||
|
setTimeout(async () => {
|
||||||
|
await channel.delete();
|
||||||
|
}, 5000);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user