diff --git a/commands/test/test-command.ts b/commands/test/test-command.ts index 998b9c1..3560b57 100644 --- a/commands/test/test-command.ts +++ b/commands/test/test-command.ts @@ -44,6 +44,8 @@ const questions = [ { question: 'Unternehmen sollen selbst entscheiden, ob sie ihren Beschäftigten das Arbeiten im Homeoffice erlauben.', tag: ['Arbeitsrecht', 'Digitalisierung'] }, ]; +const specificQuestionMessage = {} as { [key: string]: any} + const checkForFeedbackRequests = async () => { const now = new Date(); const oneWeekAgo = new Date(now.getTime() - (7 * 24 * 60 * 60 * 1000)); @@ -108,7 +110,7 @@ export const sendTestButton = async () => { const guild: Guild | undefined = client.guilds.cache.get(guildId); if (!guild) throw new Error('Guild not found'); - (guild.channels.cache.get("1135557183845711983") as TextChannel).send({ components: [actionRow] }); // Channel Id for #How-to-basics + (guild.channels.cache.get("1135557183845711983") as TextChannel).send({ components: [actionRow] }); // Channel Id for #How-to-basics; main sever: 1135557183845711983; test sever: 1159905209414332526 }; @@ -175,6 +177,7 @@ export const sendQuestion = async (interaction: any) => { if (currentQuestionIndex === 0) { userResponses = []; + interaction.user.send("Bitte beantworte die folgenden Fragen. 🤗 Du kannst auf eine Frage immer nur einmal antworten: 😉") } if (currentQuestionIndex < questions.length) { @@ -198,11 +201,13 @@ export const sendQuestion = async (interaction: any) => { .setEmoji("👎"), ]); - interaction.user.send({ + const questionMessage = await interaction.user.send({ embeds: [embed], components: [builder] }); + specificQuestionMessage[interaction.user.id] = questionMessage; + // Update context for this user in the database await db.db('contrabot').collection("users").updateOne( @@ -289,6 +294,7 @@ export const sendQuestion = async (interaction: any) => { } } + async function conversationStarter(channelOfDestination: any, interaction: any, bestMatch: number[], user: number[]) { // get all contrasting and similar answers @@ -417,3 +423,4 @@ export const execute = async (interaction: any) => { sendQuestion(interaction); }; +export { specificQuestionMessage } \ No newline at end of file diff --git a/index.ts b/index.ts index e73e9bb..0fd1877 100644 --- a/index.ts +++ b/index.ts @@ -1,6 +1,6 @@ import 'dotenv/config' import { Events } from 'discord.js'; -import { sendQuestion, sendTestButton } from './commands/test/test-command'; +import { sendQuestion, sendTestButton, specificQuestionMessage } from './commands/test/test-command'; import { sendSurveyQuestions, Feedbackquestions } from './startSurvey'; import * as fs from 'fs'; import path from 'path' @@ -107,6 +107,7 @@ client.on(Events.InteractionCreate, async (interaction) => { } ); + specificQuestionMessage[interaction.user.id].delete(); await interaction.deferUpdate(); sendQuestion(interaction); }