-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
41 lines (33 loc) · 1.15 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
import dotenv from "dotenv";
dotenv.config();
import { Client, Intents} from "discord.js";
import fs from "fs";
const TOKEN = process.env.DISCORD_TOKEN;
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_VOICE_STATES] });
const eventFiles = fs.readdirSync("./events").filter(file => file.endsWith(".js"));
for (const file of eventFiles) {
let { name, once, execute } = await import(`./events/${file}`);
if (once) {
client.once(name, (...args) => execute(...args));
} else {
client.on(name, (...args) => execute(...args));
}
}
client.login(TOKEN);
//spotify
//need server to listen to callbacks
import http from "http";
import { authCallback } from "./spotify/authentication.js";
const server = http.createServer();
server.on("request", (req, res) => {
res.end();
var [path, content] = req.url.split("?");
var lightsailPath = "/somehowdeadbot"; //hosting on aws lightsail changes the path
//listen to callback from initial login
if (path === `${lightsailPath}/auth/callback`) {
authCallback(content);
}
});
server.listen(5000, () => {
console.log("server start at port 5000");
});