-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
47 lines (38 loc) · 1.31 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { Player } from 'discord-player';
import { Client, GatewayIntentBits } from 'discord.js';
import { YoutubeiExtractor } from 'discord-player-youtubei';
import dotenv from 'dotenv';
import { loader } from './src/utils/loader.js';
import { events } from './src/utils/events.js';
import config from './config.js';
// Load environment variables
dotenv.config();
global.client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.MessageContent,
],
disableMentions: 'everyone',
});
client.config = config;
const player = new Player(client, client.config.opt.discordPlayer);
await player.extractors.register(YoutubeiExtractor, {
// authentication: process.env.YT_CREDENTIAL,
authentication: undefined,
streamOptions: {
useClient: 'ANDROID',
},
});
await player.extractors.loadDefault((ext) => ext !== 'YouTubeExtractor');
loader();
events();
client.login(process.env.TOKEN);
// Prevent crash on unhandled promise rejection
process.on('unhandledRejection', (reason) => console.error(reason));
// Prevent crash on uncaught exception
process.on('uncaughtException', (error) => console.error(error));
// Log warning
process.on('warning', (warning) => console.error(warning));