-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
393 lines (353 loc) Β· 16 KB
/
index.js
File metadata and controls
393 lines (353 loc) Β· 16 KB
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
const Discord = require ('discord.js');
const config = require('./config.json');
const client = new Discord.Client();
const command = require('./command');
const { cpuUsage } = require('process');
const PREFIX = '!';
require('events').EventEmitter.defaultMaxListeners = 20;
let already_init = false;
client.on("guildMemberAdd", member => {
console.log("new member")
member.send({embed: newMemberDM})
});
// Message that is sent when the bot detects suicidal ideation
const suicidalMessageDM = {
color: '#edf5f7',
title: 'Baymax Has A Message For You',
author: {
name: 'Mental Health Bot',
icon_url: 'http://clipart-library.com/data_images/134143.gif'
},
description: `A text you have sent in a server was flagged as containing Suicidal Ideation.
We care about you, and we want to make sure you're okay!
Please look at the commands and resources below, they may help you.
If you found this message helpful or not please react with π or π`,
thumbnail: {
url: 'https://i.ibb.co/ZSWXnSW/Screen-Shot-2021-05-22-at-5-13-56-PM.png',
},
fields: [
{
name: 'National Suicide Prevention Lifeline',
value: 'https://suicidepreventionlifeline.org/',
},
{
name: 'Reasons to Live',
value: 'https://www.healthline.com/health/mental-health/reasons-to-live#Youre-not-as-alone-as-you-feel',
},
{
name: 'Self-Care Strategies',
value: 'https://www.healthline.com/health/depression/self-care-for-depression',
},
{
name: 'Type the command below for a list of commands and helpful resources',
value: '!commands',
}
],
timestamp: new Date()
};
// Message that is sent when a new user joins the server
const newMemberDM = {
color: '#edf5f7',
title: 'Baymax Has A Message For You',
author: {
name: 'Mental Health Bot',
icon_url: 'http://clipart-library.com/data_images/134143.gif'
},
description: `Welcome!`,
thumbnail: {
url: 'https://i.ibb.co/ZSWXnSW/Screen-Shot-2021-05-22-at-5-13-56-PM.png',
},
fields: [
{
name: 'Thank you for joining this server!',
value: `I am a Baymax bot. My job is to search through messages within the server chat and determine if a user seems depressed or overly stressed
I provide helpful links to those who need it, and I try my
best to give the support to people who are suffering`,
},
{
name: 'Take a look at some of the commands I offer by typing in chat:',
value: '!commands'
}]
};
// Message that is sent when the bot detects stressed ideation
const stressedMessageDM = {
color: '#edf5f7',
title: 'Baymax Has A Message For You',
author: {
name: 'Mental Health Bot',
icon_url: 'http://clipart-library.com/data_images/134143.gif'
},
description: `A text you have sent in a server was flagged as containing Stressed Ideation.
We know that life can get stressful at times, especially during school
Baymax would love if you could take a step back, breathe, and remember that everything will be okay in the end`,
thumbnail: {
url: 'https://i.ibb.co/ZSWXnSW/Screen-Shot-2021-05-22-at-5-13-56-PM.png',
},
fields: [
{
name: '101 Reasons Why It Will All Be Okay',
value: 'https://www.anniewright.com/101-reasons-will-okay/',
},
{
name: 'A Guide to Burnout',
value: 'https://www.healthline.com/health/tips-for-identifying-and-preventing-burnout',
},
{
name: '10 Simple Ways to Relieve Stress',
value: 'https://www.healthline.com/health/10-ways-to-relieve-stress',
},
{
name: '14 Instant Ways to Calm Yourself Down',
value: 'https://www.everydayhealth.com/columns/therese-borchard-sanity-break/10-quick-ways-to-calm-down/',
},
{
name: 'Type the command below for a list of commands and helpful resources',
value: '!commands',
}
],
timestamp: new Date()
};
// List of commands that a user can choose from
const listOfCommands = {
color: '#adf1ff',
title: 'Commands',
author: {
name: 'Mental Health Bot',
icon_url: 'http://clipart-library.com/data_images/134143.gif'
},
fields: [
{
name: 'Canada',
value: `!Ontario
!Quebec
!Nova Scotia
!New Brunswick
!Manitoba
!British Columbia
!Prince Edward Island
!Saskatchewan
!Alberta
!Newfoundland and Labrador
!Northwest Territories
!Yukon
!Nunavut`,
},
{
name: 'United States',
value: '!US',
},
{
name: 'Other Commands',
value: `!Hi
!gif`,
}
]
};
// On ready function + all hard coded commands
client.on('ready',() => {
console.log('client is ready!')
// List of commands
command(client, 'commands', message => {
message.channel.send({ embed: listOfCommands })
})
// All provinces and US
command(client, 'Ontario', message => {
message.channel.send('Mental Health Helpline. Call 1-866-531-2600.')
})
command(client, 'Quebec', message => {
message.channel.send('Mental Health. Visit http://sante.gouv.qc.ca/en/problemes-de-sante/sante-mentale to learn more.')
})
command(client, 'Nova Scotia', message => {
message.channel.send('Crisis Text Line is available for adults who are going through a difficult time and need someone to text with: https://www.crisistextline.org/')
})
command(client, 'New Brunswick', message => {
message.channel.send('Suicide Prevention CHIMO Helpline. Visit http://www2.gnb.ca/content/gnb/en/departments/health/Suicide_Prevention.html or call 1-800-667-5005.')
})
command(client, 'Manitoba', message => {
message.channel.send('Call the Manitoba Suicide Prevention & Support Line at 1-877-435-7170')
})
command(client, 'British Columbia', message => {
message.author.send('BC Mental Health and Substance Use Services. Call 310-6789 (310 Mental Health) or visit www.bcmhsus.ca.')
})
command(client, 'Prince Edward Island', message => {
message.channel.send('The Island Helpline provides free, confidential emotional support and crisis intervention to Islanders of all ages: 1-800-218-2885.')
})
command(client, 'Saskatchewan', message => {
message.channel.send('Mental Health and Addiction Services. Go to www.saskatchewan.ca/residents/health/accessing-health-care-services/mental-health-and-addictions-support-services for a list of local mental health and addictions services.')
})
command(client, 'Alberta', message => {
message.channel.send('Mental Health Helpline. Call 1-877-303-2642')
})
command(client, 'Newfoundland and Labrador', message => {
message.channel.send('If you are having a mental health crisis please contact the Mental Health Crisis Line at (709) 737-4668 or toll free 1-888-737-4668')
})
command(client, 'Northwest Territories', message => {
message.channel.send('The NWT Help Line offers free support to residents of the Northwest Territories, 24 hours a day, 7 days a week: 1-800-661-0844.')
})
command(client, 'Yukon', message => {
message.channel.send('Kids Help Phone: 1-800-668-6868 (toll free), Yukon Distress and Support Line: 1-800-563-0808')
})
command(client, 'Nunavut', message => {
message.channel.send('Local Nunavut Phone Number: 867.979.3333 or Toll Free Outside of Iqaluit and residents of Nunavumiut: 1.800.265.3333')
})
command(client, 'US', message => {
message.channel.send('The National Suicide Prevention Lifeline: 1-800-273-8255')
})
// Hello message
command(client, 'Hi', message => {
message.channel.send('Hey, I am Beymax, happy to help!')
})
command(client, 'pingadmins', message => {
const the_channel = message.guild.channels.cache.find(varChannel => varChannel.name === 'baymax-bot-notifs');
});
// Sending messages in mod channel
command(client, 'init', message => {
if (!already_init) {
already_init = true;
message.guild.channels.create('Baymax Bot', {
type: 'category',
position: 1,
permissionOverwrites: [
{
id: message.guild.id,
deny: ['VIEW_CHANNEL']
},
{
id: message.guild.roles.highest,
allow: ['SEND_MESSAGES', 'VIEW_CHANNEL']
}
]
}).then(category => {
message.guild.channels.create('baymax-bot-notifs', {
type: 'text',
parent: category,
permissionOverwrites: [
{
id: message.guild.id,
deny: ['VIEW_CHANNEL']
},
{
id: message.guild.roles.highest,
allow: ['SEND_MESSAGES', 'VIEW_CHANNEL']
}
]
});
}).catch(error => {
console.log(error);
});
}
});
})
// List of phrases to check for
const suicidalWords = ["I want to die", "I wanna die", "I actually want to die", "I actually wanna die",
"I can't do this", "I actually want to die rn", "I actually wanna die rn",
"I cant do this", "kill myself", "kms", "end my life", "I dont want to wakeup",
"goodbye world", "I dont want to live", "I never want to wake up", "this is the end", "i cant do this anymore",
"I dont want to be alive", "i dont wanna be alive", "i can't do this anymore", "i can't keep going", "i cant go on anymore"];
const stressfulWords= ["stressed", "too much work", "too busy", "no time", "everything sucks",
"I hate everything", "I have so much", "I have so much to do", "I have no time",
"I will never get this done", "Why is there so much work", "I can't even sleep", "I literally can't sleep", "I hate this",
"why always me", "why me", "so much work", "so busy", "don't have time for anything", "im buried", "i'm buried",
"i literally cant sleep"];
const gifs = [
'https://i.imgur.com/P4415fF.gif', //penguin
'https://i.imgur.com/HLSQLQ2.gif', //ghost
'https://i.imgur.com/bkhs8qE.jpeg', //panda
'https://i.imgur.com/xvE2pyy.jpeg', //chick
'https://64.media.tumblr.com/65c8e5abcf8690a94519a781077687fd/tumblr_p2wag5u61k1qc4uvwo1_500.gifv', //multiple
'https://64.media.tumblr.com/4ebe8e53e9de517ca556b397aaa4a4be/377d106051e4ed6b-b3/s500x750/bae3ccb1c2c5b5d5824863d18bf9c68782eca3b4.jpg', //turtle
'https://64.media.tumblr.com/cc07f3a8a8ff087a739a0ccd4d9f254c/d4f9b40f1be7a526-ea/s500x750/67e6f2d418356e3239afb1c4bf822ba29c57f7a5.jpg', //chicksun
'https://64.media.tumblr.com/70fdcd63f1650278205782fc83fb9e4a/08c943f81ee2c4c4-d2/s500x750/deac6ba0a3320fa4a8db4b9ef2e8f83df2811af4.jpg'
];
let timecheck = new Date(2003, 05, 05);
let msgId = [];
let counter = 0;
let msgId2 = [];
client.on('message', message => {
let suicidalWordFound = false;
let stressfulWordFound = false;
for (let i = 0 ; i < suicidalWords.length ; i++){
if (message.content.toLowerCase().includes(suicidalWords[i].toLowerCase())){
console.log("it has a sad word");
// if a suicidal word is found
suicidalWordFound = true;
message.author.send({ embed: suicidalMessageDM }).then(msg => {
msgId.push(msg.id);
msg.react("π");
msg.react("π");
}).catch(error => {
const the_channel = message.guild.channels.cache.find(varChannel => varChannel.name === 'baymax-bot-notifs');
the_channel.send(`${message.author.tag} has been saying things that potentially signal suicidal behavior. Their dm's are closed. Please reach out and ask them to dm this bot '!command' if needed.`);
});
break; // if one word is found then exit after, dont keep looping
}
}
if (!suicidalWordFound){
for (let i = 0 ; i < stressfulWords.length ; i++){
if (message.content.toLowerCase().includes(stressfulWords[i].toLowerCase())){
// if a stressed word is found
stressfulWordFound = true;
message.author.send({ embed: stressedMessageDM }).then(message => {
msgId2.push(message.id);
message.react("π");
message.react("π");
}).catch(error => {
const the_channel2 = message.guild.channels.cache.find(varChannel => varChannel.name === 'baymax-bot-notifs');
the_channel2.send(`${message.author.tag} has been saying things that potentially signal depressed behavior. Their dm's are closed. Please reach out and ask them to dm this bot '!command' if needed.`);
});
break; // if one word is found then exit after, dont keep looping
}
}
}
if ((stressfulWordFound || suicidalWordFound) && message.author.bot) {
let minelapsed = (message.createdAt.getTime()-timecheck.getTime())/(1000*60);
console.log(minelapsed);
console.log(counter +' me');
if (minelapsed>=60){
counter = 0;
}else{
counter++;
}
timecheck = message.createdAt;
}
if (counter>=3) {
const gif = gifs[Math.floor(Math.random() * gifs.length)];
const newEmbed = new Discord.MessageEmbed()
.setImage(gif)
.setTitle('Hello! Heres a nice gif for you:')
.setColor('#304281');
message.channel.send(newEmbed);
counter = 0;
console.log(counter);
}
let args = message.content.substring(PREFIX.length).split(/\s+/);
switch(args[0]){
case 'gif':
const gif = gifs[Math.floor(Math.random() * gifs.length)];
const newEmbed = new Discord.MessageEmbed()
.setImage(gif)
.setTitle('Hello! Heres a nice gif for you:')
.setColor('#304281');
console.log('check')
message.channel.send(newEmbed);
break;
}
});
client.on('messageReactionAdd', (reaction, user) => {
if(user.id !== client.user.id) {
if(reaction.message.id === msgId[0] && reaction.emoji.name == "π") {
user.send(`I'm glad I could help! \nPlease utilize the links above, along with other resources by typing !command`);
const the_channel = client.channels.cache.find(varChannel => varChannel.name === 'baymax-bot-notifs');
the_channel.send(`${user.tag} has been saying things that potentially signal suicidal behavior. Please reach out.`);
} else if(reaction.message.id === msgId[0] && reaction.emoji.name == "π") {
user.send("Sorry for the inconvenience, but always remember you are wanted and loved β€οΈ");
} else if(reaction.message.id === msgId2[0] && reaction.emoji.name == "π") {
user.send(`I'm glad I could help! \nPlease utilize the links above, along with other resources by typing !command`);
const the_channel = client.channels.cache.find(varChannel => varChannel.name === 'baymax-bot-notifs');
the_channel.send(`${user.tag} has been saying things that potentially signal depressed behavior. Please reach out.`);
} else if(reaction.message.id === msgId2[0] && reaction.emoji.name == "π") {
user.send("Sorry for the inconvenience, but always remember you are wanted and loved β€οΈ");
}
}
});
client.login(config.token)