-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add modal for additional information input and update message handling
- Loading branch information
Showing
5 changed files
with
153 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
const { ModalBuilder, TextInputBuilder, TextInputStyle, ActionRowBuilder } = require('@discordjs/builders'); | ||
|
||
module.exports = { | ||
button: { | ||
name: "info_" | ||
}, | ||
run: async (client, interaction, prisma) => { | ||
// Create the modal | ||
const modal = new ModalBuilder() | ||
.setCustomId(interaction.customId) | ||
.setTitle('Zusätzliche Informationen'); | ||
|
||
//boolean input "3D-View benutzt" | ||
const input1 = new TextInputBuilder() | ||
.setCustomId('3d_view') | ||
.setLabel('3D-View benutzt') | ||
.setPlaceholder('Ja/Nein') | ||
.setStyle(TextInputStyle.DEFAULT); | ||
|
||
//boolean input "Street-View benutzt" | ||
const input2 = new TextInputBuilder() | ||
.setCustomId('street_view') | ||
.setLabel('Street-View benutzt') | ||
.setPlaceholder('Ja/Nein') | ||
.setStyle(TextInputStyle.DEFAULT); | ||
|
||
//text input "Link zu Street-View" | ||
const input3 = new TextInputBuilder() | ||
.setCustomId('street_view_link') | ||
.setLabel('Link zu Street-View') | ||
.setPlaceholder('Link') | ||
.setStyle(TextInputStyle.DEFAULT); | ||
|
||
//text input "Sonstige Informationen" | ||
const input4 = new TextInputBuilder() | ||
.setCustomId('other_info') | ||
.setLabel('Sonstige Informationen') | ||
.setPlaceholder('Informationen') | ||
.setStyle(TextInputStyle.DEFAULT); | ||
|
||
|
||
// Add inputs to the modal | ||
modal.addComponents( | ||
new ActionRowBuilder().addComponents(input1), | ||
new ActionRowBuilder().addComponents(input2), | ||
new ActionRowBuilder().addComponents(input3), | ||
new ActionRowBuilder().addComponents(input4) | ||
); | ||
|
||
// Show the modal to the user | ||
await interaction.showModal(modal); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
module.exports = { | ||
modal: { | ||
name: "info_" | ||
}, | ||
run: async (client, interaction, prisma) => { | ||
//handle modal submit | ||
//add information to judge_msg in discord | ||
//get judge_msg | ||
const judge_msg = await prisma.build.findUnique({ | ||
where: { | ||
id: interaction.customId.split("_")[1] | ||
} | ||
}); | ||
|
||
//get the message | ||
const message = await client.channels.cache.get(process.env.JUDGE_CHANNEL).messages.fetch(judge_msg.judge_msg.toString()); | ||
let newMessage = message; | ||
message.embeds[0].fields.push({ | ||
name: "Zusätzliche Informationen", | ||
value: interaction.values.map((v) => { | ||
switch(v.customId) { | ||
case "3d_view": | ||
return `3D-View benutzt: ${v.value}`; | ||
case "street_view": | ||
return `Street-View benutzt: ${v.value}`; | ||
case "street_view_link": | ||
return `Link zu Street-View: ${v.value}`; | ||
case "other_info": | ||
return `Sonstige Informationen: ${v.value}`; | ||
} | ||
}).join("\n") | ||
}); | ||
|
||
//edit the message | ||
message.edit( | ||
{ | ||
content: newMessage.content, | ||
embeds: newMessage.embeds | ||
} | ||
) | ||
|
||
} | ||
} |