-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
60 lines (60 loc) · 1.77 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
48
49
50
51
52
53
54
55
56
57
58
59
60
"use strict";
require("dotenv").config();
const Routes = require("./Requests/routes");
const CR = require("./Model/customResponses");
const Discord = require("discord.js");
const _TOKEN = String(process.env.TOKEN);
const client = new Discord.Client({
/*
Intents 'GUILDS' is required
if you wish to receive (message) events
from guilds as well.
*/
intents: [
Discord.Intents.FLAGS.GUILDS,
Discord.Intents.FLAGS.DIRECT_MESSAGES,
Discord.Intents.FLAGS.GUILD_MESSAGES,
],
/*
You have to include partials
to receive messages from Channel and DM
*/
partials: ["USER", "MESSAGE", "CHANNEL"],
});
/**
* Shows the connection was successful with discord.
*/
client.on("ready", (msg) => {
console.log("Bot connected as " + msg.user.tag);
});
/**
* Responds to messages from channel and direct message
*/
client.on("messageCreate", (msg) => {
if (!msg.author.bot && msg.content.startsWith("~")) {
//splits the msg into an array of ['',{help-code},{url}]
let args = msg.content.split(/[~,\s++]/);
let routing = args[1];
let url;
let isPrivate = false;
if (args.length === 4) {
url = args[1];
if (args[2] === "private") {
isPrivate = true;
}
Routes.Navigate(msg, routing, isPrivate, url);
}
else if (args.length === 3) {
url = args[2];
Routes.Navigate(msg, routing, isPrivate, url);
}
else {
msg.reply(CR.DefaultResponse + "\n" + CR.HelpCodes);
}
// let route: string = args[1];
// let isPrivate: boolean = false;
// let url: string = args[2];
// route(msg, args[1], false, args[2]);
}
});
client.login(_TOKEN);