이세린

Wrote basic checklist. Need to optimize.

1 const Discord = require('discord.js'); 1 const Discord = require('discord.js');
2 +
3 +module.exports = {
4 + name: 'checklist',
5 + description: 'Go through anxiety help checklist',
6 + async run(client, message, args){
7 + const start = '🧡';
8 + const next1 = '💛';
9 + const next2 = '💚';
10 + const next3 = '💙';
11 + var listnum = 0;
12 + const checklistlist = [
13 + "First, breathe deeply",
14 + "Have a glass of water",
15 + "Do neck and shoulder stretches",
16 + "I hope this helped. You got this!"
17 + ];
18 +
19 +
20 + message.channel.send("We'll go through a checklist to help with anxiety. Click the heart to continue.").then(reactmessage => {
21 + reactmessage.react(start);
22 + });
23 +
24 + client.on('messageReactionAdd', async(reaction, user) =>{
25 + if (reaction.message.partial) await reaction.message.fetch();
26 + if (reaction.partial) await reaction.fetch();
27 + if (user.bot) return;
28 + if (!reaction.message.guild) return;
29 +
30 + if (reaction.emoji.name === start){
31 + if (listnum <= checklistlist.length){
32 + message.channel.send(checklistlist[listnum]).then(reactmessage =>{
33 + reactmessage.react(next1);
34 + });
35 + message.channel.send(';breathe');
36 + listnum++;
37 + }
38 + }
39 + if (reaction.emoji.name === next1){
40 + if (listnum <= checklistlist.length){
41 + message.channel.send(checklistlist[listnum]).then(reactmessage =>{
42 + reactmessage.react(next2);
43 + });
44 + listnum++;
45 + }
46 + }
47 + if (reaction.emoji.name === next2){
48 + if (listnum <= checklistlist.length){
49 + message.channel.send(checklistlist[listnum]).then(reactmessage =>{
50 + reactmessage.react(next3);
51 + });
52 + message.channel.send('https://media.istockphoto.com/vectors/neck-shoulder-spine-exercise-isolated-set-vector-flat-cartoon-graphic-vector-id1221242499?k=20&m=1221242499&s=612x612&w=0&h=M8ea84Lp3lrPxlPGU6OkFpz0NwUXEynRSa11yisn6KQ=');
53 + listnum++;
54 + }
55 + }
56 + if (reaction.emoji.name === next3){
57 + if (listnum <= checklistlist.length){
58 + message.channel.send(checklistlist[listnum]);
59 + listnum = 0;
60 + }
61 + }
62 + });
63 + }
64 +}
65 +
66 +// FIX: while loop not working for using same emoji??
...\ No newline at end of file ...\ No newline at end of file
......