forked from ieee-uottawa/SITE-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
46 lines (37 loc) · 1.23 KB
/
index.ts
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
import Discord from "discord.js";
import dotenv from "dotenv";
import express from "express";
import { handleMessage } from "./commands";
import { Message } from "discord.js";
/**
* ATTENTION, CONTRIBUTORS!
* ========================
* To add functionality to this bot, please create a file in /commands
* that exports an object with type "Command". See the tutorial for more
* details. Please do not modify this file.
*/
export const client = new Discord.Client();
client.once("ready", () => {
console.log("Logged in to Discord! The bot should be available now.");
});
client.on("message", (message: Message) => {
// Don't respond to other bots.
if (message.author.bot) return;
// Return an empty string (no key) if message does not start with a bang.
if (!message.content.startsWith("!")) return;
handleMessage(message);
});
dotenv.config();
// This Discord client call should come last.
client.login(process.env.DISCORD_API_KEY);
/**
* Start a tiny express app at {port} to prevent Heroku from killing the service.
*/
export const app = express();
const port = process.env.PORT || 3000;
app.get("/", (req, res) => {
res.send("SITE-Bot");
});
app.listen(port, () => {
console.log(`Started express app on port ${port}.`);
});