chore: add code quality tooling
This commit is contained in:
+50
-48
@@ -1,12 +1,12 @@
|
||||
import "./mock-crc";
|
||||
import "libsodium-wrappers";
|
||||
import "@snazzah/davey";
|
||||
import { Client } from "discord.js-selfbot-v13";
|
||||
import { startRecording } from "./recorder";
|
||||
import { config } from "./config";
|
||||
import { startWebserver } from "./webserver";
|
||||
import { discordPlayer } from "./player";
|
||||
import { getVoiceConnection } from "@discordjs/voice";
|
||||
import { Client } from "discord.js-selfbot-v13";
|
||||
import { config } from "./config";
|
||||
import { discordPlayer } from "./player";
|
||||
import { startRecording } from "./recorder";
|
||||
import { startWebserver } from "./webserver";
|
||||
|
||||
// Validasi environment variables
|
||||
const token = process.env.DISCORD_TOKEN;
|
||||
@@ -21,64 +21,66 @@ if (!guildId) throw new Error("Missing GUILD_ID in .env");
|
||||
const client = new Client();
|
||||
|
||||
client.on("ready", async () => {
|
||||
if (config.verbose) {
|
||||
console.log(`[bot] Logged in as ${client.user!.tag}`);
|
||||
}
|
||||
if (config.verbose) {
|
||||
console.log(`[bot] Logged in as ${client.user!.tag}`);
|
||||
}
|
||||
|
||||
// Ambil guild
|
||||
const guild = client.guilds.cache.get(guildId!);
|
||||
if (!guild) {
|
||||
console.error(`[bot] Guild not found: ${guildId}`);
|
||||
process.exit(1);
|
||||
}
|
||||
// Ambil guild
|
||||
const guild = client.guilds.cache.get(guildId!);
|
||||
if (!guild) {
|
||||
console.error(`[bot] Guild not found: ${guildId}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Fetch channels jika belum ada di cache
|
||||
const channel =
|
||||
guild.channels.cache.get(voiceChannelId!) ??
|
||||
(await guild.channels.fetch(voiceChannelId!).catch(() => null));
|
||||
// Fetch channels jika belum ada di cache
|
||||
const channel =
|
||||
guild.channels.cache.get(voiceChannelId!) ??
|
||||
(await guild.channels.fetch(voiceChannelId!).catch(() => null));
|
||||
|
||||
if (!channel || channel.type !== "GUILD_VOICE") {
|
||||
console.error(
|
||||
`[bot] Voice channel not found or wrong type: ${voiceChannelId}`
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
if (!channel || channel.type !== "GUILD_VOICE") {
|
||||
console.error(
|
||||
`[bot] Voice channel not found or wrong type: ${voiceChannelId}`,
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (config.verbose) {
|
||||
console.log(`[bot] Joining voice channel: #${channel.name} (${channel.id})`);
|
||||
}
|
||||
await startRecording(client, channel as any);
|
||||
|
||||
// Set up player connection
|
||||
const connection = getVoiceConnection(guildId!);
|
||||
if (connection) {
|
||||
discordPlayer.setConnection(connection);
|
||||
console.log("[bot] Player connected to voice channel");
|
||||
}
|
||||
if (config.verbose) {
|
||||
console.log(
|
||||
`[bot] Joining voice channel: #${channel.name} (${channel.id})`,
|
||||
);
|
||||
}
|
||||
await startRecording(client, channel as any);
|
||||
|
||||
// Start Webserver
|
||||
startWebserver(3000);
|
||||
// Set up player connection
|
||||
const connection = getVoiceConnection(guildId!);
|
||||
if (connection) {
|
||||
discordPlayer.setConnection(connection);
|
||||
console.log("[bot] Player connected to voice channel");
|
||||
}
|
||||
|
||||
// Start Webserver
|
||||
startWebserver(3000);
|
||||
});
|
||||
|
||||
client.on("error", (err) => {
|
||||
console.error("[bot] Client error:", err);
|
||||
console.error("[bot] Client error:", err);
|
||||
});
|
||||
|
||||
// Graceful shutdown
|
||||
process.on("SIGINT", () => {
|
||||
if (config.verbose) {
|
||||
console.log("\n[bot] Shutting down...");
|
||||
}
|
||||
client.destroy();
|
||||
process.exit(0);
|
||||
if (config.verbose) {
|
||||
console.log("\n[bot] Shutting down...");
|
||||
}
|
||||
client.destroy();
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
process.on("SIGTERM", () => {
|
||||
if (config.verbose) {
|
||||
console.log("[bot] Terminating...");
|
||||
}
|
||||
client.destroy();
|
||||
process.exit(0);
|
||||
if (config.verbose) {
|
||||
console.log("[bot] Terminating...");
|
||||
}
|
||||
client.destroy();
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
client.login(token);
|
||||
|
||||
Reference in New Issue
Block a user