-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.js
117 lines (117 loc) · 3.17 KB
/
bot.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// const {
// Pool
// } = require('pg');
// const {
// saveSpinPlayerName,
// playerExists,
// resetSpinPlayers,
// getSpinWinners,
// playerWinners
// } = require("./db");
//
// const dotenv = require('dotenv');
// const mydbkey = process.env.DATABASE_URL;
// const Discord = require("discord.js");
// const dsbot = process.env.DS_BOT;
//
//
// const client = new Discord.Client({
// allowedMentions: {
// parse: ['users', 'roles'],
// repliedUser: true
// },
// intents: [
// "GUILDS",
// "GUILD_MESSAGES",
// "GUILD_PRESENCES",
// "GUILD_MEMBERS",
// "GUILD_MESSAGE_REACTIONS"
// ],
// });
//
// client.on('ready', () => {
// console.log("i ready!");
// });
//
//
// client.on('message', (receivedMessage) => {
// if (receivedMessage.author == client.user) {
// return
// }
//
// if (receivedMessage.content.startsWith("!")) {
// processCommand(receivedMessage);
// }
// })
//
//
// function processCommand(receivedMessage) {
// let fullCommand = receivedMessage.content.substr(1);
// let splitCommand = fullCommand.split(" ");
// let primaryCommand = splitCommand[0];
// let arguments = splitCommand.slice(1);
//
// switch(primaryCommand) {
// case "help":
// helpCommand(arguments, receivedMessage);
// break;
// case "multiply":
// multiplyCommand(arguments, receivedMessage);
// break;
// case "bing":
// receivedMessage.channel.send("bong");
// break;
// case "spin":
// const thirdWord = receivedMessage.content.trim().split(' ')[1];
// saveSpinPlayerName(thirdWord);
// receivedMessage.channel.send("Oh my swirls!! My bits are spinning! (" + thirdWord + " recorded for raffle)");
// break;
// default:
// receivedMessage.channel.send("Does not compute! Try `!help` or `!spin yourwax.wam`");
// }
//
//
// /* if (primaryCommand == "help") {
// helpCommand(arguments, receivedMessage);
// } else if (primaryCommand == "multiply") {
// multiplyCommand(arguments, receivedMessage);
// } else if (primaryCommand == "bing") {
// receivedMessage.channel.send("bong");
// } else {
// receivedMessage.channel.send("Does not compute! Try `!help` or `!multiply`");
// } */
//
// }
//
// client.login(dsbot);
//
// // ------------------------------------------------------
// // WEB SOCKET SERVER
// // ------------------------------------------------------
// const WebSocket = require('ws');
//
// const PORT = process.env.PORT || 3000;
//
// const wsServer = new WebSocket.Server({
// port: PORT
// });
//
// wsServer.on('connection', function(socket) {
// // Some feedback on the console
// console.log("A client just connected");
//
// // Attach some behavior to the incoming socket
// socket.on('message', function(msg) {
// console.log("Received message from client: " + msg);
// // socket.send("Take this back: " + msg);
//
// // Broadcast that message to all connected clients
// wsServer.clients.forEach(function(client) {
// client.send(msg);
// });
//
// });
//
// });
//
// console.log((new Date()) + " Server is listening on port " + PORT);