format more files
All checks were successful
Compile the repository / compile (pull_request) Successful in 1m12s

This commit is contained in:
2023-06-24 21:09:56 +02:00
parent d82a7cffd2
commit 66f843b399
25 changed files with 1418 additions and 1418 deletions

View File

@ -8,114 +8,114 @@ import { Command } from '../structures/command'
import { RunOptions } from '../types/commandTypes'
export default new Command({
name: 'announce',
description: 'Neues announcement im announcement Channel an alle senden.',
options: [{
name: "typ",
type: ApplicationCommandOptionType.String,
description: "Was für ein announcement?",
choices: [{ name: "initial", value: "initial" }, { name: "votepls", value: "votepls" }, { name: "cancel", value: "cancel" }],
required: true
}],
run: async (interaction: RunOptions) => {
const command = interaction.interaction
const requestId = uuid()
if (!command.guildId) {
logger.error("COMMAND DOES NOT HAVE A GUILD ID; CANCELLING!!!", { requestId })
return
}
const guildId = command.guildId
const announcementType = command.options.data.find(option => option.name.includes("typ"))
logger.info(`Got command for announcing ${announcementType?.value}!`, { guildId, requestId })
name: 'announce',
description: 'Neues announcement im announcement Channel an alle senden.',
options: [{
name: "typ",
type: ApplicationCommandOptionType.String,
description: "Was für ein announcement?",
choices: [{ name: "initial", value: "initial" }, { name: "votepls", value: "votepls" }, { name: "cancel", value: "cancel" }],
required: true
}],
run: async (interaction: RunOptions) => {
const command = interaction.interaction
const requestId = uuid()
if (!command.guildId) {
logger.error("COMMAND DOES NOT HAVE A GUILD ID; CANCELLING!!!", { requestId })
return
}
const guildId = command.guildId
const announcementType = command.options.data.find(option => option.name.includes("typ"))
logger.info(`Got command for announcing ${announcementType?.value}!`, { guildId, requestId })
if (!announcementType) {
logger.error("Did not get an announcement type!", { guildId, requestId })
return
}
if (!announcementType) {
logger.error("Did not get an announcement type!", { guildId, requestId })
return
}
if (!isAdmin(command.member)) {
logger.info(`Announcement was requested by ${command.member.displayName} but they are not an admin! Not sending announcement.`, { guildId, requestId })
return
} else {
logger.info(`User ${command.member.displayName} seems to be admin`)
}
if (!isAdmin(command.member)) {
logger.info(`Announcement was requested by ${command.member.displayName} but they are not an admin! Not sending announcement.`, { guildId, requestId })
return
} else {
logger.info(`User ${command.member.displayName} seems to be admin`)
}
if ((<string>announcementType.value).includes("initial")) {
sendInitialAnnouncement(guildId, requestId)
command.followUp("Ist rausgeschickt!")
} else {
command.followUp(`${announcementType.value} ist aktuell noch nicht implementiert`)
}
}
if ((<string>announcementType.value).includes("initial")) {
sendInitialAnnouncement(guildId, requestId)
command.followUp("Ist rausgeschickt!")
} else {
command.followUp(`${announcementType.value} ist aktuell noch nicht implementiert`)
}
}
})
function isAdmin(member: GuildMember): boolean {
return member.roles.cache.find((role) => role.id === config.bot.jf_admin_role) !== undefined
return member.roles.cache.find((role) => role.id === config.bot.jf_admin_role) !== undefined
}
async function sendInitialAnnouncement(guildId: string, requestId: string): Promise<void> {
logger.info("Sending initial announcement")
const announcementChannel: Maybe<TextChannel> = client.getAnnouncementChannelForGuild(guildId)
if (!announcementChannel) {
logger.error("Could not find announcement channel. Aborting", { guildId, requestId })
return
}
logger.info("Sending initial announcement")
const announcementChannel: Maybe<TextChannel> = client.getAnnouncementChannelForGuild(guildId)
if (!announcementChannel) {
logger.error("Could not find announcement channel. Aborting", { guildId, requestId })
return
}
const currentPinnedAnnouncementMessages = (await announcementChannel.messages.fetchPinned()).filter(message => message.cleanContent.includes("[initial]"))
currentPinnedAnnouncementMessages.forEach(async (message) => await message.unpin())
currentPinnedAnnouncementMessages.forEach(message => message.delete())
const currentPinnedAnnouncementMessages = (await announcementChannel.messages.fetchPinned()).filter(message => message.cleanContent.includes("[initial]"))
currentPinnedAnnouncementMessages.forEach(async (message) => await message.unpin())
currentPinnedAnnouncementMessages.forEach(message => message.delete())
const body = `[initial] Hey! @everyone! Hier ist der Watchparty Bot vom Hartzarett.
const body = `[initial] Hey! @everyone! Hier ist der Watchparty Bot vom Hartzarett.
Wir machen in Zukunft regelmäßig Watchparties in denen wir zusammen Filme gucken! Falls du mitmachen möchtest, reagiere einfach auf diesen Post mit 🎫, dann bekommst du automatisch eine Rolle zugewiesen und wirst benachrichtigt sobald es in der Zukunft weitere Watchparties und Filme zum abstimmen gibt.
Für eine Erklärung wie das alles funktioniert mach einfach /mitgucken für eine lange Erklärung am Stück oder /guides wenn du auswählen möchtest wozu du Infos bekommst.`
const options: MessageCreateOptions = {
allowedMentions: { parse: ['everyone'] },
content: body
}
const message: Message<true> = await announcementChannel.send(options)
await message.react("🎫")
await message.pin()
const options: MessageCreateOptions = {
allowedMentions: { parse: ['everyone'] },
content: body
}
const message: Message<true> = await announcementChannel.send(options)
await message.react("🎫")
await message.pin()
}
export async function manageAnnouncementRoles(guild: Guild, reaction: MessageReaction, requestId: string) {
const guildId = guild.id
logger.info("Managing roles", { guildId, requestId })
const guildId = guild.id
logger.info("Managing roles", { guildId, requestId })
const announcementRole: Role | undefined = (await guild.roles.fetch()).find(role => role.id === config.bot.announcement_role)
if (!announcementRole) {
logger.error(`Could not find announcement role! Aborting! Was looking for role with id: ${config.bot.announcement_role}`, { guildId, requestId })
return
}
const announcementRole: Role | undefined = (await guild.roles.fetch()).find(role => role.id === config.bot.announcement_role)
if (!announcementRole) {
logger.error(`Could not find announcement role! Aborting! Was looking for role with id: ${config.bot.announcement_role}`, { guildId, requestId })
return
}
const usersWhoWantRole: User[] = (await reaction.users.fetch()).filter(user => !user.bot).map(user => user)
const usersWhoWantRole: User[] = (await reaction.users.fetch()).filter(user => !user.bot).map(user => user)
const allUsers = (await guild.members.fetch())
const allUsers = (await guild.members.fetch())
const usersWhoHaveRole: GuildMember[] = allUsers
.filter(member => member.roles.cache
.find(role => role.id === config.bot.announcement_role) !== undefined)
.map(member => member)
const usersWhoHaveRole: GuildMember[] = allUsers
.filter(member => member.roles.cache
.find(role => role.id === config.bot.announcement_role) !== undefined)
.map(member => member)
const usersWhoNeedRoleRevoked: GuildMember[] = usersWhoHaveRole
.filter(userWhoHas => !usersWhoWantRole.map(wanter => wanter.id).includes(userWhoHas.id))
const usersWhoNeedRoleRevoked: GuildMember[] = usersWhoHaveRole
.filter(userWhoHas => !usersWhoWantRole.map(wanter => wanter.id).includes(userWhoHas.id))
const usersWhoDontHaveRole: GuildMember[] = allUsers
.filter(member => member.roles.cache
.find(role => role.id === config.bot.announcement_role) === undefined)
.map(member => member)
const usersWhoDontHaveRole: GuildMember[] = allUsers
.filter(member => member.roles.cache
.find(role => role.id === config.bot.announcement_role) === undefined)
.map(member => member)
const usersWhoNeedRole: GuildMember[] = usersWhoDontHaveRole
.filter(userWhoNeeds => usersWhoWantRole.map(wanter => wanter.id).includes(userWhoNeeds.id))
const usersWhoNeedRole: GuildMember[] = usersWhoDontHaveRole
.filter(userWhoNeeds => usersWhoWantRole.map(wanter => wanter.id).includes(userWhoNeeds.id))
logger.debug(`Theses users will get the role removed: ${JSON.stringify(usersWhoNeedRoleRevoked)}`, { guildId, requestId })
logger.debug(`Theses users will get the role added: ${JSON.stringify(usersWhoNeedRole)}`, { guildId, requestId })
logger.debug(`Theses users will get the role removed: ${JSON.stringify(usersWhoNeedRoleRevoked)}`, { guildId, requestId })
logger.debug(`Theses users will get the role added: ${JSON.stringify(usersWhoNeedRole)}`, { guildId, requestId })
usersWhoNeedRoleRevoked.forEach(user => user.roles.remove(announcementRole))
usersWhoNeedRole.forEach(user => user.roles.add(announcementRole))
usersWhoNeedRoleRevoked.forEach(user => user.roles.remove(announcementRole))
usersWhoNeedRole.forEach(user => user.roles.add(announcementRole))
}

View File

@ -10,175 +10,175 @@ import { Command } from '../structures/command'
import { RunOptions } from '../types/commandTypes'
export default new Command({
name: 'closepoll',
description: 'Aktuelle Umfrage für nächste Watchparty beenden und Gewinner in Event eintragen.',
options: [],
run: async (interaction: RunOptions) => {
const command = interaction.interaction
const requestId = uuid()
if (!command.guild) {
logger.error("No guild found in interaction. Cancelling closing request", { requestId })
command.followUp("Es gab leider ein Problem. Ich konnte deine Anfrage nicht bearbeiten :(")
return
}
const guildId = command.guildId
logger.info("Got command for closing poll!", { guildId, requestId })
name: 'closepoll',
description: 'Aktuelle Umfrage für nächste Watchparty beenden und Gewinner in Event eintragen.',
options: [],
run: async (interaction: RunOptions) => {
const command = interaction.interaction
const requestId = uuid()
if (!command.guild) {
logger.error("No guild found in interaction. Cancelling closing request", { requestId })
command.followUp("Es gab leider ein Problem. Ich konnte deine Anfrage nicht bearbeiten :(")
return
}
const guildId = command.guildId
logger.info("Got command for closing poll!", { guildId, requestId })
command.followUp("Alles klar, beende die Umfrage :)")
closePoll(command.guild, requestId)
}
command.followUp("Alles klar, beende die Umfrage :)")
closePoll(command.guild, requestId)
}
})
export async function closePoll(guild: Guild, requestId: string) {
const guildId = guild.id
logger.info("stopping poll", { guildId, requestId })
const guildId = guild.id
logger.info("stopping poll", { guildId, requestId })
const announcementChannel: Maybe<TextChannel> = client.getAnnouncementChannelForGuild(guildId)
if (!announcementChannel) {
logger.error("Could not find the textchannel. Unable to close poll.", { guildId, requestId })
return
}
const announcementChannel: Maybe<TextChannel> = client.getAnnouncementChannelForGuild(guildId)
if (!announcementChannel) {
logger.error("Could not find the textchannel. Unable to close poll.", { guildId, requestId })
return
}
const messages: Message<true>[] = (await announcementChannel.messages.fetch()) //todo: fetch only pinned messages
.map((value) => value)
.filter(message => !message.cleanContent.includes("[Abstimmung beendet]") && message.cleanContent.includes("[Abstimmung]"))
.sort((a, b) => b.createdTimestamp - a.createdTimestamp)
const messages: Message<true>[] = (await announcementChannel.messages.fetch()) //todo: fetch only pinned messages
.map((value) => value)
.filter(message => !message.cleanContent.includes("[Abstimmung beendet]") && message.cleanContent.includes("[Abstimmung]"))
.sort((a, b) => b.createdTimestamp - a.createdTimestamp)
if (!messages || messages.length <= 0) {
logger.info("Could not find any vote messages. Cancelling pollClose", { guildId, requestId })
return
}
if (!messages || messages.length <= 0) {
logger.info("Could not find any vote messages. Cancelling pollClose", { guildId, requestId })
return
}
const lastMessage: Message<true> = messages[0]
const lastMessage: Message<true> = messages[0]
logger.debug(`Found messages: ${JSON.stringify(messages, null, 2)}`, { guildId, requestId })
logger.debug(`Found messages: ${JSON.stringify(messages, null, 2)}`, { guildId, requestId })
logger.debug(`Last message: ${JSON.stringify(lastMessage, null, 2)}`, { guildId, requestId })
logger.debug(`Last message: ${JSON.stringify(lastMessage, null, 2)}`, { guildId, requestId })
const votes = await (await getVotesByEmote(lastMessage, guildId, requestId))
.sort((a, b) => b.count - a.count)
const votes = await (await getVotesByEmote(lastMessage, guildId, requestId))
.sort((a, b) => b.count - a.count)
logger.debug(`votes: ${JSON.stringify(votes, null, 2)}`, { guildId, requestId })
logger.debug(`votes: ${JSON.stringify(votes, null, 2)}`, { guildId, requestId })
logger.info("Deleting vote message")
await lastMessage.delete()
const event = await getEvent(guild, guild.id, requestId)
if (event) {
updateEvent(event, votes, guild, guildId, requestId)
sendVoteClosedMessage(event, votes[0].movie, guildId, requestId)
}
logger.info("Deleting vote message")
await lastMessage.delete()
const event = await getEvent(guild, guild.id, requestId)
if (event) {
updateEvent(event, votes, guild, guildId, requestId)
sendVoteClosedMessage(event, votes[0].movie, guildId, requestId)
}
//lastMessage.unpin() //todo: uncomment when bot has permission to pin/unpin
//lastMessage.unpin() //todo: uncomment when bot has permission to pin/unpin
}
async function sendVoteClosedMessage(event: GuildScheduledEvent, movie: string, guildId: string, requestId: string) {
const date = event.scheduledStartAt ? format(event.scheduledStartAt, "dd.MM") : "Fehler, event hatte kein Datum"
const time = event.scheduledStartAt ? format(event.scheduledStartAt, "HH:mm") : "Fehler, event hatte kein Datum"
const body = `[Abstimmung beendet] für https://discord.com/events/${event.guildId}/${event.id}\n<@&${config.bot.announcement_role}> Wir gucken ${movie} am ${date} um ${time}`
const options: MessageCreateOptions = {
content: body,
allowedMentions: { parse: ["roles"] }
}
const announcementChannel = client.getAnnouncementChannelForGuild(guildId)
logger.info("Sending vote closed message.", { guildId, requestId })
if (!announcementChannel) {
logger.error("Could not find announcement channel. Please fix!", { guildId, requestId })
return
}
announcementChannel.send(options)
const date = event.scheduledStartAt ? format(event.scheduledStartAt, "dd.MM") : "Fehler, event hatte kein Datum"
const time = event.scheduledStartAt ? format(event.scheduledStartAt, "HH:mm") : "Fehler, event hatte kein Datum"
const body = `[Abstimmung beendet] für https://discord.com/events/${event.guildId}/${event.id}\n<@&${config.bot.announcement_role}> Wir gucken ${movie} am ${date} um ${time}`
const options: MessageCreateOptions = {
content: body,
allowedMentions: { parse: ["roles"] }
}
const announcementChannel = client.getAnnouncementChannelForGuild(guildId)
logger.info("Sending vote closed message.", { guildId, requestId })
if (!announcementChannel) {
logger.error("Could not find announcement channel. Please fix!", { guildId, requestId })
return
}
announcementChannel.send(options)
}
async function updateEvent(voteEvent: GuildScheduledEvent, votes: Vote[], guild: Guild, guildId: string, requestId: string) {
logger.info(`Updating event with movie ${votes[0].movie}.`, { guildId, requestId })
const options: GuildScheduledEventEditOptions<GuildScheduledEventStatus.Scheduled, GuildScheduledEventSetStatusArg<GuildScheduledEventStatus.Scheduled>> = {
name: votes[0].movie,
description: `!wp\nNummer 2: ${votes[1].movie} mit ${votes[1].count - 1} Stimmen\nNummer 3: ${votes[2].movie} mit ${votes[2].count - 1} Stimmen`
}
logger.debug(`Updating event: ${JSON.stringify(voteEvent, null, 2)}`, { guildId, requestId })
logger.info("Updating event.", { guildId, requestId })
voteEvent.edit(options)
logger.info(`Updating event with movie ${votes[0].movie}.`, { guildId, requestId })
const options: GuildScheduledEventEditOptions<GuildScheduledEventStatus.Scheduled, GuildScheduledEventSetStatusArg<GuildScheduledEventStatus.Scheduled>> = {
name: votes[0].movie,
description: `!wp\nNummer 2: ${votes[1].movie} mit ${votes[1].count - 1} Stimmen\nNummer 3: ${votes[2].movie} mit ${votes[2].count - 1} Stimmen`
}
logger.debug(`Updating event: ${JSON.stringify(voteEvent, null, 2)}`, { guildId, requestId })
logger.info("Updating event.", { guildId, requestId })
voteEvent.edit(options)
}
async function getEvent(guild: Guild, guildId: string, requestId: string): Promise<GuildScheduledEvent | null> {
const voteEvents = (await guild.scheduledEvents.fetch())
.map((value) => value)
.filter(event => event.name.toLowerCase().includes("voting offen"))
logger.debug(`Found events: ${JSON.stringify(voteEvents, null, 2)}`, { guildId, requestId })
const voteEvents = (await guild.scheduledEvents.fetch())
.map((value) => value)
.filter(event => event.name.toLowerCase().includes("voting offen"))
logger.debug(`Found events: ${JSON.stringify(voteEvents, null, 2)}`, { guildId, requestId })
if (!voteEvents || voteEvents.length <= 0) {
logger.error("Could not find vote event. Cancelling update!", { guildId, requestId })
return null
}
return voteEvents[0]
if (!voteEvents || voteEvents.length <= 0) {
logger.error("Could not find vote event. Cancelling update!", { guildId, requestId })
return null
}
return voteEvents[0]
}
type Vote = {
emote: string, //todo habs nicht hinbekommen hier Emotes zu nutzen
count: number,
movie: string
emote: string, //todo habs nicht hinbekommen hier Emotes zu nutzen
count: number,
movie: string
}
async function getVotesByEmote(message: Message, guildId: string, requestId: string): Promise<Vote[]> {
const votes: Vote[] = []
logger.debug(`Number of items in emotes: ${Object.values(Emotes).length}`, { guildId, requestId })
for (let i = 0; i < Object.keys(Emotes).length / 2; i++) {
const emote = Emotes[i]
logger.debug(`Getting reaction for emote ${emote}`, { guildId, requestId })
const reaction = await message.reactions.resolve(emote)
logger.debug(`Reaction for emote ${emote}: ${JSON.stringify(reaction, null, 2)}`, { guildId, requestId })
if (reaction) {
const vote: Vote = { emote: emote, count: reaction.count, movie: extractMovieFromMessageByEmote(message, emote) }
votes.push(vote)
}
}
return votes
const votes: Vote[] = []
logger.debug(`Number of items in emotes: ${Object.values(Emotes).length}`, { guildId, requestId })
for (let i = 0; i < Object.keys(Emotes).length / 2; i++) {
const emote = Emotes[i]
logger.debug(`Getting reaction for emote ${emote}`, { guildId, requestId })
const reaction = await message.reactions.resolve(emote)
logger.debug(`Reaction for emote ${emote}: ${JSON.stringify(reaction, null, 2)}`, { guildId, requestId })
if (reaction) {
const vote: Vote = { emote: emote, count: reaction.count, movie: extractMovieFromMessageByEmote(message, emote) }
votes.push(vote)
}
}
return votes
}
function extractMovieFromMessageByEmote(message: Message, emote: string): string {
const lines = message.cleanContent.split("\n")
const emoteLines = lines.filter(line => line.includes(emote))
const lines = message.cleanContent.split("\n")
const emoteLines = lines.filter(line => line.includes(emote))
if (!emoteLines) {
return ""
}
const movie = emoteLines[0].substring(emoteLines[0].indexOf(emote) + emote.length + 2) // plus colon and space
if (!emoteLines) {
return ""
}
const movie = emoteLines[0].substring(emoteLines[0].indexOf(emote) + emote.length + 2) // plus colon and space
return movie
return movie
}
export async function checkForPollsToClose(guild: Guild): Promise<void> {
const requestId = uuid()
logger.info(`Automatic check for poll closing.`, { guildId: guild.id, requestId })
const events = (await guild.scheduledEvents.fetch()).filter(event => event.name.toLocaleLowerCase().includes("voting offen")).map(event => event)
if (events.length > 1) {
logger.error("Handling more than one Event is not implemented yet. Found more than one poll to close")
return
} else if (events.length == 0) {
logger.info("Could not find any events. Cancelling", { guildId: guild.id, requestId })
}
const requestId = uuid()
logger.info(`Automatic check for poll closing.`, { guildId: guild.id, requestId })
const events = (await guild.scheduledEvents.fetch()).filter(event => event.name.toLocaleLowerCase().includes("voting offen")).map(event => event)
if (events.length > 1) {
logger.error("Handling more than one Event is not implemented yet. Found more than one poll to close")
return
} else if (events.length == 0) {
logger.info("Could not find any events. Cancelling", { guildId: guild.id, requestId })
}
const updatedEvent = events[0] //add two hours because of different timezones in discord api and Date.now()
if (!updatedEvent.scheduledStartTimestamp) {
logger.error("Event does not have a scheduled start time. Cancelling", { guildId: guild.id, requestId })
return
}
const updatedEvent = events[0] //add two hours because of different timezones in discord api and Date.now()
if (!updatedEvent.scheduledStartTimestamp) {
logger.error("Event does not have a scheduled start time. Cancelling", { guildId: guild.id, requestId })
return
}
const createDate: Date = toDate(updatedEvent.createdTimestamp)
const eventDate: Date = toDate(updatedEvent.scheduledStartTimestamp)
const difference: number = differenceInDays(createDate, eventDate)
const createDate: Date = toDate(updatedEvent.createdTimestamp)
const eventDate: Date = toDate(updatedEvent.scheduledStartTimestamp)
const difference: number = differenceInDays(createDate, eventDate)
if (difference <= 2) {
logger.info("Less than two days between event create and event start. Not closing poll.", { guildId: guild.id, requestId })
return
}
if (difference <= 2) {
logger.info("Less than two days between event create and event start. Not closing poll.", { guildId: guild.id, requestId })
return
}
const closePollDate: Date = addDays(eventDate, -2)
const closePollDate: Date = addDays(eventDate, -2)
if (isAfter(Date.now(), closePollDate)) {
logger.info("Less than two days until event. Closing poll", { guildId: guild.id, requestId })
closePoll(guild, requestId)
} else {
logger.info(`ScheduledStart: ${closePollDate}. Now: ${toDate(Date.now())}`, { guildId: guild.id, requestId })
}
}
if (isAfter(Date.now(), closePollDate)) {
logger.info("Less than two days until event. Closing poll", { guildId: guild.id, requestId })
closePoll(guild, requestId)
} else {
logger.info(`ScheduledStart: ${closePollDate}. Now: ${toDate(Date.now())}`, { guildId: guild.id, requestId })
}
}

View File

@ -2,18 +2,18 @@ import { ApplicationCommandOptionType } from 'discord.js'
import { Command } from '../structures/command'
import { RunOptions } from '../types/commandTypes'
export default new Command({
name: 'echo',
description: 'Echoes a text',
options: [
{
name: 'echo',
description: 'The text to echo',
type: ApplicationCommandOptionType.String,
required: true
}
],
run: async (interaction: RunOptions) => {
console.log('echo called')
interaction.interaction.reply(interaction.toString())
}
name: 'echo',
description: 'Echoes a text',
options: [
{
name: 'echo',
description: 'The text to echo',
type: ApplicationCommandOptionType.String,
required: true
}
],
run: async (interaction: RunOptions) => {
console.log('echo called')
interaction.interaction.reply(interaction.toString())
}
})

View File

@ -8,76 +8,76 @@ import { RunOptions } from '../types/commandTypes'
import { configureServer, explainRole, installation, loginInfo, useSyncgroup } from './mitgucken'
export default new Command({
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 })
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 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 accountSetupGuideButton = new ButtonBuilder()
.setCustomId('configureServer')
.setLabel('Server einstellen')
.setStyle(ButtonStyle.Primary)
const loginGuideButton = new ButtonBuilder()
.setCustomId('login')
.setLabel('Einloggen')
.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 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 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 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]
})
//const userDMchannel = await interaction.interaction.user.createDM()
const response = await interaction.interaction.followUp({
content: `Hier ist eine Auswahl von Guides.`,
components: [row]
})
try {
try {
const guideSelection = await response.awaitMessageComponent({ time: 60_000 })
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() })
}
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: [] })
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: [] });
}
} catch (error) {
await interaction.interaction.editReply({ content: 'Das dauert mir zu lange, frag mich nochmal wenn du nen Guide brauchst', components: [] });
}
}
}
})

View File

@ -7,139 +7,139 @@ import { attachmentImages } from '../..'
const color = 0x0099FF
export default new Command({
name: 'mitgucken',
description: 'Erfahre wie die Verbindung mit Jellyfin funktioniert und eine WatchTogether Gruppe funktioniert.',
options: [],
run: async (interaction: RunOptions) => {
const requestId = uuid()
interaction.interaction.followUp('Ich schicke dir einen Guide per DM!')
const embedList: APIEmbed[] = []
embedList.push(...installation())
embedList.push(...configureServer())
embedList.push(...explainRole())
embedList.push(...loginInfo())
embedList.push(...useSyncgroup())
name: 'mitgucken',
description: 'Erfahre wie die Verbindung mit Jellyfin funktioniert und eine WatchTogether Gruppe funktioniert.',
options: [],
run: async (interaction: RunOptions) => {
const requestId = uuid()
interaction.interaction.followUp('Ich schicke dir einen Guide per DM!')
const embedList: APIEmbed[] = []
embedList.push(...installation())
embedList.push(...configureServer())
embedList.push(...explainRole())
embedList.push(...loginInfo())
embedList.push(...useSyncgroup())
//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()
userDMchannel.send({ embeds: embedList, files: attachmentImages })
}
//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()
userDMchannel.send({ embeds: embedList, files: attachmentImages })
}
})
export function explainRole(): APIEmbed[] {
return [{
color,
title: "Wie du an einen Account kommst",
description: roleExplanation
}]
return [{
color,
title: "Wie du an einen Account kommst",
description: roleExplanation
}]
}
export function installation(): APIEmbed[] {
const embedList: APIEmbed[] = []
// DownloadLink and installation
embedList.push({
color,
title: 'Jellyfin Media Player Installation',
description: 'Du kannst den Jellyfin Media Player von github herunterladen.\n Der Mediaplayer muss genutzt werden, da ein Schauen direkt über das Webinterface den Server zum Schmelzen bringt.\nFühre die Datei aus und installiere den Jellyfin Media Player an den Ort deiner Wahl.',
fields: [
{ name: "Windows", value: "https://github.com/jellyfin/jellyfin-media-player/releases/download/v1.9.1/JellyfinMediaPlayer-1.9.1-windows-x64.exe" },
{ name: "Mac", value: "https://github.com/jellyfin/jellyfin-media-player/releases/download/v1.9.1/JellyfinMediaPlayer-1.9.1-macos-notarized.dmg" }
],
image: {
url: 'attachment://set_splashscreen.png'
}
})
return embedList
const embedList: APIEmbed[] = []
// DownloadLink and installation
embedList.push({
color,
title: 'Jellyfin Media Player Installation',
description: 'Du kannst den Jellyfin Media Player von github herunterladen.\n Der Mediaplayer muss genutzt werden, da ein Schauen direkt über das Webinterface den Server zum Schmelzen bringt.\nFühre die Datei aus und installiere den Jellyfin Media Player an den Ort deiner Wahl.',
fields: [
{ name: "Windows", value: "https://github.com/jellyfin/jellyfin-media-player/releases/download/v1.9.1/JellyfinMediaPlayer-1.9.1-windows-x64.exe" },
{ name: "Mac", value: "https://github.com/jellyfin/jellyfin-media-player/releases/download/v1.9.1/JellyfinMediaPlayer-1.9.1-macos-notarized.dmg" }
],
image: {
url: 'attachment://set_splashscreen.png'
}
})
return embedList
}
export function configureServer(): APIEmbed[] {
const embedList: APIEmbed[] = []
// Login
embedList.push({
color,
title: "Server Auswahl",
description: "Die Jellyfin App kann sich mit mehreren Servern verbinden.\n Hattest du noch nie eine Server Verbindung wähle hier 'Server hinzufügen'.",
image: {
url: 'attachment://start_screen.png'
}
})
// Server Address
embedList.push({
color,
title: "Server Verbindung",
description: "Stelle eine Verbindung zum Hartzarett Jellyfin Server her",
fields: [
{ name: "Server Adresse", value: "`https://media.hartzarett.ruhr`" }
],
image: {
url: 'attachment://server_verbindung.png'
}
})
return embedList
const embedList: APIEmbed[] = []
// Login
embedList.push({
color,
title: "Server Auswahl",
description: "Die Jellyfin App kann sich mit mehreren Servern verbinden.\n Hattest du noch nie eine Server Verbindung wähle hier 'Server hinzufügen'.",
image: {
url: 'attachment://start_screen.png'
}
})
// Server Address
embedList.push({
color,
title: "Server Verbindung",
description: "Stelle eine Verbindung zum Hartzarett Jellyfin Server her",
fields: [
{ name: "Server Adresse", value: "`https://media.hartzarett.ruhr`" }
],
image: {
url: 'attachment://server_verbindung.png'
}
})
return embedList
}
export function loginInfo(): APIEmbed[] {
const embedList: APIEmbed[] = []
// Account choice
embedList.push({
color,
title: "Account Auswahl",
description: "In der Regel sind die Accounts aus Datenschutzgründen versteckt.\nWähle 'Manuelle Anmeldung' aus",
image: {
url: 'attachment://auswahl_anmeldung.png'
}
})
// password screen
embedList.push({
color,
title: "Login",
description: "Melde dich mit dem Usernamen und Passwort an, welches dir von mir zugeschickt wird. Falls du ein neues brauchst führe einmal `/passwort_reset` aus :)",
image: {
url: 'attachment://login_screen.png'
}
})
return embedList
const embedList: APIEmbed[] = []
// Account choice
embedList.push({
color,
title: "Account Auswahl",
description: "In der Regel sind die Accounts aus Datenschutzgründen versteckt.\nWähle 'Manuelle Anmeldung' aus",
image: {
url: 'attachment://auswahl_anmeldung.png'
}
})
// password screen
embedList.push({
color,
title: "Login",
description: "Melde dich mit dem Usernamen und Passwort an, welches dir von mir zugeschickt wird. Falls du ein neues brauchst führe einmal `/passwort_reset` aus :)",
image: {
url: 'attachment://login_screen.png'
}
})
return embedList
}
export function useSyncgroup(): APIEmbed[] {
const embedList: APIEmbed[] = []
embedList.push({
color,
title: "SyncPlay Menü",
image: {
url: 'attachment://jellyfin_ubersicht.png'
},
description: "Im Hauptbildschirm findest du die 'SyncPlay' Einstellungen oben rechts.",
})
// join group
embedList.push({
color,
title: "Gruppe beitreten",
image: {
url: 'attachment://gruppe_beitreten.png'
},
description: "Suche dir aus dem Dropdown die SyncPlay Gruppe aus, die zu deinem Event gehört.",
})
// leave group
embedList.push({
color,
title: "Gruppe verlassen",
image: {
url: 'attachment://gruppe_verlassen.png'
},
description: "Wenn du die Watchparty verlassen möchtest, kannst du das ebenfalls über das Menü oben rechts tun.",
})
//resume playback
embedList.push({
color,
title: "Wiedergabe fortsetzen",
image: {
url: 'attachment://wiedergabe_fortsetzen.png'
},
description: "Wenn du aus der Watchparty rausgeflogen bist, oder die Wiedergabe verlassen hast, kannst du über das Menü oben rechts auch wieder zurückkehren.",
})
return embedList
const embedList: APIEmbed[] = []
embedList.push({
color,
title: "SyncPlay Menü",
image: {
url: 'attachment://jellyfin_ubersicht.png'
},
description: "Im Hauptbildschirm findest du die 'SyncPlay' Einstellungen oben rechts.",
})
// join group
embedList.push({
color,
title: "Gruppe beitreten",
image: {
url: 'attachment://gruppe_beitreten.png'
},
description: "Suche dir aus dem Dropdown die SyncPlay Gruppe aus, die zu deinem Event gehört.",
})
// leave group
embedList.push({
color,
title: "Gruppe verlassen",
image: {
url: 'attachment://gruppe_verlassen.png'
},
description: "Wenn du die Watchparty verlassen möchtest, kannst du das ebenfalls über das Menü oben rechts tun.",
})
//resume playback
embedList.push({
color,
title: "Wiedergabe fortsetzen",
image: {
url: 'attachment://wiedergabe_fortsetzen.png'
},
description: "Wenn du aus der Watchparty rausgeflogen bist, oder die Wiedergabe verlassen hast, kannst du über das Menü oben rechts auch wieder zurückkehren.",
})
return embedList
}
const roleExplanation = `Mit einer Rolle kann dafür gesorgt werden, dass du einen dauerhaften Account auf dem Mediaserver hast. Wende dich bei Bedarf an Samantha oder Markus.\n

View File

@ -4,13 +4,13 @@ import { Command } from '../structures/command'
import { RunOptions } from '../types/commandTypes'
export default new Command({
name: 'passwort_reset',
description: 'Ich vergebe dir ein neues Passwort und schicke es dir per DM zu. Kostet auch nix! Versprochen! 😉',
options: [],
run: async (interaction: RunOptions) => {
console.log('PasswortReset called')
interaction.interaction.followUp('Yo, ich schick dir eins!')
console.log(JSON.stringify(interaction.interaction.member, null, 2))
jellyfinHandler.resetUserPasswort(interaction.interaction.member, uuid())
}
name: 'passwort_reset',
description: 'Ich vergebe dir ein neues Passwort und schicke es dir per DM zu. Kostet auch nix! Versprochen! 😉',
options: [],
run: async (interaction: RunOptions) => {
console.log('PasswortReset called')
interaction.interaction.followUp('Yo, ich schick dir eins!')
console.log(JSON.stringify(interaction.interaction.member, null, 2))
jellyfinHandler.resetUserPasswort(interaction.interaction.member, uuid())
}
})