do some mini cleany cleany
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import type { ChatMessage } from "@twurple/chat";
|
||||
import axios from "axios";
|
||||
import { Config } from "../config/config.ts";
|
||||
import { logError, logSuccess } from "../util/logger.ts";
|
||||
import { BaseCommand } from "./base-command.ts";
|
||||
import type { ICommandRequirements } from "./interface.ts";
|
||||
@@ -38,7 +39,7 @@ export class SongCommand extends BaseCommand {
|
||||
}
|
||||
|
||||
async function getSongFromTidal() {
|
||||
axios.get<ISong>("http://localhost:47836/current").then(
|
||||
axios.get<ISong>(`${Config.tidal.host}:${Config.tidal.port}/current`).then(
|
||||
(response) => {
|
||||
const currentSong = response.data;
|
||||
|
||||
|
||||
@@ -9,4 +9,9 @@ export const Config = {
|
||||
client_secret: process.env.CLIENT_SECRET || "",
|
||||
channels: process.env.CHANNELS?.split(",") || [],
|
||||
developers: process.env.DEVELOPERS?.split(",") || [],
|
||||
|
||||
tidal: {
|
||||
host: process.env.TIDAL_HOST || "",
|
||||
port: process.env.TIDAL_PORT || "",
|
||||
},
|
||||
} as const;
|
||||
|
||||
@@ -18,7 +18,7 @@ const authProviderPrivate = new RefreshingAuthProvider({
|
||||
});
|
||||
|
||||
authProviderPrivate.onRefresh(async (_userId, newTokenData: AccessToken) =>
|
||||
tokenManager.updateToken(newTokenData),
|
||||
tokenManager.createTokenFile(newTokenData),
|
||||
);
|
||||
|
||||
authProviderPrivate.addUser(Config.bot_user_id, tokenData, ["chat"]);
|
||||
|
||||
@@ -14,17 +14,13 @@ export class TokenManager {
|
||||
return JSON.parse(tokenFile);
|
||||
} catch (_error) {
|
||||
console.log(
|
||||
`Token file ${this.tokenFilePath} not found. Please run the setup`,
|
||||
`token file ${this.tokenFilePath} not found. please run the setup`,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async updateToken(token: AccessToken): Promise<void> {
|
||||
this.createTokenFile(token);
|
||||
}
|
||||
|
||||
private async createTokenFile(tokenData: AccessToken): Promise<void> {
|
||||
async createTokenFile(tokenData: AccessToken): Promise<void> {
|
||||
const formattedTokens = JSON.stringify(tokenData, null, 4);
|
||||
await fs.writeFile(this.tokenFilePath, formattedTokens, "utf-8");
|
||||
}
|
||||
|
||||
@@ -44,6 +44,6 @@ const code = await auth.startCallbackServer(port, 120);
|
||||
|
||||
const tokenManager = new TokenManager(botId);
|
||||
|
||||
tokenManager.updateToken(
|
||||
tokenManager.createTokenFile(
|
||||
await exchangeCode(Config.client_id, Config.client_secret, code, redirectUri),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user