Compare commits
2 Commits
eef3a9c358
...
e66aebc88c
Author | SHA1 | Date | |
---|---|---|---|
e66aebc88c | |||
599243990e |
@ -1,6 +1,7 @@
|
||||
import { ApplicationCommandOptionType } from 'discord.js'
|
||||
import { Command } from '../structures/command'
|
||||
import { RunOptions } from '../types/commandTypes'
|
||||
import { logger } from '../logger'
|
||||
export default new Command({
|
||||
name: 'echo',
|
||||
description: 'Echoes a text',
|
||||
@ -13,7 +14,7 @@ export default new Command({
|
||||
}
|
||||
],
|
||||
run: async (interaction: RunOptions) => {
|
||||
console.log('echo called')
|
||||
logger.info('echo called')
|
||||
interaction.interaction.reply(interaction.toString())
|
||||
}
|
||||
})
|
||||
|
@ -2,15 +2,16 @@ import { v4 as uuid } from 'uuid'
|
||||
import { jellyfinHandler } from "../.."
|
||||
import { Command } from '../structures/command'
|
||||
import { RunOptions } from '../types/commandTypes'
|
||||
import { logger } from '../logger'
|
||||
|
||||
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')
|
||||
logger.info('PasswortReset called')
|
||||
interaction.interaction.followUp('Yo, ich schick dir eins!')
|
||||
console.log(JSON.stringify(interaction.interaction.member, null, 2))
|
||||
logger.info(JSON.stringify(interaction.interaction.member, null, 2))
|
||||
jellyfinHandler.resetUserPasswort(interaction.interaction.member, uuid())
|
||||
}
|
||||
})
|
||||
|
@ -31,6 +31,7 @@ export interface Config {
|
||||
yavin_jellyfin_token: string
|
||||
yavin_jellyfin_collection_user: string
|
||||
random_movie_count: number
|
||||
reroll_retains_top_picks: boolean
|
||||
}
|
||||
}
|
||||
export const config: Config = {
|
||||
@ -71,6 +72,7 @@ export const config: Config = {
|
||||
yavin_jellyfin_token: process.env.YAVIN_TOKEN ?? "",
|
||||
yavin_jellyfin_collection_user: process.env.YAVIN_COLLECTION_USER ?? "",
|
||||
jf_user: process.env.JELLYFIN_USER ?? "",
|
||||
random_movie_count: parseInt(process.env.RANDOM_MOVIE_COUNT ?? "5") ?? 5
|
||||
random_movie_count: parseInt(process.env.RANDOM_MOVIE_COUNT ?? "5") ?? 5,
|
||||
reroll_retains_top_picks: process.env.REROLL_RETAIN === "true"
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { Message } from "discord.js"
|
||||
import { logger } from "../logger"
|
||||
|
||||
export const name = 'messageCreate'
|
||||
export function execute(message: Message) {
|
||||
console.log(`${JSON.stringify(message)} has been created`)
|
||||
logger.info(`${JSON.stringify(message)} has been created`)
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
import { CustomError, errorCodes } from "../interfaces"
|
||||
import { logger } from "../logger"
|
||||
import { ExtendedClient } from "../structures/client"
|
||||
|
||||
export async function sendFailureDM(creatorMessage: string, client: ExtendedClient, creatorId?: string): Promise<void> {
|
||||
if (!creatorId) throw new CustomError('No creator ID present', errorCodes.no_creator_id)
|
||||
const creator = await client.users.fetch(creatorId)
|
||||
console.log(`Creator ${JSON.stringify(creator)}`)
|
||||
logger.info(`Creator ${JSON.stringify(creator)}`)
|
||||
if (creator)
|
||||
if (!creator.dmChannel)
|
||||
await creator.createDM()
|
||||
|
@ -52,7 +52,7 @@ export default class VoteController {
|
||||
logger.info(`No reroll`, { requestId, guildId })
|
||||
else {
|
||||
logger.info('Starting poll reroll', { requestId, guildId })
|
||||
await this.handleReroll(reactedUponMessage, guild, guild.id, requestId)
|
||||
await this.handleReroll(reactedUponMessage, guild.id, requestId)
|
||||
logger.info(`Finished handling NONE_OF_THAT vote`, { requestId, guildId })
|
||||
}
|
||||
}
|
||||
@ -68,20 +68,25 @@ export default class VoteController {
|
||||
logger.debug(`${vote.movie} : ${vote.count} -> above: ${aboveThreshold}`)
|
||||
return aboveThreshold
|
||||
}
|
||||
public async handleReroll(voteMessage: VoteMessage, guild: Guild, guildId: string, requestId: string) {
|
||||
public async handleReroll(voteMessage: VoteMessage, guildId: string, requestId: string) {
|
||||
//get movies that already had votes to give them a second chance
|
||||
const voteInfo: VoteMessageInfo = await this.parseVoteInfoFromVoteMessage(voteMessage, requestId)
|
||||
const votedOnMovies = voteInfo.votes.filter(this.isAboveThreshold).filter(x => x.emote !== NONE_OF_THAT)
|
||||
logger.info(`Found ${votedOnMovies.length} with votes`, { requestId, guildId })
|
||||
|
||||
// get movies from jellyfin to fill the remaining slots
|
||||
const newMovieCount: number = config.bot.random_movie_count - votedOnMovies.length
|
||||
logger.info(`Fetching ${newMovieCount} from jellyfin`)
|
||||
const newMovies: string[] = await this.yavinJellyfinHandler.getRandomMovieNames(newMovieCount, guildId, requestId)
|
||||
|
||||
// merge
|
||||
const movies: string[] = newMovies.concat(votedOnMovies.map(x => x.movie))
|
||||
|
||||
let movies: string[] = Array()
|
||||
if (config.bot.reroll_retains_top_picks) {
|
||||
const votedOnMovies = voteInfo.votes.filter(this.isAboveThreshold).filter(x => x.emote !== NONE_OF_THAT)
|
||||
logger.info(`Found ${votedOnMovies.length} with votes`, { requestId, guildId })
|
||||
const newMovieCount: number = config.bot.random_movie_count - votedOnMovies.length
|
||||
logger.info(`Fetching ${newMovieCount} from jellyfin`)
|
||||
const newMovies: string[] = await this.yavinJellyfinHandler.getRandomMovieNames(newMovieCount, guildId, requestId)
|
||||
// merge
|
||||
movies = newMovies.concat(votedOnMovies.map(x => x.movie))
|
||||
} else {
|
||||
// get movies from jellyfin to fill the remaining slots
|
||||
const newMovieCount: number = config.bot.random_movie_count
|
||||
logger.info(`Fetching ${newMovieCount} from jellyfin`)
|
||||
movies = await this.yavinJellyfinHandler.getRandomMovieNames(newMovieCount, guildId, requestId)
|
||||
}
|
||||
// create new message
|
||||
|
||||
logger.info(`Creating new poll message with new movies: ${movies}`, { requestId, guildId })
|
||||
|
Loading…
Reference in New Issue
Block a user