-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
283 lines (275 loc) · 8.91 KB
/
main.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
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
//MADE BY FeAr#0577 github.com/fearek
//DO NOT REMOVE THIS AND DONT EVEN TRY TO CLAIM THIS CODE AS YOUR OWN
//YOU ARE ALLOWED TO EDIT THIS CODE, HOST BOT ON YOUR OWN ETC ON THE BASIS THAT YOU RESHARE THE SOURCE CODE WITH THESE COMMENTS
const ghosts = [
{
"type": "Banshee",
"evidence": [1, 3, 4],
"strength": "• Only targets one person at a time",
"weakness": "• Fears the Crucifix and are less aggressive near one"
},
{
"type": "Demon",
"evidence": [1, 2, 5],
"strength": "• Attack more often than any other ghost",
"weakness": "• Asking as Demon successful Ouija board questions won't lower your sanity"
},
{
"type": "Goryo",
"evidence": [6, 1, 4],
"strength": "• A Goryo will usually only show itself on camera if there are no people nearby",
"weakness": "• They are rarely seen far from their place of death"
},
{
"type": "Hantu",
"evidence": [1, 3, 5],
"strength": "• Lower temperatures can cause the Hantu to move at faster speeds.",
"weakness": "• A Hantu will move slower in warm areas."
},
{
"type": "Jinn",
"evidence": [6, 1, 5],
"strength": "• Travels at a faster speed if victim is far away",
"weakness": "• Turning off power source will prevent the Jinn from using its ability"
},
{
"type": "Myling",
"evidence": [6, 1, 2],
"strength": "• Known to be quieter when hunting",
"weakness": "• More frequently make paranormal sounds"
},
{
"type": "Mare",
"evidence": [7, 3, 2],
"strength": "• Increased chance to attack in the dark",
"weakness": "• Turning the lights on lowers its chance to attack"
},
{
"type": "Oni",
"evidence": [6, 5, 4],
"strength": "• Can move objects and are more active with people nearby",
"weakness": "• Is easy to find and identify due to being very active"
},
{
"type": "Poltergeist",
"evidence": [7, 1, 2],
"strength": "• Throws a huge amount of objects at once",
"weakness": "• Ineffective in an empty room"
},
{
"type": "Phantom",
"evidence": [7, 1, 4],
"strength": "• Sanity drops considerably when looking at a Phantom",
"weakness": "• Taking a photo of a Phantom will make it temporarily disappear"
},
{
"type": "Revenant",
"evidence": [3, 2, 5],
"strength": "• Travels significantly faster when hunting a victim",
"weakness": "• Hiding from a Revenant causes it to move very slowly"
},
{
"type": "Shade",
"evidence": [6, 2, 5],
"strength": "• Shy, making it difficult to locate",
"weakness": "• Will not enter hunting mode with multiple people nearby"
},
{
"type": "Spirit",
"evidence": [6, 7, 2],
"strength": "• None",
"weakness": "• Smudge Sticks will stop it from attacking for a long period of time."
},
{
"type": "Wraith",
"evidence": [6, 7, 4],
"strength": "• Can't be tracked by footsteps",
"weakness": "• Toxic reaction to salt"
},
{
"type": "Yurei",
"evidence": [3, 5, 4],
"strength": "• Have a stronger effect on your sanity",
"weakness": "• Using Smudge Sticks on a Yurei's room will prevent it from wandering for a long time"
},
{
"type": "Yokai",
"evidence": [7, 3, 4],
"strength": "• Talking near a Yokai will anger it and increase its chance of attacking.",
"weakness": "• When hunting, a Yokai can only hear voices close to it."
}
]
function convertToEvidence(x)
{
switch(x)
{
case 1:
return "Fingerprints"
case 2:
return "Ghost Writing"
case 3:
return "Ghost Orbs"
case 4:
return "DOTS Projector"
case 5:
return "Freezing temperatures"
case 6:
return "EMF Level 5"
case 7:
return "Spirit Box"
default:
return "Error"
}
}
function getEvidence(evlist)
{
let evidencestr = evlist.map(function (x) {
return convertToEvidence(x);
});
return evidencestr
}
function uniq(a) {
var seen = {};
return a.filter(function(item) {
return seen.hasOwnProperty(item) ? false : (seen[item] = true);
});
}
function getLeftEvidence(chosenval,ghostval)
{
let leftevidence = ghostval.filter( function( el ) {
return !chosenval.includes( el );
} );
return leftevidence;
}
function getGhost(values)
{
let intvalues = values.map(function (x) {
return parseInt(x, 10);
});
let keys = []
let chosenevidence = getEvidence(intvalues)
keys.push(`Chosen evidence: ${chosenevidence.toString()}\n`)
let leftevidence = []
let ghostevidenceint = []
let found = 0
for(let k in ghosts)
{
let vSet = new Set(ghosts[k]["evidence"])
let ifcontains = intvalues.every(value => vSet.has(value))
if(ifcontains == true)
{
let ghostevidence = getEvidence(ghosts[k]["evidence"])
ghostevidenceint = ghostevidenceint.concat(ghosts[k]["evidence"].map(function (x) {
return parseInt(x, 10);
}));
keys.push(`\nType: ${ghosts[k]["type"]}\n Strength: ${ghosts[k]["strength"]}\n Weakness: ${ghosts[k]["weakness"]}\n Evidence: ${ghostevidence.toString()}\n`)
found++
}
delete vSet
}
if(found <= 0)
{
keys.push("No ghosts with that evidence.")
return keys;
}
ghostevidenceint = uniq(ghostevidenceint)
leftevidence = getLeftEvidence(intvalues,ghostevidenceint)
leftevidence = getEvidence(leftevidence)
if(leftevidence.length === 0)
{
leftevidence[0] = " You got all of the evidence."
}
keys.push(`\nEvidence left to check: ${leftevidence}`)
return keys;
}
// RUN THIS ONCE WHEN YOU START YOUR BOT, IT CAN BUG IT WHEN YOU RUN IT EVERYTIME YOUR BOT LAUNCHES
/*const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const commands = [{
name: 'evidence',
description: 'Start the evidence selector'
}];
const rest = new REST({ version: '9' }).setToken('YOUR TOKEN HERE');
(async () => {
try {
console.log('Started refreshing application (/) commands.');
await rest.put(
Routes.applicationCommands("YOUR BOT APP ID HERE"),
{ body: commands },
);
console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
})();*/
const { Client, Intents, MessageActionRow, MessageSelectMenu } = require('discord.js');
const client = new Client({
disableEveryone: true,
intents: [Intents.FLAGS.GUILDS,Intents.FLAGS.GUILD_MEMBERS,Intents.FLAGS.GUILD_INVITES,Intents.FLAGS.GUILD_MESSAGES,Intents.FLAGS.DIRECT_MESSAGES],
partials: ['MESSAGE','CHANNEL']
});
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on('interactionCreate', async interaction => {
if(interaction.isSelectMenu())
{
if(interaction.customId === 'select')
{
await interaction.reply({content: "Wait..."});
let ghost = getGhost(interaction.values)
try{
await interaction.editReply({ content: `${interaction.user.toString()}\n${ghost.join(" ")}`, components: [] });
}
catch(err)
{
await interaction.editReply({ content: `${interaction.user.toString()}\nNo ghost.`});
}
}
}
if (interaction.isCommand())
{
if (interaction.commandName === 'evidence') {
const row = new MessageActionRow()
.addComponents(
new MessageSelectMenu()
.setCustomId('select')
.setPlaceholder('Nothing selected')
.setMinValues(1)
.setMaxValues(3)
.addOptions([
{
label: 'Fingerprints',
value: '1',
},
{
label: 'Ghost Writing',
value: '2',
},
{
label: 'Ghost Orbs',
value: '3',
},
{
label: 'DOTS Projector',
value: '4',
},
{
label: 'Freezing temperatures',
value: '5',
},
{
label: 'EMF Level 5',
value: '6',
},
{
label: 'Spirit Box',
value: '7',
},
]),
);
await interaction.reply({ content: 'Select evidence:', components: [row] });
}
}
});
client.login('YOUR TOKEN HERE');