permanent-waves/index.js
2024-07-20 14:41:35 -05:00

41 lines
1.6 KiB
JavaScript

import chalk from 'chalk';
import Discord, { GatewayIntentBits } from 'discord.js';
import { Track } from "./track";
import { MusicSubscription } from './subscription';
import { configs } from "./configs.ts";
import { parseCommand } from "./commands.ts";
import { helpCommand } from "./commands/help.ts";
import { leaveCommand } from "./commands/leave.ts";
import { loopCommand } from "./commands/loop.ts";
import { npCommand } from "./commands/np.ts";
import { pauseCommand, stopCommand } from "./commands/pause.ts";
import { playCommand } from "./commands/play.ts";
import { skipCommand } from "./commands/skip.ts";
import { unloopCommand } from "./commands/unloop.ts";
export const client = new Discord.Client({ intents: [GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.GuildMessages, GatewayIntentBits.Guilds] });
export const subscriptions = new Map();
client.on('ready', () => {
//await registerCommands(bot);
console.log(`${chalk.cyan("permanent waves")} is ready to go`);
});
client.on('interactionCreate', async (interaction) => {
if (!interaction.isCommand() || !interaction.guildId) return;
let subscription = subscriptions.get(interaction.guildId);
parseCommand(interaction, subscription);
});
client.on('error', (e) => {
console.warn;
console.log(e);
});
void client.login(configs.discord_token);
async function registerCommands() {
//console.log(await upsertGlobalApplicationCommands(bot, [helpCommand, leaveCommand, loopCommand, npCommand, pauseCommand, playCommand, skipCommand, stopCommand, unloopCommand]));
}