Strongly typed config (and ts strict mode)

This commit is contained in:
Linnea Gräf 2025-02-22 16:06:44 +01:00
parent 36c05556e5
commit 4585f60af7
No known key found for this signature in database
GPG key ID: AA563E93EB628D91
7 changed files with 31 additions and 16 deletions

View file

@ -11,8 +11,9 @@ import {
} from "discord.js";
import { getSongOnPreferredProvider } from "../helper.ts"
import { Config } from "../config.ts";
function keepV(url) {
function keepV(url: string): string {
const urlObj = new URL(url);
const vParam = urlObj.searchParams.get("v");
@ -26,7 +27,7 @@ function keepV(url) {
}
export default class PingCommand extends Command {
async run(interaction: ChatInputCommandInteraction, config) {
async run(interaction: ChatInputCommandInteraction, config: Config) {
await interaction.deferReply()
@ -76,4 +77,4 @@ export default class PingCommand extends Command {
InteractionContextType.Guild,
InteractionContextType.PrivateChannel
]);
}
}

View file

@ -5,9 +5,10 @@ import {
InteractionContextType,
SlashCommandBuilder
} from "discord.js";
import { Config } from "../config.ts";
export default class PingCommand extends Command {
async run(interaction: ChatInputCommandInteraction, config) {
async run(interaction: ChatInputCommandInteraction, config: Config) {
await interaction.reply({
content: 'Pong!',
});
@ -23,4 +24,4 @@ export default class PingCommand extends Command {
InteractionContextType.Guild,
InteractionContextType.PrivateChannel
]);
}
}

View file

@ -6,9 +6,10 @@ import {
InteractionContextType,
SlashCommandBuilder
} from "discord.js";
import { Config } from "../config.ts";
export default class PingCommand extends Command {
async run(interaction: ChatInputCommandInteraction, config) {
async run(interaction: ChatInputCommandInteraction, config: Config) {
const repo = interaction.options.getString("repo")
const meow = await fetch(config.gitapi + repo).then(res => res.json());
const embed = new EmbedBuilder()
@ -38,4 +39,4 @@ export default class PingCommand extends Command {
InteractionContextType.Guild,
InteractionContextType.PrivateChannel
]);
}
}