Updating to add defer reply

This commit is contained in:
2023-03-19 13:53:00 +01:00
parent 02ae88ad64
commit c9cc8e4e52
5 changed files with 20 additions and 14 deletions

View File

@@ -8,14 +8,16 @@ module.exports = {
async execute(interaction) { async execute(interaction) {
await interaction.deferReply();
const channel = interaction.channel; const channel = interaction.channel;
const applicantId = await channel.topic; const applicantId = await channel.topic;
await interaction.reply('Application channel will be deleted in 5 seconds'); await interaction.editReply('Application channel will be deleted in 5 seconds');
setTimeout(async () => { setTimeout(async () => {
const filePath = path.join(__dirname, `../../applications/${applicantId}`); const filePath = path.join(__dirname, `../../apps/guild/${applicantId}`);
fs.rmSync(filePath, { force: true }); fs.rmSync(filePath, { force: true });
await channel.delete(); await channel.delete();

View File

@@ -16,7 +16,7 @@ module.exports = {
const channel = interaction.channel; const channel = interaction.channel;
const applicantId = await channel.topic const applicantId = await channel.topic
const filePath = path.join(__dirname, `../../applications/${applicantId}`); const filePath = path.join(__dirname, `../../apps/guild/${applicantId}`);
const uuid = fs.readFileSync(filePath, 'utf8'); const uuid = fs.readFileSync(filePath, 'utf8');
@@ -42,7 +42,7 @@ module.exports = {
return return
} }
await interaction.reply({ await interaction.editReply({
embeds: [{ embeds: [{
title: stats.data.username, title: stats.data.username,
description: "**Network Level:** `" + stats.data.level.toString() + "`\n" + description: "**Network Level:** `" + stats.data.level.toString() + "`\n" +

View File

@@ -31,9 +31,11 @@ module.exports = {
if (interaction.customId === 'guildapply') { if (interaction.customId === 'guildapply') {
const applicationFile = path.join(__dirname, '../../applications/' + user.id); await interaction.deferReply();
const applicationFile = path.join(__dirname, '../../apps/guild/' + 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
} }
@@ -60,11 +62,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({
@@ -439,7 +441,7 @@ 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/guild/${user.id}`, uuid, function (err) {
if (err) throw err; if (err) throw err;
}); });

View File

@@ -61,7 +61,7 @@ module.exports = {
}); });
await interaction.reply({ await interaction.editReply({
embeds: [{ embeds: [{
title: applicantUsername + " - Application", title: applicantUsername + " - 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.**",
@@ -78,7 +78,7 @@ module.exports = {
new ActionRowBuilder().addComponents( new ActionRowBuilder().addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId("applicationdelete") .setCustomId("applicationdelete")
.setLabel("Delete Channel") .setLabel("Delete channel")
.setStyle(ButtonStyle.Danger) .setStyle(ButtonStyle.Danger)
) )
] ]

View File

@@ -10,6 +10,8 @@ module.exports = {
async execute(interaction) { async execute(interaction) {
interaction.deferReply();
if (interaction.type !== InteractionType.ModalSubmit) return; if (interaction.type !== InteractionType.ModalSubmit) return;
if (interaction.customId !== "denyreasonbox") return; if (interaction.customId !== "denyreasonbox") return;
@@ -19,7 +21,7 @@ module.exports = {
const applicant = await guild.members.fetch(applicantId); const applicant = await guild.members.fetch(applicantId);
const reason = interaction.fields.fields.get('denyreason').value || "No reason provided"; const reason = interaction.fields.fields.get('denyreason').value || "No reason provided";
const embedColor = Number(color.replace("#", "0x")); const embedColor = Number(color.replace("#", "0x"));
const filePath = path.join(__dirname, `../../applications/${applicantId}`); const filePath = path.join(__dirname, `../../apps/guild/${applicantId}`);
const dmMessage = new EmbedBuilder() const dmMessage = new EmbedBuilder()
.setDescription("Your application for the Illegitimate guild has been denied\n" + .setDescription("Your application for the Illegitimate guild has been denied\n" +
@@ -28,7 +30,7 @@ module.exports = {
await applicant.send({ embeds: [dmMessage] }); await applicant.send({ embeds: [dmMessage] });
await interaction.reply({ await interaction.editReply({
embeds: [{ embeds: [{
description: "Application denied\n" + description: "Application denied\n" +
"Channel will be deleted in 5 seconds...", "Channel will be deleted in 5 seconds...",