jellyfin-discord-bot/server/commands/guides.ts

84 lines
3.3 KiB
TypeScript
Raw Permalink Normal View History

2023-06-09 16:16:23 +02:00
2023-06-09 22:01:38 +02:00
import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from 'discord.js'
2023-06-09 16:16:23 +02:00
import { v4 as uuid } from 'uuid'
2023-06-09 21:30:24 +02:00
import { accountChoice, joingroup, leavegroup, loginScreen, overview, resume, serverConnection, splashScreen, startScreen } from '../assets/attachments'
2023-06-09 22:01:38 +02:00
import { logger } from '../logger'
import { Command } from '../structures/command'
import { RunOptions } from '../types/commandTypes'
import { configureServer, explainRole, installation, loginInfo, useSyncgroup } from './mitgucken'
2023-06-09 16:16:23 +02:00
export default new Command({
2023-06-24 21:09:56 +02:00
name: 'guides',
description: 'Bekomme eine Auswahl von Guides per DM',
options: [],
run: async (interaction: RunOptions) => {
const requestId = uuid()
const guildId = interaction.interaction.guild?.id
logger.info(`Starting guides interaction for user ${interaction.interaction.user.id}`, { requestId, guildId })
const mediaPlayerGuideButton = new ButtonBuilder()
.setCustomId('jfInstallation')
.setLabel('Media Player Installation')
.setStyle(ButtonStyle.Primary)
const accountSetupGuideButton = new ButtonBuilder()
.setCustomId('configureServer')
.setLabel('Server einstellen')
.setStyle(ButtonStyle.Primary)
const loginGuideButton = new ButtonBuilder()
.setCustomId('login')
.setLabel('Einloggen')
.setStyle(ButtonStyle.Primary)
const useSyncGroupGuideButton = new ButtonBuilder()
.setCustomId('useSyncGroup')
.setLabel('Watch Parties nutzen')
.setStyle(ButtonStyle.Primary)
const roleExplanationButton = new ButtonBuilder()
.setCustomId('explainRoles')
.setLabel('Wie bekomme ich Zugang')
.setStyle(ButtonStyle.Primary)
const row = new ActionRowBuilder<ButtonBuilder>()
.addComponents(mediaPlayerGuideButton, accountSetupGuideButton, loginGuideButton, useSyncGroupGuideButton, roleExplanationButton)
//const userDMchannel = await interaction.interaction.user.createDM()
const response = await interaction.interaction.followUp({
content: `Hier ist eine Auswahl von Guides.`,
components: [row]
})
try {
const guideSelection = await response.awaitMessageComponent({ time: 60_000 })
if (guideSelection.customId === 'jfInstallation') {
const userDMChannel = await guideSelection.user.createDM()
userDMChannel.send({ embeds: installation(), files: [splashScreen] })
} else if (guideSelection.customId === 'configureServer') {
const userDMChannel = await guideSelection.user.createDM()
userDMChannel.send({ embeds: configureServer(), files: [startScreen, serverConnection] })
} else if (guideSelection.customId === 'login') {
const userDMChannel = await guideSelection.user.createDM()
userDMChannel.send({ embeds: loginInfo(), files: [accountChoice, loginScreen] })
} else if (guideSelection.customId === 'useSyncGroup') {
const userDMChannel = await guideSelection.user.createDM()
userDMChannel.send({ embeds: useSyncgroup(), files: [overview, joingroup, resume, leavegroup] })
} else if (guideSelection.customId === 'explainRoles') {
const userDMChannel = await guideSelection.user.createDM()
userDMChannel.send({ embeds: explainRole() })
}
guideSelection.update({ content: "Hab ich dir per DM geschickt :)", components: [] })
} catch (error) {
await interaction.interaction.editReply({ content: 'Das dauert mir zu lange, frag mich nochmal wenn du nen Guide brauchst', components: [] });
}
}
2023-06-09 16:16:23 +02:00
})