Fixed guild apply

This commit is contained in:
2023-03-13 12:26:31 +01:00
parent a4e3035806
commit b9b0102e42

View File

@@ -16,9 +16,7 @@ module.exports = {
if (interaction.customId === 'guildapply') { 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); const applicationFile = path.join(__dirname, '../../applications/' + 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.reply({ content: "You already have an application in progress.", ephemeral: true });
return return
@@ -27,17 +25,11 @@ module.exports = {
const tooLong = new EmbedBuilder() const tooLong = new EmbedBuilder()
.setDescription("You took too long to respond.") .setDescription("You took too long to respond.")
.setColor(embedColor) .setColor(embedColor)
const cancelled = new EmbedBuilder() const cancelled = new EmbedBuilder()
.setDescription("You have cancelled your application.") .setDescription("You have cancelled your application.")
.setColor(embedColor) .setColor(embedColor)
await interaction.reply({ content: "Please check your DMs.", ephemeral: true}) try {
if (!user.dmChannel) {
await user.createDM();
}
await user.send({ await user.send({
embeds: [{ embeds: [{
title: 'Guild Application', title: 'Guild Application',
@@ -45,7 +37,14 @@ module.exports = {
"If you wish to cancel your application, please press the button below or type `cancel`.", "If you wish to cancel your application, please press the button below or type `cancel`.",
color: embedColor, color: embedColor,
}] }]
}); })
} catch (error) {
await interaction.reply({ content: "Please enable your DMs.", ephemeral: true });
return
}
await interaction.reply({ 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,
@@ -229,6 +228,8 @@ module.exports = {
if (err) throw err; if (err) throw err;
}); });
await user.deleteDM();
await guild.channels.create({ await guild.channels.create({
name: `Application-${user.username}`, name: `Application-${user.username}`,
type: ChannelType.GuildText, type: ChannelType.GuildText,