Skip to content

Commit

Permalink
final commit
Browse files Browse the repository at this point in the history
  • Loading branch information
johan-t committed Oct 29, 2023
1 parent e017b87 commit 907f293
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
10 changes: 6 additions & 4 deletions commands/match-command.ts
@@ -1,14 +1,14 @@
import { db } from '../common';
import 'dotenv/config';
import { questions } from '../questions';
import { sendQuestion } from './test-command';
import { initiateConversation, sendQuestion } from './test-command';
import { decrypt } from '../encryptionUtils';
import { ChatInputCommandInteraction } from "discord.js";

export async function executeMatch(interaction: ChatInputCommandInteraction) {

const userContext = await db.db('contrabot').collection("users").findOne({ userId: interaction.user.id });

const userResponses = userContext?.userVector || [];
const userResponses = userContext?.userVector ? JSON.parse(decrypt(userContext.userVector)) : [];

// checks if the user has answered the test
// if not, an error hint is displayed
Expand All @@ -17,12 +17,14 @@ export async function executeMatch(interaction: ChatInputCommandInteraction) {
content: 'Neues Match wird ermittelt. Bitte schaue in deinen Direktnachrichten nach :)',
ephemeral: true,
});
sendQuestion(interaction);

initiateConversation(interaction, userResponses);
} else {
await interaction.reply({
content: 'Bitte beantworte den Meinungstest vollständig, bevor du mit Anderen gematcht werden kannst! Bitte nutze dazu den Befehl `/test`.',
ephemeral: true,
});
sendQuestion(interaction);
console.log('Invalid userVector: test was not completed!');
}
};
4 changes: 2 additions & 2 deletions commands/test-command.ts
Expand Up @@ -194,7 +194,7 @@ export async function sendQuestion(interaction: any) {
);
}

async function initiateConversation(interaction: any, userResponses: number[]): Promise<any> {
export async function initiateConversation(interaction: any, userResponses: number[]): Promise<any> {
const guild = client.guilds.cache.get(process.env.GUILD_ID!)!;

const bestMatchId = await findMatchingUser(interaction.user.id, userResponses);
Expand Down Expand Up @@ -272,7 +272,7 @@ async function initiateConversation(interaction: any, userResponses: number[]):
}

function verifyUser(interaction: any, guild: Guild) {
const role: Role | undefined = guild.roles.cache.get('1153647196449820755'); // Verified role: 1143590879274213486
const role: Role | undefined = guild.roles.cache.get('1143590879274213486'); // Verified role: 1143590879274213486
if (!role) throw new Error('Role not found');

const interactionGuildMember = guild.members.cache.get(interaction.user.id);
Expand Down
4 changes: 2 additions & 2 deletions questions.ts
@@ -1,5 +1,5 @@
export const questions = [
/*{ question: 'Auf allen Autobahnen soll ein generelles Tempolimit gelten.', tag: ['Verkehrssicherheit', ' Klimawandel'] },
{ question: 'Auf allen Autobahnen soll ein generelles Tempolimit gelten.', tag: ['Verkehrssicherheit', ' Klimawandel'] },
{ question: 'Deutschland soll seine Verteidigungsausgaben erhöhen.', tag: 'Verteidigungspolitik' },
{ question: 'Bei Bundestagswahlen sollen auch Jugendliche ab 16 Jahren wählen dürfen.', tag: ['Wahlalter', 'Demokratie'] },
{ question: 'Die Förderung von Windenenergie soll beendet werden?', tag: ['Energiepolitik', 'Klimawandel'] },
Expand Down Expand Up @@ -30,7 +30,7 @@ export const questions = [
{ question: 'Bei der Videoüberwachung öffentlicher Plätze soll Gesichtserkennungssoftware eingesetzt werden dürfen.', tag: ['Datenschutz', 'Videoüberwachung'] },
{ question: 'Auch Ehepaare ohne Kinder sollen weiterhin steuerlich begünstigt werden.', tag: 'Familienpolitik' },
{ question: 'Ökologische Landwirtschaft soll stärker gefördert werden als konventionelle Landwirtschaft.', tag: 'Klimawandel' },
*/{ question: 'Islamische Verbände sollen als Religionsgemeinschaften staatlich anerkannt werden können.', tag: ['Religionspolitik', 'Minderheitenpolitik'] },
{ question: 'Islamische Verbände sollen als Religionsgemeinschaften staatlich anerkannt werden können.', tag: ['Religionspolitik', 'Minderheitenpolitik'] },
{ question: 'Der staatlich festgelegte Preis für den Ausstoß von CO2 beim Heizen und Autofahren soll stärker steigen als geplant.', tag: ['Klimaschutz', 'Klimawandel'] },
{ question: 'Die Schuldenbremse im Grundgesetz soll beibehalten werden.', tag: 'Wirtschaftspolitik' },
{ question: 'Asyl soll weiterhin nur politisch Verfolgten gewährt werden.', tag: 'Migrationspolitik' },
Expand Down

0 comments on commit 907f293

Please sign in to comment.