initialize attachmentImages ahead of time, to be reused
This commit is contained in:
parent
0ba867b23a
commit
0aef525994
3
index.ts
3
index.ts
@ -2,12 +2,15 @@ import { ExtendedClient } from "./server/structures/client"
|
|||||||
import { config } from "./server/configuration"
|
import { config } from "./server/configuration"
|
||||||
import { logger } from "./server/logger"
|
import { logger } from "./server/logger"
|
||||||
import { JellyfinHandler } from "./server/jellyfin/handler"
|
import { JellyfinHandler } from "./server/jellyfin/handler"
|
||||||
|
import { attachedImages } from "./server/assets/attachments"
|
||||||
const requestId = 'startup'
|
const requestId = 'startup'
|
||||||
|
|
||||||
export const jellyfinHandler = new JellyfinHandler(config)
|
export const jellyfinHandler = new JellyfinHandler(config)
|
||||||
|
|
||||||
export const client = new ExtendedClient(jellyfinHandler)
|
export const client = new ExtendedClient(jellyfinHandler)
|
||||||
|
|
||||||
|
export const attachmentImages = attachedImages
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
try {
|
try {
|
||||||
const users = await jellyfinHandler.getCurrentUsers("", requestId)
|
const users = await jellyfinHandler.getCurrentUsers("", requestId)
|
||||||
|
12
server/assets/attachments.ts
Normal file
12
server/assets/attachments.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { AttachmentBuilder } from "discord.js"
|
||||||
|
|
||||||
|
const splashScreen = new AttachmentBuilder('./server/assets/images/set_splashscreen.png')
|
||||||
|
const startScreen = new AttachmentBuilder('./server/assets/images/start_screen.png')
|
||||||
|
const serverConnection = new AttachmentBuilder('./server/assets/images/server_verbindung.png')
|
||||||
|
const accountChoice = new AttachmentBuilder('./server/assets/images/auswahl_anmeldung.png')
|
||||||
|
const loginScreen = new AttachmentBuilder('./server/assets/images/login_screen.png')
|
||||||
|
const overview = new AttachmentBuilder('./server/assets/images/jellyfin_ubersicht.png')
|
||||||
|
const joingroup = new AttachmentBuilder('./server/assets/images/gruppe_beitreten.png')
|
||||||
|
const resume = new AttachmentBuilder('./server/assets/images/wiedergabe_fortsetzen.png')
|
||||||
|
const leavegroup = new AttachmentBuilder('./server/assets/images/gruppe_verlassen.png')
|
||||||
|
export const attachedImages = [splashScreen, startScreen, serverConnection, accountChoice, loginScreen, overview, resume, leavegroup, joingroup]
|
@ -1,8 +1,9 @@
|
|||||||
import { Command } from '../structures/command'
|
import { Command } from '../structures/command'
|
||||||
import { RunOptions } from '../types/commandTypes'
|
import { RunOptions } from '../types/commandTypes'
|
||||||
import { AttachmentBuilder, APIEmbed } from 'discord.js'
|
import { APIEmbed } from 'discord.js'
|
||||||
import { v4 as uuid } from 'uuid'
|
import { v4 as uuid } from 'uuid'
|
||||||
import { logger } from '../logger'
|
import { logger } from '../logger'
|
||||||
|
import { attachmentImages } from '../..'
|
||||||
|
|
||||||
const color = 0x0099FF
|
const color = 0x0099FF
|
||||||
export default new Command({
|
export default new Command({
|
||||||
@ -11,18 +12,7 @@ export default new Command({
|
|||||||
options: [],
|
options: [],
|
||||||
run: async (interaction: RunOptions) => {
|
run: async (interaction: RunOptions) => {
|
||||||
const requestId = uuid()
|
const requestId = uuid()
|
||||||
const splashScreen = new AttachmentBuilder('./server/assets/images/set_splashscreen.png')
|
|
||||||
const startScreen = new AttachmentBuilder('./server/assets/images/start_screen.png')
|
|
||||||
const serverConnection = new AttachmentBuilder('./server/assets/images/server_verbindung.png')
|
|
||||||
const accountChoice = new AttachmentBuilder('./server/assets/images/auswahl_anmeldung.png')
|
|
||||||
const loginScreen = new AttachmentBuilder('./server/assets/images/login_screen.png')
|
|
||||||
const overview = new AttachmentBuilder('./server/assets/images/jellyfin_ubersicht.png')
|
|
||||||
const joingroup = new AttachmentBuilder('./server/assets/images/gruppe_beitreten.png')
|
|
||||||
const resume = new AttachmentBuilder('./server/assets/images/wiedergabe_fortsetzen.png')
|
|
||||||
const leavegroup = new AttachmentBuilder('./server/assets/images/gruppe_verlassen.png')
|
|
||||||
const attachedImages = [splashScreen, startScreen, serverConnection, accountChoice, loginScreen, overview, resume, leavegroup, joingroup]
|
|
||||||
interaction.interaction.followUp('Ich schicke dir einen Guide per DM!')
|
interaction.interaction.followUp('Ich schicke dir einen Guide per DM!')
|
||||||
logger.info(`Using images: ${JSON.stringify(attachedImages)}`)
|
|
||||||
const embedList: APIEmbed[] = []
|
const embedList: APIEmbed[] = []
|
||||||
// DownloadLink
|
// DownloadLink
|
||||||
embedList.push({
|
embedList.push({
|
||||||
@ -118,7 +108,8 @@ export default new Command({
|
|||||||
description: "Wenn du aus der Watchparty rausgeflogen bist, oder die Wiedergabe verlassen hast, kannst du über das Menü oben rechts auch wieder zurückkehren.",
|
description: "Wenn du aus der Watchparty rausgeflogen bist, oder die Wiedergabe verlassen hast, kannst du über das Menü oben rechts auch wieder zurückkehren.",
|
||||||
})
|
})
|
||||||
//logger.info(`Trying to use ${splashScreen.name}`, { requestId, guildId: interaction.interaction.guild?.id })
|
//logger.info(`Trying to use ${splashScreen.name}`, { requestId, guildId: interaction.interaction.guild?.id })
|
||||||
|
logger.info(`Sending guide to ${interaction.interaction.user.id}`, { requestId, guildId: interaction.interaction.guild?.id })
|
||||||
const userDMchannel = await interaction.interaction.user.createDM()
|
const userDMchannel = await interaction.interaction.user.createDM()
|
||||||
userDMchannel.send({ embeds: embedList, files: attachedImages })
|
userDMchannel.send({ embeds: embedList, files: attachmentImages})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user