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