How to use fs.unlink method in Appium Android Driver

Best JavaScript code snippet using appium-android-driver

Run Appium Android Driver automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

conflate.test.js

Source: conflate.test.js Github

copy
1'use strict';
2
3const ReadLine = require('n-readlines');
4const worker = require('../index').conflate;
5
6const test = require('tape');
7const path = require('path');
8const fs = require('fs');
9
10const db = require('./lib/db');
11db.init(test);
12
13test('conflate - in_persistent argument error', (t) => {
14    t.throws(() => worker(), /in_persistent argument is required/);
15    t.end();
16});
17
18test('conflate - in_address argument error', (t) => {
19    t.throws(() => worker({
20        'in_persistent': path.resolve(__dirname, './fixtures/dc-persistent.geojson')
21    }), /in_address argument is required/);
22    t.end();
23});
24
25test('conflate - output argument error', (t) => {
26    t.throws(() => worker({
27        'in_persistent': path.resolve(__dirname, './fixtures/dc-persistent.geojson'),
28        'in_address': path.resolve(__dirname, './fixtures/dc-new.geojson')
29    }), /Output file required/);
30    t.end();
31});
32
33test('conflate - CREATE finds only exact duplicate features, adds nothing', (t) => {
34    // Ensure files don't exist before test
35    try {
36        fs.unlinkSync('/tmp/output.geojson');
37        fs.unlinkSync('/tmp/error-persistent');
38    } catch (err) {
39        console.error('ok - cleaned tmp files');
40    }
41
42    worker({
43        'in_persistent': path.resolve(__dirname, './fixtures/dc-persistent.geojson'),
44        'in_address': path.resolve(__dirname, './fixtures/dc-persistent.geojson'),
45        output: '/tmp/output.geojson',
46        'error_persistent': '/tmp/error-persistent',
47        context: {
48            country: 'us',
49            region: 'dc',
50            languages: ['en']
51        },
52        db: 'pt_test'
53    });
54
55    const rl = new ReadLine('/tmp/output.geojson');
56
57    t.notOk(rl.next(), 'no output features');
58    t.doesNotThrow(() => {
59        fs.accessSync('/tmp/error-persistent');
60    });
61
62    fs.unlinkSync('/tmp/output.geojson');
63    fs.unlinkSync('/tmp/error-persistent');
64    t.end();
65});
66
67test('conflate - CREATE finds features with same address number and street less than 1km away, adds nothing', (t) => {
68    // Ensure files don't exist before test
69    try {
70        fs.unlinkSync('/tmp/output.geojson');
71        fs.unlinkSync('/tmp/error-persistent');
72    } catch (err) {
73        console.error('ok - cleaned tmp files');
74    }
75
76    worker({
77        'in_persistent': path.resolve(__dirname, './fixtures/dc-persistent.geojson'),
78        'in_address': path.resolve(__dirname, './fixtures/dc-new-close.geojson'),
79        output: '/tmp/output.geojson',
80        'error_persistent': '/tmp/error-persistent',
81        context: {
82            country: 'us',
83            region: 'dc',
84            languages: ['en']
85        },
86        db: 'pt_test'
87    });
88
89    const rl = new ReadLine('/tmp/output.geojson');
90
91    t.notOk(rl.next(), 'no output features');
92    t.doesNotThrow(() => {
93        fs.accessSync('/tmp/error-persistent');
94    });
95
96    fs.unlinkSync('/tmp/output.geojson');
97    fs.unlinkSync('/tmp/error-persistent');
98    t.end();
99});
100
101test('conflate - CREATE finds features with same address number and street more than 1km away, add new address', (t) => {
102    // Ensure files don't exist before test
103    try {
104        fs.unlinkSync('/tmp/output.geojson');
105        fs.unlinkSync('/tmp/error-persistent');
106    } catch (err) {
107        console.error('ok - cleaned tmp files');
108    }
109
110    worker({
111        'in_persistent': path.resolve(__dirname, './fixtures/dc-persistent.geojson'),
112        'in_address': path.resolve(__dirname, './fixtures/dc-new-far.geojson'),
113        output: '/tmp/output.geojson',
114        'error_persistent': '/tmp/error-persistent',
115        context: {
116            country: 'us',
117            region: 'dc',
118            languages: ['en']
119        },
120        db: 'pt_test'
121    });
122
123    const rl = new ReadLine('/tmp/output.geojson');
124    t.deepEquals(JSON.parse(rl.next()), {
125        action: 'create',
126        type: 'Feature',
127        properties: {
128            number: '108',
129            street: [{
130                display: '4th St NE',
131                priority: -1
132            }]
133        },
134        geometry: {
135            type: 'Point',
136            coordinates: [-77.00055599212646, 38.880443352851955]
137        }
138    });
139
140    t.notOk(rl.next(), '1 output feature');
141    t.doesNotThrow(() => {
142        fs.accessSync('/tmp/error-persistent');
143    });
144
145    fs.unlinkSync('/tmp/output.geojson');
146    fs.unlinkSync('/tmp/error-persistent');
147    t.end();
148});
149
150test('conflate - CREATE finds feature with different address number and street, adds new address', (t) => {
151    // Ensure files don't exist before test
152    try {
153        fs.unlinkSync('/tmp/output.geojson');
154        fs.unlinkSync('/tmp/error-persistent');
155    } catch (err) {
156        console.error('ok - cleaned tmp files');
157    }
158
159    worker({
160        'in_persistent': path.resolve(__dirname, './fixtures/dc-persistent.geojson'),
161        'in_address': path.resolve(__dirname, './fixtures/dc-new.geojson'),
162        output: '/tmp/output.geojson',
163        'error_persistent': '/tmp/error-persistent',
164        context: {
165            country: 'us',
166            region: 'dc',
167            languages: ['en']
168        },
169        db: 'pt_test'
170    });
171
172    const rl = new ReadLine('/tmp/output.geojson');
173
174    t.deepEquals(JSON.parse(rl.next()), {
175        action: 'create',
176        type: 'Feature',
177        properties: {
178            number: '112',
179            street: [{
180                display: '4th St NE',
181                priority: -1
182            }]
183        },
184        geometry: {
185            type: 'Point',
186            coordinates: [-77.00080543756485, 38.89128752230519]
187        }
188    });
189
190    t.notOk(rl.next(), 'output 1 feature');
191    t.doesNotThrow(() => {
192        fs.accessSync('/tmp/error-persistent');
193    });
194
195    fs.unlinkSync('/tmp/output.geojson');
196    fs.unlinkSync('/tmp/error-persistent');
197    t.end();
198});
199
200test('conflate - MODIFY adds new names to existing address names preferencing new names', (t) => {
201    // Ensure files don't exist before test
202    try {
203        fs.unlinkSync('/tmp/output.geojson');
204        fs.unlinkSync('/tmp/error-persistent');
205    } catch (err) {
206        console.error('ok - cleaned tmp files');
207    }
208
209    worker({
210        'in_persistent': path.resolve(__dirname, './fixtures/dc-persistent-syns.geojson'),
211        'in_address': path.resolve(__dirname, './fixtures/dc-modify.geojson'),
212        output: '/tmp/output.geojson',
213        'error_persistent': '/tmp/error-persistent',
214        context: {
215            country: 'us',
216            region: 'dc',
217            languages: ['en']
218        },
219        db: 'pt_test'
220    });
221
222    const rl = new ReadLine('/tmp/output.geojson');
223
224    t.deepEquals(JSON.parse(rl.next()), {
225        id: 1,
226        version: 2,
227        action: 'modify',
228        type: 'Feature',
229        properties: {
230            number: 108,
231            street: [{
232                display: '4th Street Northeast',
233                priority: -1
234            }, {
235                display: 'DC Route 101',
236                priority: -2
237            }, {
238                display: 'Main St',
239                priority: -2
240            }]
241        },
242        geometry: {
243            type: 'Point',
244            coordinates: [-77.0008054375648, 38.8912875223052]
245        }
246    });
247
248    t.notOk(rl.next(), 'output 1 feature');
249    t.doesNotThrow(() => {
250        fs.accessSync('/tmp/error-persistent');
251    });
252
253    fs.unlinkSync('/tmp/output.geojson');
254    fs.unlinkSync('/tmp/error-persistent');
255    t.end();
256});
257
258test('conflate - MODIFY does not update existing address, no new names are added', (t) => {
259    // Ensure files don't exist before test
260    try {
261        fs.unlinkSync('/tmp/output.geojson');
262        fs.unlinkSync('/tmp/error-persistent');
263    } catch (err) {
264        console.error('ok - cleaned tmp files');
265    }
266
267    worker({
268        'in_persistent': path.resolve(__dirname, './fixtures/dc-persistent-syns.geojson'),
269        'in_address': path.resolve(__dirname, './fixtures/dc-persistent.geojson'),
270        output: '/tmp/output.geojson',
271        'error_persistent': '/tmp/error-persistent',
272        context: {
273            country: 'us',
274            region: 'dc',
275            languages: ['en']
276        },
277        db: 'pt_test'
278    });
279
280    const rl = new ReadLine('/tmp/output.geojson');
281
282    t.notOk(rl.next(), 'no output features');
283    t.doesNotThrow(() => {
284        fs.accessSync('/tmp/error-persistent');
285    });
286
287    fs.unlinkSync('/tmp/output.geojson');
288    fs.unlinkSync('/tmp/error-persistent');
289    t.end();
290});
291
292test('conflate - MODIFY handles multiple updates to the same feature', (t) => {
293    // Ensure files don't exist before test
294    try {
295        fs.unlinkSync('/tmp/output.geojson');
296        fs.unlinkSync('/tmp/error-persistent');
297    } catch (err) {
298        console.error('ok - cleaned tmp files');
299    }
300
301    worker({
302        'in_persistent': path.resolve(__dirname, './fixtures/dc-persistent.geojson'),
303        'in_address': path.resolve(__dirname, './fixtures/dc-modify-multiple.geojson'),
304        output: '/tmp/output.geojson',
305        'error_persistent': '/tmp/error-persistent',
306        context: {
307            country: 'us',
308            region: 'dc',
309            languages: ['en']
310        },
311        db: 'pt_test'
312    });
313
314    const rl = new ReadLine('/tmp/output.geojson');
315
316    t.deepEquals(JSON.parse(rl.next()), {
317        id: 1,
318        version: 2,
319        action: 'modify',
320        type: 'Feature',
321        properties: {
322            number: 108,
323            street: [{
324                display: '4th St NE',
325                priority: -1
326            }, {
327                display: 'Main St',
328                priority: -2
329            }, {
330                display: 'DC Route 101',
331                priority: -2
332            }]
333        },
334        geometry: {
335            type: 'Point',
336            coordinates: [-77.0008054375648, 38.8912875223052]
337        }
338    });
339
340    t.notOk(rl.next(), 'output 1 feature');
341    t.doesNotThrow(() => {
342        fs.accessSync('/tmp/error-persistent');
343    });
344
345    fs.unlinkSync('/tmp/output.geojson');
346    fs.unlinkSync('/tmp/error-persistent');
347    t.end();
348});
349
350test('conflate - MODIFY all properties on the existing address are preserved, including overrides, excluding street names', (t) => {
351    // Ensure files don't exist before test
352    try {
353        fs.unlinkSync('/tmp/output.geojson');
354        fs.unlinkSync('/tmp/error-persistent');
355    } catch (err) {
356        console.error('ok - cleaned tmp files');
357    }
358
359    worker({
360        'in_persistent': path.resolve(__dirname, './fixtures/dc-persistent-override.geojson'),
361        'in_address': path.resolve(__dirname, './fixtures/dc-modify.geojson'),
362        output: '/tmp/output.geojson',
363        'error_persistent': '/tmp/error-persistent',
364        context: {
365            country: 'us',
366            region: 'dc',
367            languages: ['en']
368        },
369        db: 'pt_test'
370    });
371
372    const rl = new ReadLine('/tmp/output.geojson');
373
374    t.deepEquals(JSON.parse(rl.next()), {
375        id: 1,
376        version: 2,
377        action: 'modify',
378        type: 'Feature',
379        properties: {
380            postcode: '00000',
381            accuracy: 'rooftop',
382            source: 'original-source',
383            number: 108,
384            street: [{
385                display: '4th Street Northeast',
386                priority: -1
387            }, {
388                display: 'DC Route 101',
389                priority: -2
390            }]
391        },
392        geometry: {
393            type: 'Point',
394            coordinates: [-77.0008054375648, 38.8912875223052]
395        }
396    });
397
398    t.notOk(rl.next(), 'output 1 feature');
399    t.doesNotThrow(() => {
400        fs.accessSync('/tmp/error-persistent');
401    });
402
403    fs.unlinkSync('/tmp/output.geojson');
404    fs.unlinkSync('/tmp/error-persistent');
405    t.end();
406});
407
408test('conflate - MODIFY non-street properties on the new address are not included in updates', (t) => {
409    // Ensure files don't exist before test
410    try {
411        fs.unlinkSync('/tmp/output.geojson');
412        fs.unlinkSync('/tmp/error-persistent');
413    } catch (err) {
414        console.error('ok - cleaned tmp files');
415    }
416
417    worker({
418        'in_persistent': path.resolve(__dirname, './fixtures/dc-persistent.geojson'),
419        'in_address': path.resolve(__dirname, './fixtures/dc-persistent-override.geojson'),
420        output: '/tmp/output.geojson',
421        'error_persistent': '/tmp/error-persistent',
422        context: {
423            country: 'us',
424            region: 'dc',
425            languages: ['en']
426        },
427        db: 'pt_test'
428    });
429
430    const rl = new ReadLine('/tmp/output.geojson');
431
432    t.notOk(rl.next(), 'no features output');
433    t.doesNotThrow(() => {
434        fs.accessSync('/tmp/error-persistent');
435    });
436
437    fs.unlinkSync('/tmp/output.geojson');
438    fs.unlinkSync('/tmp/error-persistent');
439    t.end();
440});
441
442test('conflate - MODIFY existing addresses with output==false are not modified', (t) => {
443    // Ensure files don't exist before test
444    try {
445        fs.unlinkSync('/tmp/output.geojson');
446        fs.unlinkSync('/tmp/error-persistent');
447    } catch (err) {
448        console.error('ok - cleaned tmp files');
449    }
450
451    worker({
452        'in_persistent': path.resolve(__dirname, './fixtures/dc-persistent-output.geojson'),
453        'in_address': path.resolve(__dirname, './fixtures/dc-modify-output.geojson'),
454        output: '/tmp/output.geojson',
455        'error_persistent': '/tmp/error-persistent',
456        context: {
457            country: 'us',
458            region: 'dc',
459            languages: ['en']
460        },
461        db: 'pt_test'
462    });
463
464    const rl = new ReadLine('/tmp/output.geojson');
465    t.notOk(rl.next(), 'no features output');
466    t.doesNotThrow(() => {
467        fs.accessSync('/tmp/error-persistent');
468    });
469
470    fs.unlinkSync('/tmp/output.geojson');
471    fs.unlinkSync('/tmp/error-persistent');
472    t.end();
473});
474
475test('conflate - MODIFY existing addresses with output==false are not modified, cardinal to non-cardinal match', (t) => {
476    // Ensure files don't exist before test
477    try {
478        fs.unlinkSync('/tmp/output.geojson');
479        fs.unlinkSync('/tmp/error-persistent');
480    } catch (err) {
481        console.error('ok - cleaned tmp files');
482    }
483
484    worker({
485        'in_persistent': path.resolve(__dirname, './fixtures/dc-persistent-output-cardinal.geojson'),
486        'in_address': path.resolve(__dirname, './fixtures/dc-modify-output-cardinal.geojson'),
487        output: '/tmp/output.geojson',
488        'error_persistent': '/tmp/error-persistent',
489        context: {
490            country: 'us',
491            region: 'dc',
492            languages: ['en']
493        },
494        db: 'pt_test'
495    });
496
497    const rl = new ReadLine('/tmp/output.geojson');
498    t.notOk(rl.next(), 'no features output');
499    t.doesNotThrow(() => {
500        fs.accessSync('/tmp/error-persistent');
501    });
502
503    fs.unlinkSync('/tmp/output.geojson');
504    fs.unlinkSync('/tmp/error-persistent');
505    t.end();
506});
507
Full Screen

test-trace-events-fs-sync.js

Source: test-trace-events-fs-sync.js Github

copy
1'use strict';
2const common = require('../common');
3const assert = require('assert');
4const cp = require('child_process');
5const fs = require('fs');
6const path = require('path');
7const util = require('util');
8
9const tests = new Array();
10
11let gid = 1;
12let uid = 1;
13
14if (!common.isWindows) {
15  gid = process.getgid();
16  uid = process.getuid();
17}
18
19tests['fs.sync.access'] = 'fs.writeFileSync("fs.txt", "123", "utf8");' +
20                          'fs.accessSync("fs.txt");' +
21                          'fs.unlinkSync("fs.txt")';
22tests['fs.sync.chmod'] = 'fs.writeFileSync("fs.txt", "123", "utf8");' +
23                         'fs.chmodSync("fs.txt",100);' +
24                         'fs.unlinkSync("fs.txt")';
25tests['fs.sync.chown'] = 'fs.writeFileSync("fs.txt", "123", "utf8");' +
26                         `fs.chownSync("fs.txt", ${uid}, ${gid});` +
27                         'fs.unlinkSync("fs.txt")';
28tests['fs.sync.close'] = 'fs.writeFileSync("fs.txt", "123", "utf8");' +
29                         'fs.unlinkSync("fs.txt")';
30tests['fs.sync.copyfile'] = 'fs.writeFileSync("fs.txt", "123", "utf8");' +
31                            'fs.copyFileSync("fs.txt","a.txt");' +
32                            'fs.unlinkSync("fs.txt")';
33tests['fs.sync.fchmod'] = 'fs.writeFileSync("fs.txt", "123", "utf8");' +
34                          'const fd = fs.openSync("fs.txt", "r+");' +
35                          'fs.fchmodSync(fd,100);' +
36                          'fs.unlinkSync("fs.txt")';
37tests['fs.sync.fchown'] = 'fs.writeFileSync("fs.txt", "123", "utf8");' +
38                          'const fd = fs.openSync("fs.txt", "r+");' +
39                          `fs.fchownSync(fd, ${uid}, ${gid});` +
40                          'fs.unlinkSync("fs.txt")';
41tests['fs.sync.fdatasync'] = 'fs.writeFileSync("fs.txt", "123", "utf8");' +
42                             'const fd = fs.openSync("fs.txt", "r+");' +
43                             'fs.fdatasyncSync(fd);' +
44                             'fs.unlinkSync("fs.txt")';
45tests['fs.sync.fstat'] = 'fs.writeFileSync("fs.txt", "123", "utf8");' +
46                         'fs.readFileSync("fs.txt");' +
47                         'fs.unlinkSync("fs.txt")';
48tests['fs.sync.fsync'] = 'fs.writeFileSync("fs.txt", "123", "utf8");' +
49                         'const fd = fs.openSync("fs.txt", "r+");' +
50                         'fs.fsyncSync(fd);' +
51                         'fs.unlinkSync("fs.txt")';
52tests['fs.sync.ftruncate'] = 'fs.writeFileSync("fs.txt", "123", "utf8");' +
53                             'const fd = fs.openSync("fs.txt", "r+");' +
54                             'fs.ftruncateSync(fd, 1);' +
55                             'fs.unlinkSync("fs.txt")';
56tests['fs.sync.futimes'] = 'fs.writeFileSync("fs.txt", "123", "utf8");' +
57                           'const fd = fs.openSync("fs.txt", "r+");' +
58                           'fs.futimesSync(fd,1,1);' +
59                           'fs.unlinkSync("fs.txt")';
60tests['fs.sync.lchown'] = 'fs.writeFileSync("fs.txt", "123", "utf8");' +
61                          `fs.lchownSync("fs.txt", ${uid}, ${gid});` +
62                          'fs.unlinkSync("fs.txt")';
63tests['fs.sync.link'] = 'fs.writeFileSync("fs.txt", "123", "utf8");' +
64                        'fs.linkSync("fs.txt", "linkx");' +
65                        'fs.unlinkSync("linkx");' +
66                        'fs.unlinkSync("fs.txt")';
67tests['fs.sync.lstat'] = 'fs.writeFileSync("fs.txt", "123", "utf8");' +
68                         'fs.lstatSync("fs.txt");' +
69                         'fs.unlinkSync("fs.txt")';
70tests['fs.sync.mkdir'] = 'fs.mkdirSync("fstemp");' +
71                         'fs.rmdirSync("fstemp")';
72tests['fs.sync.mkdtemp'] = 'const fp = fs.mkdtempSync("fstest");' +
73                           'fs.rmdirSync(fp)';
74tests['fs.sync.open'] = 'fs.writeFileSync("fs.txt", "123", "utf8");' +
75                        'fs.unlinkSync("fs.txt")';
76tests['fs.sync.read'] = 'fs.writeFileSync("fs.txt", "123", "utf8");' +
77                        'fs.readFileSync("fs.txt");' +
78                        'fs.unlinkSync("fs.txt")';
79tests['fs.sync.readdir'] = 'fs.readdirSync("./")';
80tests['fs.sync.realpath'] = 'fs.writeFileSync("fs.txt", "123", "utf8");' +
81                            'fs.linkSync("fs.txt", "linkx");' +
82                            'fs.realpathSync.native("linkx");' +
83                            'fs.unlinkSync("linkx");' +
84                            'fs.unlinkSync("fs.txt")';
85tests['fs.sync.rename'] = 'fs.writeFileSync("fs.txt", "123", "utf8");' +
86                          'fs.renameSync("fs.txt","xyz.txt"); ' +
87                          'fs.unlinkSync("xyz.txt")';
88tests['fs.sync.rmdir'] = 'fs.mkdirSync("fstemp");' +
89                         'fs.rmdirSync("fstemp")';
90tests['fs.sync.stat'] = 'fs.writeFileSync("fs.txt", "123", "utf8");' +
91                        'fs.statSync("fs.txt");' +
92                        'fs.unlinkSync("fs.txt")';
93tests['fs.sync.unlink'] = 'fs.writeFileSync("fs.txt", "123", "utf8");' +
94                          'fs.linkSync("fs.txt", "linkx");' +
95                          'fs.unlinkSync("linkx");' +
96                          'fs.unlinkSync("fs.txt")';
97tests['fs.sync.utimes'] = 'fs.writeFileSync("fs.txt", "123", "utf8");' +
98                          'fs.utimesSync("fs.txt",1,1);' +
99                          'fs.unlinkSync("fs.txt")';
100tests['fs.sync.write'] = 'fs.writeFileSync("fs.txt", "123", "utf8");' +
101                         'fs.unlinkSync("fs.txt")';
102
103// On windows, we need permissions to test symlink and readlink.
104// We'll only try to run these tests if we have enough privileges.
105if (common.canCreateSymLink()) {
106  tests['fs.sync.symlink'] = 'fs.writeFileSync("fs.txt", "123", "utf8");' +
107                             'fs.symlinkSync("fs.txt", "linkx");' +
108                             'fs.unlinkSync("linkx");' +
109                             'fs.unlinkSync("fs.txt")';
110  tests['fs.sync.readlink'] = 'fs.writeFileSync("fs.txt", "123", "utf8");' +
111                              'fs.symlinkSync("fs.txt", "linkx");' +
112                              'fs.readlinkSync("linkx");' +
113                              'fs.unlinkSync("linkx");' +
114                              'fs.unlinkSync("fs.txt")';
115}
116
117const tmpdir = require('../common/tmpdir');
118tmpdir.refresh();
119const traceFile = path.join(tmpdir.path, 'node_trace.1.log');
120
121for (const tr in tests) {
122  const proc = cp.spawnSync(process.execPath,
123                            [ '--trace-events-enabled',
124                              '--trace-event-categories', 'node.fs.sync',
125                              '-e', tests[tr] ],
126                            { cwd: tmpdir.path, encoding: 'utf8' });
127
128  // Make sure the operation is successful.
129  // Don't use assert with a custom message here. Otherwise the
130  // inspection in the message is done eagerly and wastes a lot of CPU
131  // time.
132  if (proc.status !== 0) {
133    throw new Error(`${tr}:\n${util.inspect(proc)}`);
134  }
135
136  // Confirm that trace log file is created.
137  assert(fs.existsSync(traceFile));
138  const data = fs.readFileSync(traceFile);
139  const traces = JSON.parse(data.toString()).traceEvents;
140  assert(traces.length > 0);
141
142  // C++ fs sync trace events should be generated.
143  assert(traces.some((trace) => {
144    if (trace.pid !== proc.pid)
145      return false;
146    if (trace.cat !== 'node,node.fs,node.fs.sync')
147      return false;
148    if (trace.name !== tr)
149      return false;
150    return true;
151  }));
152}
153
Full Screen

comebackCmd.js

Source: comebackCmd.js Github

copy
1function comebackCmd(message, prefix, client, member, msgChan, cmd, fileName, fs) {
2  
3  var comebackCmd = ((cmd == "faire demi-tour")||(cmd == "faire demi tour"));
4  var doorCBmsg = `à ce stade votre seul moyen de faire marche arrière est de recommencer.\nSi c'est ce que vous souhaitez, je vous invite à taper ici-même la commande: **\`!restart\`**`;
5  
6  if (comebackCmd) {
7
8  	// 4 PRINCIPALS DOORS
9    if (message.channel == chanDoor1) {
10      if ((!fs.existsSync(rep_1A + fileName) && (!fs.existsSync(rep_1B + fileName)))) { // l'utilisateur ne provient d'aucune direction
11      	return message.reply(doorCBmsg).then(reply => reply.delete(10000));
12      } else if (fs.existsSync(rep_1A + fileName)) {
13      	member.addRole(role_1A).then(addRole => member.removeRole(door1Role));
14      	if (fs.existsSync(rep_1B + fileName)) fs.unlinkSync(rep_1B + fileName)
15      } else if (fs.existsSync(rep_1B + fileName)) {
16      	member.addRole(role_1B).then(addRole => member.removeRole(door1Role));
17      	if (fs.existsSync(rep_1A + fileName)) fs.unlinkSync(rep_1A + fileName)
18      }
19
20    } else if (message.channel == chanDoor2) {
21      if ((!fs.existsSync(rep_2A + fileName) && (!fs.existsSync(rep_2B + fileName)))) { // l'utilisateur ne provient d'aucune direction
22      	return message.reply(doorCBmsg).then(reply => reply.delete(10000));
23      } else if (fs.existsSync(rep_2A + fileName)) {
24      	member.addRole(role_2A).then(addRole => member.removeRole(door2Role));
25      } else if (fs.existsSync(rep_2B + fileName)) {
26      	member.addRole(role_2B).then(addRole => member.removeRole(door2Role));
27      }
28
29    } else if (message.channel == chanDoor3) {
30      if ((!fs.existsSync(rep_3A + fileName) && (!fs.existsSync(rep_3B + fileName)))) { // l'utilisateur ne provient d'aucune direction
31      	return message.reply(doorCBmsg).then(reply => reply.delete(10000));
32      } else if (fs.existsSync(rep_3A + fileName)) {
33      	member.addRole(role_3A).then(addRole => member.removeRole(door3Role));
34      } else if (fs.existsSync(rep_3B + fileName)) {
35      	member.addRole(role_3B).then(addRole => member.removeRole(door3Role));
36      }
37
38    } else if (message.channel == chanDoor4) {
39      if ((!fs.existsSync(rep_4A + fileName) && (!fs.existsSync(rep_4B + fileName)))) { // l'utilisateur ne provient d'aucune direction
40      	return message.reply(doorCBmsg).then(reply => reply.delete(10000));
41      } else if (fs.existsSync(rep_4A + fileName)) {
42      	member.addRole(role_4A).then(addRole => member.removeRole(door4Role));
43      } else if (fs.existsSync(rep_4B + fileName)) {
44      	member.addRole(role_4B).then(addRole => member.removeRole(door4Role));
45      }
46
47    // LABYRINTHE CHANNELS
48    } else if (msgChan == chan_1A) {
49  	  if (fs.existsSync(door1UsersRep + fileName)) {
50  	    member.addRole(door1Role);
51  	    if (fs.existsSync(rep_1B + fileName)) fs.unlinkSync(rep_1B + fileName);
52  	  } else if (fs.existsSync(rep_1B + fileName)) {
53        member.addRole(role_1B);
54        if (fs.existsSync(door1UsersRep + fileName)) fs.unlinkSync(door1UsersRep + fileName);
55  	  }
56  	  member.removeRole(role_1A);
57
58    } else if (msgChan == chan_1B) {
59      if (fs.existsSync(door1UsersRep + fileName)) {
60  	    member.addRole(door1Role);
61  	    if (fs.existsSync(rep_1A + fileName)) fs.unlinkSync(rep_1A + fileName);
62  	} else if (fs.existsSync(rep_1A + fileName)) {
63      member.addRole(role_1A);
64      if (fs.existsSync(door1UsersRep + fileName)) fs.unlinkSync(door1UsersRep + fileName);
65  	} else if (fs.existsSync(rep_1D + fileName)) {
66      if (fs.existsSync(door1UsersRep + fileName)) fs.unlinkSync(door1UsersRep + fileName);
67      if (fs.existsSync(rep_1A + fileName)) fs.unlinkSync(rep_1A + fileName);
68      member.addRole(role_1D);
69  	}
70  	member.removeRole(role_1B);
71
72  } else if (msgChan == chan_1D) {
73
74    if (fs.existsSync(rep_1B + fileName)) {
75  	  member.addRole(role_1B);
76      if (fs.existsSync(rep_1E + fileName)) fs.unlinkSync(rep_1E + fileName);
77      if (fs.existsSync(rep_1F + fileName)) fs.unlinkSync(rep_1F + fileName);
78  	} else if (fs.existsSync(rep_1E + fileName)) {
79      member.addRole(role_1E);
80      if (fs.existsSync(rep_1B + fileName)) fs.unlinkSync(rep_1B + fileName);
81      if (fs.existsSync(rep_1F + fileName)) fs.unlinkSync(rep_1F + fileName);
82  	} else if (fs.existsSync(rep_1F + fileName)) {
83      member.addRole(role_1F);
84      if (fs.existsSync(rep_1B + fileName)) fs.unlinkSync(rep_1B + fileName);
85      if (fs.existsSync(rep_1E + fileName)) fs.unlinkSync(rep_1E + fileName);
86  	}
87  	member.removeRole(role_1D);
88
89  } else if (msgChan == chan_1E) {
90
91    if (fs.existsSync(rep_1D + fileName)) {
92  	  member.addRole(role_1D);
93      if (fs.existsSync(rep_1F + fileName)) fs.unlinkSync(rep_1F + fileName);
94  	} else if (fs.existsSync(rep_1F + fileName)) {
95      member.addRole(role_1F);
96      if (fs.existsSync(rep_1D + fileName)) fs.unlinkSync(rep_1D + fileName);
97  	}
98  	member.removeRole(role_1E);
99
100  } else if (msgChan == chan_1F) {
101    
102    if (fs.existsSync(rep_1D + fileName)) {
103  	  member.addRole(role_1D);
104      if (fs.existsSync(rep_1E + fileName)) fs.unlinkSync(rep_1E + fileName);
105      if (fs.existsSync(rep_2A + fileName)) fs.unlinkSync(rep_2A + fileName);
106      if (fs.existsSync(rep_2C + fileName)) fs.unlinkSync(rep_2C + fileName);
107  	} else if (fs.existsSync(rep_1E + fileName)) {
108      member.addRole(role_1E);
109      if (fs.existsSync(rep_1D + fileName)) fs.unlinkSync(rep_1D + fileName);
110      if (fs.existsSync(rep_2A + fileName)) fs.unlinkSync(rep_2A + fileName);
111      if (fs.existsSync(rep_2C + fileName)) fs.unlinkSync(rep_2C + fileName);
112  	} else if (fs.existsSync(rep_2A + fileName)) {
113      member.addRole(role_2A);
114      if (fs.existsSync(rep_1D + fileName)) fs.unlinkSync(rep_1D + fileName);
115      if (fs.existsSync(rep_1E + fileName)) fs.unlinkSync(rep_1E + fileName);
116      if (fs.existsSync(rep_2C + fileName)) fs.unlinkSync(rep_2C + fileName);
117  	} else if (fs.existsSync(rep_2C + fileName)) {
118      member.addRole(role_2C);
119      if (fs.existsSync(rep_1D + fileName)) fs.unlinkSync(rep_1D + fileName);
120      if (fs.existsSync(rep_1E + fileName)) fs.unlinkSync(rep_1E + fileName);
121      if (fs.existsSync(rep_2A + fileName)) fs.unlinkSync(rep_2A + fileName);
122  	}
123  	member.removeRole(role_1F);
124
125  } else if (msgChan == chan_2A) {
126    if (fs.existsSync(door2UsersRep + fileName)) {
127  	  member.addRole(door2Role);
128      if (fs.existsSync(rep_1F + fileName)) fs.unlinkSync(rep_1F + fileName);
129      if (fs.existsSync(rep_2B + fileName)) fs.unlinkSync(rep_2B + fileName);
130      if (fs.existsSync(rep_2C + fileName)) fs.unlinkSync(rep_2C + fileName);
131  	} else if (fs.existsSync(rep_2B + fileName)) {
132      member.addRole(role_2B);
133      if (fs.existsSync(door2UsersRep + fileName)) fs.unlinkSync(door2UsersRep + fileName);
134      if (fs.existsSync(rep_1F + fileName)) fs.unlinkSync(rep_1F + fileName);
135      if (fs.existsSync(rep_2C + fileName)) fs.unlinkSync(rep_2C + fileName);
136  	} else if (fs.existsSync(rep_2C + fileName)) {
137      member.addRole(role_2C);
138      if (fs.existsSync(door2UsersRep + fileName)) fs.unlinkSync(door2UsersRep + fileName);
139      if (fs.existsSync(rep_1F + fileName)) fs.unlinkSync(rep_1F + fileName);
140      if (fs.existsSync(rep_2B + fileName)) fs.unlinkSync(rep_2B + fileName);
141  	} else if (fs.existsSync(rep_1F + fileName)) {
142      member.addRole(role_1F);
143      if (fs.existsSync(door2UsersRep + fileName)) fs.unlinkSync(door2UsersRep + fileName);
144      if (fs.existsSync(rep_2B + fileName)) fs.unlinkSync(rep_2B + fileName);
145      if (fs.existsSync(rep_2C + fileName)) fs.unlinkSync(rep_2C + fileName);
146  	}
147  	member.removeRole(role_2A);
148
149  } else if (msgChan == chan_2B) {
150  	if (fs.existsSync(door2UsersRep + fileName)) {
151  	  member.addRole(door2Role);
152      if (fs.existsSync(rep_2A + fileName)) fs.unlinkSync(rep_2A + fileName);
153      if (fs.existsSync(rep_2C + fileName)) fs.unlinkSync(rep_2C + fileName);
154      if (fs.existsSync(rep_2D + fileName)) fs.unlinkSync(rep_2D + fileName);
155  	} else if (fs.existsSync(rep_2A + fileName)) {
156      member.addRole(role_2A);
157      if (fs.existsSync(door2UsersRep + fileName)) fs.unlinkSync(door2UsersRep + fileName);
158      if (fs.existsSync(rep_2C + fileName)) fs.unlinkSync(rep_2C + fileName);
159      if (fs.existsSync(rep_2D + fileName)) fs.unlinkSync(rep_2D + fileName);
160  	} else if (fs.existsSync(rep_2C + fileName)) {
161      member.addRole(role_2C);
162      if (fs.existsSync(door2UsersRep + fileName)) fs.unlinkSync(door2UsersRep + fileName);
163      if (fs.existsSync(rep_2A + fileName)) fs.unlinkSync(rep_2A + fileName);
164      if (fs.existsSync(rep_2D + fileName)) fs.unlinkSync(rep_2D + fileName);
165  	} else if (fs.existsSync(rep_2D + fileName)) {
166      member.addRole(role_2D);
167      if (fs.existsSync(door2UsersRep + fileName)) fs.unlinkSync(door2UsersRep + fileName);
168      if (fs.existsSync(rep_2A + fileName)) fs.unlinkSync(rep_2A + fileName);
169      if (fs.existsSync(rep_2C + fileName)) fs.unlinkSync(rep_2C + fileName);
170  	}
171  	member.removeRole(role_2B);
172
173  } else if (msgChan == chan_2C) {
174  	if (fs.existsSync(rep_1F + fileName)) {
175  	  member.addRole(role_1F);
176      if (fs.existsSync(rep_2A + fileName)) fs.unlinkSync(rep_2A + fileName);
177      if (fs.existsSync(rep_2B + fileName)) fs.unlinkSync(rep_2B + fileName);
178      if (fs.existsSync(rep_2D + fileName)) fs.unlinkSync(rep_2D + fileName);
179  	} else if (fs.existsSync(rep_2A + fileName)) {
180      member.addRole(role_2A);
181      if (fs.existsSync(rep_1F + fileName)) fs.unlinkSync(rep_1F + fileName);
182      if (fs.existsSync(rep_2B + fileName)) fs.unlinkSync(rep_2B + fileName);
183      if (fs.existsSync(rep_2D + fileName)) fs.unlinkSync(rep_2D + fileName);
184  	} else if (fs.existsSync(rep_2B + fileName)) {
185      member.addRole(role_2B);
186      if (fs.existsSync(rep_1F + fileName)) fs.unlinkSync(rep_1F + fileName);
187      if (fs.existsSync(rep_2A + fileName)) fs.unlinkSync(rep_2A + fileName);
188      if (fs.existsSync(rep_2D + fileName)) fs.unlinkSync(rep_2D + fileName);
189  	} else if (fs.existsSync(rep_2D + fileName)) {
190      member.addRole(role_2D);
191      if (fs.existsSync(rep_1F + fileName)) fs.unlinkSync(rep_1F + fileName);
192      if (fs.existsSync(rep_2A + fileName)) fs.unlinkSync(rep_2A + fileName);
193      if (fs.existsSync(rep_2B + fileName)) fs.unlinkSync(rep_2B + fileName);
194  	}
195  	member.removeRole(role_2C);
196
197  } else if (msgChan == chan_2D) {
198  	if (fs.existsSync(rep_2B + fileName)) {
199  	  member.addRole(role_2B);
200      if (fs.existsSync(rep_2C + fileName)) fs.unlinkSync(rep_2C + fileName);
201      if (fs.existsSync(rep_2E + fileName)) fs.unlinkSync(rep_2E + fileName);
202      if (fs.existsSync(rep_2F + fileName)) fs.unlinkSync(rep_2F + fileName);
203  	} else if (fs.existsSync(rep_2C + fileName)) {
204      member.addRole(role_2C);
205      if (fs.existsSync(rep_2B + fileName)) fs.unlinkSync(rep_2B + fileName);
206      if (fs.existsSync(rep_2E + fileName)) fs.unlinkSync(rep_2E + fileName);
207      if (fs.existsSync(rep_2F + fileName)) fs.unlinkSync(rep_2F + fileName);
208  	} else if (fs.existsSync(rep_2E + fileName)) {
209      member.addRole(role_2E);
210      if (fs.existsSync(rep_2B + fileName)) fs.unlinkSync(rep_2B + fileName);
211      if (fs.existsSync(rep_2C + fileName)) fs.unlinkSync(rep_2C + fileName);
212      if (fs.existsSync(rep_2F + fileName)) fs.unlinkSync(rep_2F + fileName);
213  	} else if (fs.existsSync(rep_2F + fileName)) {
214      member.addRole(role_2F);
215      if (fs.existsSync(rep_2B + fileName)) fs.unlinkSync(rep_2B + fileName);
216      if (fs.existsSync(rep_2C + fileName)) fs.unlinkSync(rep_2C + fileName);
217      if (fs.existsSync(rep_2E + fileName)) fs.unlinkSync(rep_2E + fileName);
218  	}
219  	member.removeRole(role_2D);
220
221  } else if (msgChan == chan_2E) {
222  	if (fs.existsSync(rep_2D + fileName)) {
223  	  member.addRole(role_2D);
224      if (fs.existsSync(rep_2F + fileName)) fs.unlinkSync(rep_2F + fileName);
225      if (fs.existsSync(rep_3H + fileName)) fs.unlinkSync(rep_3H + fileName);
226  	} else if (fs.existsSync(rep_2F + fileName)) {
227      member.addRole(role_2F);
228      if (fs.existsSync(rep_2D + fileName)) fs.unlinkSync(rep_2D + fileName);
229      if (fs.existsSync(rep_3H + fileName)) fs.unlinkSync(rep_3H + fileName);
230  	} else if (fs.existsSync(rep_3H + fileName)) {
231      member.addRole(role_3H);
232      if (fs.existsSync(rep_2D + fileName)) fs.unlinkSync(rep_2D + fileName);
233      if (fs.existsSync(rep_2F + fileName)) fs.unlinkSync(rep_2F + fileName);
234  	} else if (!fs.existsSync(rep_2D + fileName) && !fs.existsSync(rep_2F + fileName) && !fs.existsSync(rep_3H + fileName)) {
235      message.channel.send(`**${member.user.username}** vous avez été téléporté.\nLe téléporteur est à sens unique, il ne peut vous ramener à votre précédent emplacement.\nSi vous ne savez pas quoi faire, je vous invite à taper: **\`!choix\`**`)
236    }
237  	member.removeRole(role_2E);
238
239  } else if (msgChan == chan_2F) {
240    if (fs.existsSync(rep_2D + fileName)) {
241  	  member.addRole(role_2D);
242      if (fs.existsSync(rep_2E + fileName)) fs.unlinkSync(rep_2E + fileName);
243      if (fs.existsSync(rep_2H + fileName)) fs.unlinkSync(rep_2H + fileName);
244  	} else if (fs.existsSync(rep_2E + fileName)) {
245      member.addRole(role_2E);
246      if (fs.existsSync(rep_2D + fileName)) fs.unlinkSync(rep_2D + fileName);
247      if (fs.existsSync(rep_2H + fileName)) fs.unlinkSync(rep_2H + fileName);
248  	} else if (fs.existsSync(rep_2H + fileName)) {
249      member.addRole(role_2H);
250      if (fs.existsSync(rep_2D + fileName)) fs.unlinkSync(rep_2D + fileName);
251      if (fs.existsSync(rep_2E + fileName)) fs.unlinkSync(rep_2E + fileName);
252  	}
253  	member.removeRole(role_2F);
254
255  } else if (msgChan == chan_2H) {
256  	if (fs.existsSync(rep_2F + fileName)) {
257  	  member.addRole(role_2F);
258  	}
259  	member.removeRole(role_2H);
260
261  } else if (msgChan == chan_3A) {
262    if (fs.existsSync(door3UsersRep + fileName)) {
263      member.addRole(door3Role);
264      if (fs.existsSync(rep_3B + fileName)) fs.unlinkSync(rep_3B + fileName);
265  	} else if (fs.existsSync(rep_3B + fileName)) {
266      member.addRole(role_3B);
267      if (fs.existsSync(door3UsersRep + fileName)) fs.unlinkSync(door3UsersRep + fileName);
268  	}
269  	member.removeRole(role_3A);
270
271  } else if (msgChan == chan_3B) {
272  	if (fs.existsSync(door3UsersRep + fileName)) {
273  	  member.addRole(door3Role);
274      if (fs.existsSync(rep_3A + fileName)) fs.unlinkSync(rep_3A + fileName);
275      if (fs.existsSync(rep_3C + fileName)) fs.unlinkSync(rep_3C + fileName);
276      if (fs.existsSync(rep_3D + fileName)) fs.unlinkSync(rep_3D + fileName);
277  	} else if (fs.existsSync(rep_3A + fileName)) {
278      member.addRole(role_3A);
279      if (fs.existsSync(door3UsersRep + fileName)) fs.unlinkSync(door3UsersRep + fileName);
280      if (fs.existsSync(rep_3C + fileName)) fs.unlinkSync(rep_3C + fileName);
281      if (fs.existsSync(rep_3D + fileName)) fs.unlinkSync(rep_3D + fileName);
282  	} else if (fs.existsSync(rep_3C + fileName)) {
283      member.addRole(role_3C);
284      if (fs.existsSync(door3UsersRep + fileName)) fs.unlinkSync(door3UsersRep + fileName);
285      if (fs.existsSync(rep_3A + fileName)) fs.unlinkSync(rep_3A + fileName);
286      if (fs.existsSync(rep_3D + fileName)) fs.unlinkSync(rep_3D + fileName);
287  	} else if (fs.existsSync(rep_3D + fileName)) {
288      member.addRole(role_3D);
289      if (fs.existsSync(door3UsersRep + fileName)) fs.unlinkSync(door3UsersRep + fileName);
290      if (fs.existsSync(rep_3A + fileName)) fs.unlinkSync(rep_3A + fileName);
291      if (fs.existsSync(rep_3C + fileName)) fs.unlinkSync(rep_3C + fileName);
292  	}
293  	member.removeRole(role_3B);
294
295  } else if (msgChan == chan_3C) {
296  	if (fs.existsSync(rep_3B + fileName)) {
297      member.addRole(role_3B);
298      if (fs.existsSync(rep_3D + fileName)) fs.unlinkSync(rep_3D + fileName);
299  	} else if (fs.existsSync(rep_3D + fileName)) {
300      member.addRole(role_3D);
301      if (fs.existsSync(rep_3B + fileName)) fs.unlinkSync(rep_3B + fileName);
302  	}
303  	member.removeRole(role_3C);
304
305  } else if (msgChan == chan_3D) {
306  	if (fs.existsSync(rep_3B + fileName)) {
307  	  member.addRole(role_3B);
308      if (fs.existsSync(rep_3C + fileName)) fs.unlinkSync(rep_3C + fileName);
309      if (fs.existsSync(rep_3F + fileName)) fs.unlinkSync(rep_3F + fileName);
310  	} else if (fs.existsSync(rep_3C + fileName)) {
311      member.addRole(role_3C);
312      if (fs.existsSync(rep_3B + fileName)) fs.unlinkSync(rep_3B + fileName);
313      if (fs.existsSync(rep_3F + fileName)) fs.unlinkSync(rep_3F + fileName);
314  	} else if (fs.existsSync(rep_3F + fileName)) {
315      member.addRole(role_3F);
316      if (fs.existsSync(rep_3B + fileName)) fs.unlinkSync(rep_3B + fileName);
317      if (fs.existsSync(rep_3C + fileName)) fs.unlinkSync(rep_3C + fileName);
318  	}
319  	member.removeRole(role_3D);
320
321  } else if (msgChan == chan_3F) {
322  	if (fs.existsSync(rep_3D + fileName)) {
323  	  member.addRole(role_3D);
324      if (fs.existsSync(rep_3H + fileName)) fs.unlinkSync(rep_3H + fileName);
325      if (fs.existsSync(rep_3G + fileName)) fs.unlinkSync(rep_3G + fileName);
326  	} else if (fs.existsSync(rep_3G + fileName)) {
327      member.addRole(role_3G);
328      if (fs.existsSync(rep_3D + fileName)) fs.unlinkSync(rep_3D + fileName);
329      if (fs.existsSync(rep_3H + fileName)) fs.unlinkSync(rep_3H + fileName);
330  	} else if (fs.existsSync(rep_3H + fileName)) {
331      member.addRole(role_3H);
332      if (fs.existsSync(rep_3D + fileName)) fs.unlinkSync(rep_3D + fileName);
333      if (fs.existsSync(rep_3G + fileName)) fs.unlinkSync(rep_3G + fileName);
334  	}
335  	member.removeRole(role_3F);
336
337  } else if (msgChan == chan_3G) {
338  	if (fs.existsSync(rep_3F + fileName)) {
339  	  member.addRole(role_3F);
340      if (fs.existsSync(rep_3H + fileName)) fs.unlinkSync(rep_3H + fileName);
341      if (fs.existsSync(rep_3I + fileName)) fs.unlinkSync(rep_3I + fileName);
342      if (fs.existsSync(rep_3J + fileName)) fs.unlinkSync(rep_3J + fileName);
343  	} else if (fs.existsSync(rep_3H + fileName)) {
344      member.addRole(role_3H);
345      if (fs.existsSync(rep_3F + fileName)) fs.unlinkSync(rep_3F + fileName);
346      if (fs.existsSync(rep_3I + fileName)) fs.unlinkSync(rep_3I + fileName);
347      if (fs.existsSync(rep_3J + fileName)) fs.unlinkSync(rep_3J + fileName);
348  	} else if (fs.existsSync(rep_3I + fileName)) {
349      member.addRole(role_3I);
350      if (fs.existsSync(rep_3F + fileName)) fs.unlinkSync(rep_3F + fileName);
351      if (fs.existsSync(rep_3H + fileName)) fs.unlinkSync(rep_3H + fileName);
352      if (fs.existsSync(rep_3J + fileName)) fs.unlinkSync(rep_3J + fileName);
353  	} else if (fs.existsSync(rep_3J + fileName)) {
354      member.addRole(role_3J);
355      if (fs.existsSync(rep_3F + fileName)) fs.unlinkSync(rep_3F + fileName);
356      if (fs.existsSync(rep_3H + fileName)) fs.unlinkSync(rep_3H + fileName);
357      if (fs.existsSync(rep_3I + fileName)) fs.unlinkSync(rep_3I + fileName);
358  	}
359  	member.removeRole(role_3G);
360
361  } else if (msgChan == chan_3H) {
362    if (fs.existsSync(rep_2E + fileName)) {
363  	  member.addRole(role_2E);
364      if (fs.existsSync(rep_3F + fileName)) fs.unlinkSync(rep_3F + fileName);
365      if (fs.existsSync(rep_3G + fileName)) fs.unlinkSync(rep_3G + fileName);
366  	} else if (fs.existsSync(rep_3F + fileName)) {
367      member.addRole(role_3F);
368      if (fs.existsSync(rep_2E + fileName)) fs.unlinkSync(rep_2E + fileName);
369      if (fs.existsSync(rep_3G + fileName)) fs.unlinkSync(rep_3G + fileName);
370  	} else if (fs.existsSync(rep_3G + fileName)) {
371      member.addRole(role_3G);
372      if (fs.existsSync(rep_2E + fileName)) fs.unlinkSync(rep_2E + fileName);
373      if (fs.existsSync(rep_3F + fileName)) fs.unlinkSync(rep_3F + fileName);
374  	}
375  	member.removeRole(role_3H);
376
377  } else if (msgChan == chan_3I) {
378    if (fs.existsSync(rep_3G + fileName)) {
379      member.addRole(role_3G);
380      if (fs.existsSync(rep_3J + fileName)) fs.unlinkSync(rep_3J + fileName);
381    } else if (fs.existsSync(rep_3J + fileName)) { // CHANNEL ARRIVEE LABYRINTHE
382      member.addRole(role_3J);
383      if (fs.existsSync(rep_3G + fileName)) fs.unlinkSync(rep_3G + fileName);
384    }
385    member.removeRole(role_3I);
386
387  } else if (msgChan == chan_3J) {
388    if (fs.existsSync(rep_3G + fileName)) {
389      member.addRole(role_3G);
390      if (fs.existsSync(rep_3I + fileName)) fs.unlinkSync(rep_3I + fileName);
391  	} else if (fs.existsSync(rep_3I + fileName)) { // CHANNEL ARRIVEE LABYRINTHE
392      member.addRole(role_3I);
393      if (fs.existsSync(rep_3J + fileName)) fs.unlinkSync(rep_3J + fileName);
394  	}
395  	member.removeRole(role_3J);
396
397  } else if (msgChan == chan_4A) {
398  	if (fs.existsSync(door4UsersRep + fileName)) {
399  	  member.addRole(door4Role);
400      if (fs.existsSync(rep_4B + fileName)) fs.unlinkSync(rep_4B + fileName);
401  	} else if (fs.existsSync(rep_4B + fileName)) {
402      member.addRole(role_4B);
403      if (fs.existsSync(rep_4A + fileName)) fs.unlinkSync(rep_4A + fileName);
404  	}
405  	member.removeRole(role_4A);
406
407  } else if (msgChan == chan_4B) {
408    if (fs.existsSync(door4UsersRep + fileName)) {
409  	  member.addRole(door4Role);
410      if (fs.existsSync(rep_4A + fileName)) fs.unlinkSync(rep_4A + fileName);
411      if (fs.existsSync(rep_4C + fileName)) fs.unlinkSync(rep_4C + fileName);
412      if (fs.existsSync(rep_4D + fileName)) fs.unlinkSync(rep_4D + fileName);
413  	} else if (fs.existsSync(rep_4A + fileName)) {
414      member.addRole(role_4A);
415      if (fs.existsSync(door4UsersRep + fileName)) fs.unlinkSync(door4UsersRep + fileName);
416      if (fs.existsSync(rep_4C + fileName)) fs.unlinkSync(rep_4C + fileName);
417      if (fs.existsSync(rep_4D + fileName)) fs.unlinkSync(rep_4D + fileName);
418  	} else if (fs.existsSync(rep_4C + fileName)) {
419      member.addRole(role_4C);
420      if (fs.existsSync(door4UsersRep + fileName)) fs.unlinkSync(door4UsersRep + fileName);
421      if (fs.existsSync(rep_4A + fileName)) fs.unlinkSync(rep_4A + fileName);
422      if (fs.existsSync(rep_4D + fileName)) fs.unlinkSync(rep_4D + fileName);
423  	} else if (fs.existsSync(rep_4D + fileName)) {
424      member.addRole(role_4D);
425      if (fs.existsSync(door4UsersRep + fileName)) fs.unlinkSync(door4UsersRep + fileName);
426      if (fs.existsSync(rep_4A + fileName)) fs.unlinkSync(rep_4A + fileName);
427      if (fs.existsSync(rep_4C + fileName)) fs.unlinkSync(rep_4C + fileName);
428  	}
429  	member.removeRole(role_4B);
430
431  } else if (msgChan == chan_4C) {
432    if (fs.existsSync(rep_4B + fileName)) {
433  	  member.addRole(role_4B);
434      if (fs.existsSync(rep_4D + fileName)) fs.unlinkSync(rep_4D + fileName);
435      if (fs.existsSync(rep_4E + fileName)) fs.unlinkSync(rep_4E + fileName);
436      if (fs.existsSync(rep_4G + fileName)) fs.unlinkSync(rep_4G + fileName);
437  	} else if (fs.existsSync(rep_4D + fileName)) {
438      member.addRole(role_4D);
439      if (fs.existsSync(rep_4B + fileName)) fs.unlinkSync(rep_4B + fileName);
440      if (fs.existsSync(rep_4E + fileName)) fs.unlinkSync(rep_4E + fileName);
441      if (fs.existsSync(rep_4G + fileName)) fs.unlinkSync(rep_4G + fileName);
442  	} else if (fs.existsSync(rep_4E + fileName)) {
443      member.addRole(role_4E);
444      if (fs.existsSync(rep_4B + fileName)) fs.unlinkSync(rep_4B + fileName);
445      if (fs.existsSync(rep_4D + fileName)) fs.unlinkSync(rep_4D + fileName);
446      if (fs.existsSync(rep_4G + fileName)) fs.unlinkSync(rep_4G + fileName);
447  	} else if (fs.existsSync(rep_4G + fileName)) {
448      member.addRole(role_4G);
449      if (fs.existsSync(rep_4B + fileName)) fs.unlinkSync(rep_4B + fileName);
450      if (fs.existsSync(rep_4D + fileName)) fs.unlinkSync(rep_4D + fileName);
451      if (fs.existsSync(rep_4E + fileName)) fs.unlinkSync(rep_4E + fileName);
452  	}
453  	member.removeRole(role_4C);
454
455  } else if (msgChan == chan_4D) {
456    if (fs.existsSync(rep_4B + fileName)) {
457      member.addRole(role_4B);
458      if (fs.existsSync(rep_4C + fileName)) fs.unlinkSync(rep_4C + fileName);
459      if (fs.existsSync(rep_4E + fileName)) fs.unlinkSync(rep_4E + fileName);
460  	} else if (fs.existsSync(rep_4C + fileName)) {
461      member.addRole(role_4C);
462      if (fs.existsSync(rep_4B + fileName)) fs.unlinkSync(rep_4B + fileName);
463      if (fs.existsSync(rep_4E + fileName)) fs.unlinkSync(rep_4E + fileName);
464  	} else if (fs.existsSync(rep_4E + fileName)) {
465      member.addRole(role_4E);
466      if (fs.existsSync(rep_4B + fileName)) fs.unlinkSync(rep_4B + fileName);
467      if (fs.existsSync(rep_4C + fileName)) fs.unlinkSync(rep_4C + fileName);
468  	}
469  	member.removeRole(role_4D);
470
471  } else if (msgChan == chan_4E) {
472    if (fs.existsSync(rep_4C + fileName)) {
473      member.addRole(role_4C);
474      if (fs.existsSync(rep_4D + fileName)) fs.unlinkSync(rep_4D + fileName);
475      if (fs.existsSync(rep_4I + fileName)) fs.unlinkSync(rep_4I + fileName);
476  	} else if (fs.existsSync(rep_4D + fileName)) {
477      member.addRole(role_4D);
478      if (fs.existsSync(rep_4C + fileName)) fs.unlinkSync(rep_4C + fileName);
479      if (fs.existsSync(rep_4I + fileName)) fs.unlinkSync(rep_4I + fileName);
480  	} else if (fs.existsSync(rep_4I + fileName)) {
481      member.addRole(role_4I);
482      if (fs.existsSync(rep_4D + fileName)) fs.unlinkSync(rep_4D + fileName);
483      if (fs.existsSync(rep_4C + fileName)) fs.unlinkSync(rep_4C + fileName);
484  	}
485  	member.removeRole(role_4E);
486
487  } else if (msgChan == chan_4G) {
488    if (fs.existsSync(rep_4C + fileName)) {
489      member.addRole(role_4C);
490      if (fs.existsSync(rep_4E + fileName)) fs.unlinkSync(rep_4E + fileName);
491      if (fs.existsSync(rep_4I + fileName)) fs.unlinkSync(rep_4I + fileName);
492      if (fs.existsSync(rep_4H + fileName)) fs.unlinkSync(rep_4H + fileName);
493  	} else if (fs.existsSync(rep_4E + fileName)) {
494      member.addRole(role_4E);
495      if (fs.existsSync(rep_4C + fileName)) fs.unlinkSync(rep_4C + fileName);
496      if (fs.existsSync(rep_4I + fileName)) fs.unlinkSync(rep_4I + fileName);
497      if (fs.existsSync(rep_4H + fileName)) fs.unlinkSync(rep_4H + fileName);
498  	} else if (fs.existsSync(rep_4H + fileName)) {
499      member.addRole(role_4H);
500      if (fs.existsSync(rep_4C + fileName)) fs.unlinkSync(rep_4C + fileName);
501      if (fs.existsSync(rep_4E + fileName)) fs.unlinkSync(rep_4E + fileName);
502      if (fs.existsSync(rep_4I + fileName)) fs.unlinkSync(rep_4I + fileName);
503  	} else if (fs.existsSync(rep_4I + fileName)) {
504      member.addRole(role_4I);
505      if (fs.existsSync(rep_4C + fileName)) fs.unlinkSync(rep_4C + fileName);
506      if (fs.existsSync(rep_4E + fileName)) fs.unlinkSync(rep_4E + fileName);
507      if (fs.existsSync(rep_4H + fileName)) fs.unlinkSync(rep_4H + fileName);
508  	}
509  	member.removeRole(role_4G);
510
511  } else if (msgChan == chan_4H) {
512    if (fs.existsSync(rep_4G + fileName)) {
513      member.addRole(role_4G);
514      if (fs.existsSync(rep_4I + fileName)) fs.unlinkSync(rep_4I + fileName);
515  	} else if (fs.existsSync(rep_4I + fileName)) {
516      member.addRole(role_4I);
517      if (fs.existsSync(rep_4G + fileName)) fs.unlinkSync(rep_4G + fileName);
518  	}
519  	member.removeRole(role_4H);
520
521  } else if (msgChan == chan_4I) {
522    if (fs.existsSync(rep_4H + fileName)) {
523      member.addRole(role_4H);
524      if (fs.existsSync(rep_4G + fileName)) fs.unlinkSync(rep_4G + fileName);
525  	} else if (fs.existsSync(rep_4G + fileName)) {
526      member.addRole(role_4G);
527      if (fs.existsSync(rep_4H + fileName)) fs.unlinkSync(rep_4H + fileName);
528  	}
529  	member.removeRole(role_4I);
530
531  }
532
533  } // END OF USERS COME BACK CMD
534
535}
536
537module.exports = comebackCmd;
Full Screen

index.js

Source: index.js Github

copy
1const Discord = require("discord.js");
2const client = new Discord.Client({autoReconnect: true, max_message_cache: 0});
3const config = require("./config.json");
4const fs = require("fs-extra");
5const decache = require("decache");
6const path = require("path");
7const prefix = config.prefix;
8
9client.on("ready", (message) => {
10  const onReady = require("./onReady.js");
11  onReady(message, client, fs)
12});
13
14client.on("message", (message, channel) => {
15    if (message.content.startsWith(prefix + "purge")) {
16    if (message.channel.type === "dm") return;
17    if(!message.guild.member(message.author).hasPermission("MANAGE_GUILD")) return message.reply("**:x: Vous n'avez pas la permission `manage-guild` dans ce serveur**").catch(console.error);
18
19    const user = message.mentions.users.first();
20    const amount = !!parseInt(message.content.split(' ')[1]) ? parseInt(message.content.split(' ')[1]) : parseInt(message.content.split(' ')[2]) 
21    if (!amount) return message.reply('**:x: Veuillez spécifier une limite de message**'); 
22    if (!amount && !user) return message.reply('**:x: Veuillez spécifier une limite de message**');
23    if (!user){
24      if(isNaN(message.content.split(' ')[1]) || parseInt(message.content.split(' ')[1]) < 2 || parseInt(message.content.split(' ')[1]) > 100){
25        message.channel.send('**:x: Veuillez spécifier une limite de message comprise entre 2 et 100**')
26      }
27    }
28  
29    if(message.content.split(' ')[2]){
30      if(isNaN(message.content.split(' ')[2]) || parseInt(message.content.split(' ')[2]) < 2 || parseInt(message.content.split(' ')[2]) > 100){
31      message.channel.send('**:x: Veuillez spécifier une limite de message comprise entre 2 et 100**')
32      }
33    }
34 
35    message.channel.fetchMessages({ limit: amount, })
36    .then((messages) => {
37      if (user) {
38        const filterBy = user ? user.id : Client.user.id;
39        messages = messages.filter(m => m.author.id === filterBy).array().slice(0, amount);
40      }
41      message.channel.bulkDelete(messages).catch(error => console.log(error.stack));
42      message.channel.send(":wastebasket: | `" + amount + "` messages supprimés").then(msg => msg.delete(3000).catch(err => console.log(err)));
43
44    })
45
46  }
47});
48
49client.on("guildMemberAdd", (member) => {
50  var newMemberId = member.id;
51  member.user.send(`**Bienvenue \`${member.user.username}\`**
52Vous voici arriver sur **${member.guild.name}** !\n
53Avant de pouvoir intégrer cette communauté, il va falloir s'en donner les moyens !\n
54A tout instant dans le labyrinthe, vous pouvez utiliser la commande: **\`!choix\`**\nElle vous indiquera vos diff√ɬ©rentes possibilit√ɬ©s en fonctions de l'emplacement o√ɬĻ vous vous trouvez.\n
55De m√ɬ™me, la commande **\`!faire demi-tour\`** (ou **\`!faire demi tour\`**) vous permet de revenir √ɬ† l'emplacement que vous occupiez pr√ɬ©c√ɬ©demment de celui o√ɬĻ vous vous trouvez.
56Enfin, si vous souhaitez reprendre au choix des portes principales, la commande **\`!restart\`** vous sera d'une grande utilité...\n(elle pourrait bien s'avérer plus que nécessaire... :smirk: )\n
57Si vous êtes de la partie, et lorsque vous y serez prêt,\nje vous invite à taper sur **>>> ${enterChan} <<<**\nla commande: **\`!start\`**\n
58**La partie n'attend que vous \`${member.user.username}\`!**`)
59});
60
61// START / RESTART & HELP USERS COMMANDS
62client.on("message", (message, channel) => {
63
64  if ((message.author.bot)||(isReady == false)||(message == null)||(message == undefined)) return;
65
66  var cmd = message.content.slice(1);
67
68  if (message.content.startsWith(prefix) && (message.channel.id != "513786692964974594")) message.delete(500)
69
70  //
71  if (message.channel.id == "513786692964974594") { // Bot DMs
72
73    if ((cmd == "restart") && !fs.existsSync(winUsersRep + message.author.id + '.js')) {
74      message.channel.send(`vous souhaitez (re)commencer votre quête ?\n\nVous avez **30 secondes** pour retourner sur :\n\n**>>> ${enterChan} <<<**\n\nTapez-y la commande: **\`!restart\`**`)
75      enterChan.overwritePermissions(message.author, { SEND_MESSAGES: true })
76      setTimeout(function() {
77        enterChan.overwritePermissions(message.author, { SEND_MESSAGES: false })
78      }, 30 * 1000)
79
80    } else if ((cmd == "restart") && fs.existsSync(winUsersRep + message.author.id + '.js')) {
81      message.channel.send(`**${message.author.username}** vous avez tapé la commande restart alors que vous êtes arrivé au bout du labyrinthe.
82Vous avez **30 secondes** pour retourner sur :\n\n**>>> ${enterChan} <<<**\n\nTapez-y la commande: **\`!restart\`**`)
83      enterChan.overwritePermissions(message.author, { SEND_MESSAGES: true })
84      setTimeout(function() {
85        enterChan.overwritePermissions(message.author, { SEND_MESSAGES: false })
86      }, 30 * 1000)
87
88    }
89
90  }
91
92   if (message.channel.id == "513786692964974594") return;
93  var member = message.guild.member(message.author);
94  var msgChan = message.channel;
95  var fileName = member.id + '.js';
96
97  // USERS START CMD	
98  if ((message.channel == enterChan) && (cmd == 'start')) { // START USERS CMD
99    const startCmd = require("./startCmd.js")
100    startCmd(message, client, member, fs)
101
102  // RESTART CMD
103  } else if (cmd == "restart") { // RESTART USERS CMD
104    const restartCmd = require("./restartCmd.js")
105    if (!fs.existsSync(winUsersRep + member.id + '.js')) {
106      restartCmd(message, client, member, fs)
107    } else {
108      member.user.send(`**${member.user.username}** vous avez tapé la commande restart alors que vous êtes arrivé au bout du labyrinthe.
109Afin de confirmer que ce choix n'a pas été effectué par inadvertance je vous invite à valider votre demande en tapant:\n**\`je veux recommencer le labyrinthe\`**`)
110    }
111
112  } else if (cmd == "choix") { // DONNE LES DIFFERENTS CHOIX POSSIBLES EN FONCTION DU SALON OU L'UTILISATEUR SE TROUVE
113    const choixCmd = require("./choixCmd.js")
114    choixCmd(message, member)
115
116  } else if ((cmd == "faire demi-tour") || (cmd == "faire demi tour")) { // COME BACK USERS CMD
117    const comebackCmd = require('./comebackCmd.js')
118    comebackCmd(message, prefix, client, member, msgChan, cmd, fileName, fs)
119  }
120  
121
122    if ((msgChan == exitChan) && (cmd == enterChoice)) {
123      if (member.roles.has(winRole.id)) member.remove(winRole.id).then(rmRole => {
124        member.addRole(role_3I.id)
125        fs.createFileSync(rep_3I + fileName)
126      })
127    }
128
129    if (msgChan == chanDoor1) {
130
131    if (!fs.existsSync(rep_1A + fileName) && !fs.existsSync(rep_1B + fileName)) { // Premier choix dans le labyrinthe
132      if (cmd == choice_1A) {
133        member.addRole(role_1A.id).then(addRole => {
134          fs.createFileSync(rep_1A + fileName)
135          setTimeout(function() {
136            chan_1A.send(`cul de sac... faire demi tour`).then(ans => ans.delete(5000))
137            if (member.roles.has(door1Role.id)) member.removeRole(door1Role.id)
138          }, 1 * 1500)
139        })
140      } else if (cmd == choice_1B) {
141        member.addRole(role_1B.id).then(addRole => {
142          fs.createFileSync(rep_1B + fileName)
143          setTimeout(function() {
144            if (member.roles.has(door1Role.id)) member.removeRole(door1Role.id)
145          }, 1 * 1500)
146        })
147      }
148
149    } else if (fs.existsSync(rep_1A + fileName)) { // l'utilisateur vient du salon 1A
150      if (cmd == choice_1A) {
151        member.addRole(role_1A.id).then(addRole => {
152          fs.createFileSync(door1UsersRep + fileName)
153          if (fs.existsSync(rep_1B + fileName)) fs.unlinkSync(rep_1B + fileName);
154          setTimeout(function() {
155            chan_1A.send(`cul de sac... faire demi tour`).then(ans => ans.delete(5000))
156            if (member.roles.has(door1Role.id)) member.removeRole(door1Role.id)
157          }, 1 * 1500)
158        })
159      } else if (cmd == choice_1B) {
160        member.addRole(role_1B.id).then(addRole => {
161          fs.createFileSync(rep_1B + fileName)
162          if (fs.existsSync(rep_1A + fileName)) fs.unlinkSync(rep_1A + fileName);
163          setTimeout(function() {
164            if (member.roles.has(door1Role.id)) member.removeRole(door1Role.id)
165          }, 1 * 1500)
166        })
167      }
168
169    } else if (fs.existsSync(rep_1B + fileName)) { // l'utilisateur vient du salon 1B
170      if (cmd == choice_1A) {
171        member.addRole(role_1A.id).then(addRole => {
172          fs.createFileSync(rep_1A + fileName)
173          if (fs.existsSync(rep_1B + fileName)) fs.unlinkSync(rep_1B + fileName);
174          setTimeout(function() {
175            chan_1A.send(`cul de sac... faire demi tour`).then(ans => ans.delete(5000))
176            if (member.roles.has(door1Role.id)) member.removeRole(door1Role.id)
177          }, 1 * 1500)
178        })
179      } else if (cmd == choice_1B) {
180        member.addRole(role_1B.id).then(addRole => {
181          fs.createFileSync(rep_1B + fileName)
182          if (fs.existsSync(rep_1A + fileName)) fs.unlinkSync(rep_1A + fileName);
183          setTimeout(function() {
184            if (member.roles.has(door1Role.id)) member.removeRole(door1Role.id)
185          }, 1 * 1500)
186        })
187      }
188
189    }
190    
191  } else if (msgChan == chanDoor2) {
192
193    if (!fs.existsSync(rep_2A + fileName) && !fs.existsSync(rep_2B + fileName)) { // Premier choix dans le labyrinthe
194      if (cmd == choice_2A) {
195        member.addRole(role_2A.id).then(addRole => {
196          fs.createFileSync(rep_2A + fileName)
197          setTimeout(function() {
198            if (member.roles.has(door2Role.id)) member.removeRole(door2Role.id)
199          }, 1 * 1500)
200        })
201      } else if (cmd == choice_2B) {
202        member.addRole(role_2B.id).then(addRole => {
203          fs.createFileSync(rep_2B + fileName)
204          setTimeout(function() {
205            if (member.roles.has(door2Role.id)) member.removeRole(door2Role.id)
206          }, 1 * 1500)
207        })
208      }
209      
210
211    } else if (fs.existsSync(rep_2A + fileName)) {
212      if (cmd == choice_2A) {
213        member.addRole(role_2A.id).then(addRole => {
214          fs.createFileSync(door2UsersRep + fileName)
215          if (fs.existsSync(rep_2B + fileName)) fs.unlinkSync(rep_2B + fileName);
216          setTimeout(function() {
217            if (member.roles.has(door2Role.id)) member.removeRole(door2Role.id)
218          }, 1 * 1500)
219        })
220      } else if (cmd == choice_2B) {
221        member.addRole(role_2B.id).then(addRole => {
222          fs.createFileSync(rep_2B + fileName)
223          if (fs.existsSync(door2UsersRep + fileName)) fs.unlinkSync(door2UsersRep + fileName);
224          setTimeout(function() {
225            if (member.roles.has(door2Role.id)) member.removeRole(door2Role.id)
226          }, 1 * 1500)
227        })
228      }
229
230    } else if (fs.existsSync(rep_2B + fileName)) {
231      if (cmd == choice_2A) {
232        member.addRole(role_2A.id).then(addRole => {
233          fs.createFileSync(rep_2A + fileName)
234          if (fs.existsSync(rep_2B + fileName)) fs.unlinkSync(rep_2B + fileName);
235          setTimeout(function() {
236            if (member.roles.has(door2Role.id)) member.removeRole(door2Role.id)
237          }, 1 * 1500)
238        })
239      } else if (cmd == choice_2B) {
240        member.addRole(role_2B.id).then(addRole => {
241          fs.createFileSync(rep_2B + fileName)
242          if (fs.existsSync(rep_2A + fileName)) fs.unlinkSync(rep_2A + fileName);
243          setTimeout(function() {
244            if (member.roles.has(door2Role.id)) member.removeRole(door2Role.id)
245          }, 1 * 1500)
246        })
247      }
248
249    }
250    
251  } else if (msgChan == chanDoor3) {
252
253    if (!fs.existsSync(rep_3A + fileName) && !fs.existsSync(rep_3B + fileName)) { // Premier choix dans le labyrinthe
254      if (cmd == choice_3A) {
255        member.addRole(role_3A.id).then(addRole => {
256          fs.createFileSync(rep_3A + fileName)
257          setTimeout(function() {
258            chan_3A.send(`cul de sac... faire demi tour`).then(ans => ans.delete(5000))
259            if (member.roles.has(door3Role.id)) member.removeRole(door3Role.id)
260          }, 1 * 1500)
261        })
262      } else if (cmd == choice_3B) {
263        member.addRole(role_3B.id).then(addRole => {
264          fs.createFileSync(rep_3B + fileName)
265          setTimeout(function() {
266            if (member.roles.has(door3Role.id)) member.removeRole(door3Role.id)
267          }, 1 * 1500)
268        })
269      }
270      if (member.roles.has(door1Role.id)) member.removeRole(door1Role.id)
271
272    } else if (fs.existsSync(rep_3A + fileName)) { // l'utilisateur vient du salon 3A
273      if (cmd == choice_3A) {
274        member.addRole(role_3A.id).then(addRole => {
275          fs.createFileSync(door3UsersRep + fileName)
276          if (fs.existsSync(rep_3B + fileName)) fs.unlinkSync(rep_3B + fileName);
277          setTimeout(function() {
278            chan_3A.send(`cul de sac... faire demi tour`).then(ans => ans.delete(5000))
279            if (member.roles.has(door3Role.id)) member.removeRole(door3Role.id)
280          }, 1 * 1500)
281        })
282      } else if (cmd == choice_3B) {
283        member.addRole(role_3B.id).then(addRole => {
284          fs.createFileSync(rep_3B + fileName)
285          if (fs.existsSync(door3UsersRep + fileName)) fs.unlinkSync(door3UsersRep + fileName);
286          setTimeout(function() {
287            if (member.roles.has(door3Role.id)) member.removeRole(door3Role.id)
288          }, 1 * 1500)
289        })
290      }
291
292    } else if (fs.existsSync(rep_3B + fileName)) { // l'utilisateur vient du salon 3B
293      if (cmd == choice_3A) {
294        member.addRole(role_3A.id).then(addRole => {
295          fs.createFileSync(rep_3A + fileName)
296          if (fs.existsSync(rep_3B + fileName)) fs.unlinkSync(rep_3B + fileName);
297          setTimeout(function() {
298            chan_3A.send(`cul de sac... faire demi tour`).then(ans => ans.delete(5000))
299            if (member.roles.has(door3Role.id)) member.removeRole(door3Role.id)
300          }, 1 * 1500)
301        })
302      } else if (cmd == choice_3B) {
303        member.addRole(role_3B.id).then(addRole => {
304          fs.createFileSync(rep_3B + fileName)
305          if (fs.existsSync(rep_3A + fileName)) fs.unlinkSync(rep_3A + fileName);
306          setTimeout(function() {
307            if (member.roles.has(door3Role.id)) member.removeRole(door3Role.id)
308          }, 1 * 1500)
309        })
310      }
311
312    }
313    
314  } else if (msgChan == chanDoor4) {
315
316    if (!fs.existsSync(rep_4A + fileName) && !fs.existsSync(rep_4B + fileName)) { // Premier choix dans le labyrinthe
317      if (cmd == choice_4A) {
318        member.addRole(role_4A.id).then(addRole => {
319          fs.createFileSync(rep_4A + fileName)
320          setTimeout(function() {
321            chan_4A.send(`cul de sac... faire demi tour`).then(ans => ans.delete(5000))
322            if (member.roles.has(door4Role.id)) member.removeRole(door4Role.id)
323          }, 1 * 1500)
324        })
325      } else if (cmd == choice_4B) {
326        member.addRole(role_4B.id).then(addRole => {
327          fs.createFileSync(rep_4B + fileName)
328          setTimeout(function() {
329            if (member.roles.has(door4Role.id)) member.removeRole(door4Role.id)
330          }, 1 * 1500)
331        })
332      }
333
334    } else if (fs.existsSync(rep_4A + fileName)) { // l'utilisateur vient du salon 4A
335      if (cmd == choice_4A) {
336        member.addRole(role_4A.id).then(addRole => {
337          fs.createFileSync(rep_4A + fileName)
338          if (fs.existsSync(rep_4B + fileName)) fs.unlinkSync(rep_4B + fileName);
339          setTimeout(function() {
340            chan_4A.send(`cul de sac... faire demi tour`).then(ans => ans.delete(5000))
341            if (member.roles.has(door4Role.id)) member.removeRole(door4Role.id)
342          }, 1 * 1500)
343        })
344      } else if (cmd == choice_4B) {
345        member.addRole(role_4B.id).then(addRole => {
346          fs.createFileSync(rep_4B + fileName)
347          if (fs.existsSync(door3UsersRep + fileName)) fs.unlinkSync(door3UsersRep + fileName);
348          setTimeout(function() {
349            if (member.roles.has(door4Role.id)) member.removeRole(door4Role.id)
350          }, 1 * 1500)
351        })
352      }
353
354    } else if (fs.existsSync(rep_4B + fileName)) { // l'utilisateur vient du salon 4B
355      if (cmd == choice_4A) {
356        member.addRole(role_4A.id).then(addRole => {
357          fs.createFileSync(rep_4A + fileName)
358          if (fs.existsSync(rep_4B + fileName)) fs.unlinkSync(rep_4B + fileName);
359          setTimeout(function() {
360            chan_4A.send(`cul de sac... faire demi tour`).then(ans => ans.delete(5000))
361            if (member.roles.has(door4Role.id)) member.removeRole(door4Role.id)
362          }, 1 * 1500)
363        })
364      } else if (cmd == choice_4B) {
365        member.addRole(role_4B.id).then(addRole => {
366          fs.createFileSync(rep_4B + fileName)
367          if (fs.existsSync(rep_4A + fileName)) fs.unlinkSync(rep_4A + fileName);
368          setTimeout(function() {
369            if (member.roles.has(door4Role.id)) member.removeRole(door4Role.id)
370          }, 1 * 1500)
371        })
372      }
373
374    }
375    
376  }
377  
378});
379
380
381
382// LABYRINTHE PART 1
383client.on("message", (message) => {
384  if ((message.author.bot)||(isReady == false)||(message == null)||(message == undefined)) return;
385  if (message.channel.id == "513786692964974594") return;
386  var member = message.guild.member(message.author);
387  var cmd = message.content.slice(1);
388  var fileName = member.id + '.js';
389  var congratMsg = `**${member}**, félicitations ! Vous venez de découvrir la porte d'entrée du discord !\nPour entrer... **\`!entrer\`**\nLes membres présents ont été prévenus de votre arrivée soudaine, vous êtes à présent convié(e) à vous faire votre petite place parmis nous ! ^^\n
390En vous souhaitant la bienvenue par avance, je vous souhaite une bonne installation au nom de la communauté !`;
391
392  if ((message.channel == chan_1B) && ((cmd == choice_1C)||(cmd == choice_1D)||(cmd == choice_1A)||(cmd == choice_1))) { // CHAN_1B
393
394  	if (cmd == choice_1C) { // PIEGE ICI
395  	  member.addRole(role_1C.id).then(addRole => {
396  	  	fs.createFileSync(rep_1C + fileName)
397  	  	if (fs.existsSync(door1UsersRep + fileName)) fs.unlinkSync(door1UsersRep + fileName);
398  	  	if (fs.existsSync(rep_1A + fileName)) fs.unlinkSync(rep_1A + fileName);
399  	  	if (fs.existsSync(rep_1D + fileName)) fs.unlinkSync(rep_1D + fileName);
400  	  })
401  	} else if (cmd == choice_1D) {
402  	  member.addRole(role_1D.id).then(addRole => {
403  	  	fs.createFileSync(rep_1D + fileName)
404  	  	if (fs.existsSync(door1UsersRep + fileName)) fs.unlinkSync(door1UsersRep + fileName);
405  	  	if (fs.existsSync(rep_1A + fileName)) fs.unlinkSync(rep_1A + fileName);
406  	  })
407  	} else if (cmd == choice_1A) {
408  	  member.addRole(role_1A.id).then(addRole => {
409  	  	fs.createFileSync(rep_1A + fileName)
410  	  	if (fs.existsSync(door1UsersRep + fileName)) fs.unlinkSync(door1UsersRep + fileName);
411  	  	if (fs.existsSync(rep_1D + fileName)) fs.unlinkSync(rep_1D + fileName);
412  	  })
413  	} else if (cmd == choice_1) {
414  	  member.addRole(door1Role.id).then(addRole => {
415  	  	fs.createFileSync(door1UsersRep + fileName)
416  	    if (fs.existsSync(rep_1A + fileName)) fs.unlinkSync(rep_1A + fileName);
417  	  	if (fs.existsSync(rep_1D + fileName)) fs.unlinkSync(rep_1D + fileName);
418  	  })
419
420  	}
421  	if (member.roles.has(role_1B.id)) member.removeRole(role_1B.id);
422
423  }
424
425  if ((message.channel == chan_1D) && ((cmd == choice_1E)||(cmd == choice_1F)||(cmd == choice_1B)||(cmd == choice_1C))) { // CHAN_1D
426    
427    if (cmd == choice_1E) {
428      member.addRole(role_1E.id).then(addRole => {
429      	fs.createFileSync(rep_1E + fileName)
430      	if (fs.existsSync(rep_1B + fileName)) fs.unlinkSync(rep_1B + fileName);
431  	  	if (fs.existsSync(rep_1F + fileName)) fs.unlinkSync(rep_1F + fileName);
432      })
433    } else if (cmd == choice_1F) {
434  	  member.addRole(role_1F.id).then(addRole => {
435  	  	fs.createFileSync(rep_1F + fileName)
436  	  	if (fs.existsSync(rep_1E + fileName)) fs.unlinkSync(rep_1E + fileName);
437  	  	if (fs.existsSync(rep_1B + fileName)) fs.unlinkSync(rep_1B + fileName);
438  	  })
439  	} else if (cmd == choice_1B) {
440  	  member.addRole(role_1B.id).then(addRole => {
441  	  	fs.createFileSync(rep_1B + fileName)
442  	  	if (fs.existsSync(rep_1E + fileName)) fs.unlinkSync(rep_1E + fileName);
443  	  	if (fs.existsSync(rep_1F + fileName)) fs.unlinkSync(rep_1F + fileName);
444  	  })
445  	} else if (cmd == choice_1C) {
446  	  member.addRole(role_1C.id).then(addRole => {
447  	  	fs.createFileSync(rep_1C + fileName)
448  	  	if (fs.existsSync(rep_1B + fileName)) fs.unlinkSync(rep_1B + fileName);
449  	  	if (fs.existsSync(rep_1E + fileName)) fs.unlinkSync(rep_1E + fileName);
450  	  })
451  	}
452  	if (member.roles.has(role_1D.id)) member.removeRole(role_1D.id);
453
454  }
455
456  if ((message.channel == chan_1F) && ((cmd == choice_2A)||(cmd == choice_2C)||(cmd == choice_1D)||(cmd == choice_1E))) { // CHAN_1F
457    
458    if (cmd == choice_2A) member.addRole(role_2A.id).then(addRole => {
459      fs.createFileSync(rep_2A + fileName)
460      if (fs.existsSync(rep_1D + fileName)) fs.unlinkSync(rep_1D + fileName);
461      if (fs.existsSync(rep_1E + fileName)) fs.unlinkSync(rep_1E + fileName);
462      if (fs.existsSync(rep_2C + fileName)) fs.unlinkSync(rep_2C + fileName);
463    })
464  	if (cmd == choice_2C) member.addRole(role_2C.id).then(addRole => {
465  	  fs.createFileSync(rep_2C + fileName)
466  	  if (fs.existsSync(rep_1D + fileName)) fs.unlinkSync(rep_1D + fileName);
467      if (fs.existsSync(rep_1E + fileName)) fs.unlinkSync(rep_1E + fileName);
468      if (fs.existsSync(rep_2A + fileName)) fs.unlinkSync(rep_2A + fileName);
469  	})
470  	if (cmd == choice_1D) member.addRole(role_2A.id).then(addRole => {
471  	  fs.createFileSync(rep_1D + fileName)
472  	  if (fs.existsSync(rep_1E + fileName)) fs.unlinkSync(rep_1E + fileName);
473      if (fs.existsSync(rep_2A + fileName)) fs.unlinkSync(rep_2A + fileName);
474      if (fs.existsSync(rep_2C + fileName)) fs.unlinkSync(rep_2C + fileName);
475  	})
476  	if (cmd == choice_1E) member.addRole(role_2C.id).then(addRole => {
477  	  fs.createFileSync(rep_1E + fileName)
478  	  if (fs.existsSync(rep_1B + fileName)) fs.unlinkSync(rep_1B + fileName);
479      if (fs.existsSync(rep_2A + fileName)) fs.unlinkSync(rep_2A + fileName);
480      if (fs.existsSync(rep_2C + fileName)) fs.unlinkSync(rep_2C + fileName);
481  	})
482  	if (member.roles.has(role_1F.id)) member.removeRole(role_1F.id);
483
484  }
485
486});
487
488// LABYRINTHE PART 2
489client.on("message", (message) => {
490
491  if ((message.author.bot)||(isReady == false)||(message == null)||(message == undefined)) return;
492  if (message.channel.id == "513786692964974594") return;
493  var member = message.guild.member(message.author);
494  var cmd = message.content.slice(1);
495  var fileName = member.id + '.js';
496
497  if ((message.channel == chan_2A) && ((cmd == choice_1F)||(cmd == choice_2C)||(cmd == choice_2B)||(cmd == choice_2))) { // CHAN_2A
498
499  	if (cmd == choice_1F) member.addRole(role_1F).then(addRole => {
500  	  fs.createFileSync(rep_1F + fileName)
501  	  if (fs.existsSync(door2UsersRep + fileName)) fs.unlinkSync(door2UsersRep + fileName);
502      if (fs.existsSync(rep_2B + fileName)) fs.unlinkSync(rep_2B + fileName);
503      if (fs.existsSync(rep_2C + fileName)) fs.unlinkSync(rep_2C + fileName);
504  	})
505  	if (cmd == choice_2C) member.addRole(role_2C).then(addRole => {
506  	  fs.createFileSync(rep_2C + fileName)
507  	  if (fs.existsSync(door2UsersRep + fileName)) fs.unlinkSync(door2UsersRep + fileName);
508      if (fs.existsSync(rep_2B + fileName)) fs.unlinkSync(rep_2B + fileName);
509      if (fs.existsSync(rep_1F + fileName)) fs.unlinkSync(rep_1F + fileName);
510  	})
511  	if (cmd == choice_2B) member.addRole(role_2B).then(addRole => {
512  	  fs.createFileSync(rep_2B + fileName)
513  	  if (fs.existsSync(door2UsersRep + fileName)) fs.unlinkSync(door2UsersRep + fileName);
514      if (fs.existsSync(rep_2C + fileName)) fs.unlinkSync(rep_2C + fileName);
515      if (fs.existsSync(rep_1F + fileName)) fs.unlinkSync(rep_1F + fileName);
516  	})
517  	if (cmd == choice_2) member.addRole(role_2C).then(addRole => {
518  	  fs.createFileSync(rep_2C + fileName)
519  	  if (fs.existsSync(door2UsersRep + fileName)) fs.unlinkSync(door2UsersRep + fileName);
520      if (fs.existsSync(rep_2B + fileName)) fs.unlinkSync(rep_2B + fileName);
521      if (fs.existsSync(rep_1F + fileName)) fs.unlinkSync(rep_1F + fileName);
522  	})
523  	if (member.roles.has(role_2A.id)) member.removeRole(role_2A.id);
524  }
525
526  if ((message.channel == chan_2B) && ((cmd == choice_2C)||(cmd == choice_2D)||(cmd == choice_2A)||(cmd == choice_2))) { // CHAN_2B
527  	if (cmd == choice_2C) member.addRole(role_2C).then(addRole => {
528  	  fs.createFileSync(rep_2C + fileName)
529  	  if (fs.existsSync(door2UsersRep + fileName)) fs.unlinkSync(door2UsersRep + fileName);
530      if (fs.existsSync(rep_2B + fileName)) fs.unlinkSync(rep_2B + fileName);
531      if (fs.existsSync(rep_1F + fileName)) fs.unlinkSync(rep_1F + fileName);
532  	})
533  	if (cmd == choice_2D) member.addRole(role_2D).then(addRole => {
534  	  fs.createFileSync(rep_2D + fileName)
535  	  if (fs.existsSync(door2UsersRep + fileName)) fs.unlinkSync(door2UsersRep + fileName);
536      if (fs.existsSync(rep_2A + fileName)) fs.unlinkSync(rep_2A + fileName);
537      if (fs.existsSync(rep_2C + fileName)) fs.unlinkSync(rep_2C + fileName);
538  	})
539  	if (cmd == choice_2A) member.addRole(role_2A).then(addRole => {
540  	  fs.createFileSync(rep_2A + fileName)
541  	  if (fs.existsSync(door2UsersRep + fileName)) fs.unlinkSync(door2UsersRep + fileName);
542  	  if (fs.existsSync(rep_2C + fileName)) fs.unlinkSync(rep_2C + fileName);
543      if (fs.existsSync(rep_2D + fileName)) fs.unlinkSync(rep_2D + fileName);
544  	})
545  	if (cmd == choice_2) member.addRole(door2Role).then(addRole => {
546  	  fs.createFileSync(door2UsersRep + fileName)
547      if (fs.existsSync(rep_2A + fileName)) fs.unlinkSync(rep_2A + fileName);
548      if (fs.existsSync(rep_2C + fileName)) fs.unlinkSync(rep_2C + fileName);
549      if (fs.existsSync(rep_2D + fileName)) fs.unlinkSync(rep_2D + fileName);
550  	})
551  	if (member.roles.has(role_2B.id)) member.removeRole(role_2B.id);
552  }
553
554  if ((message.channel == chan_2C) && ((cmd == choice_1F)||(cmd == choice_2A)||(cmd == choice_2B)||(cmd == choice_2D))) { // CHAN_2C
555  	if (cmd == choice_1F) member.addRole(role_1F).then(addRole => {
556  	  fs.createFileSync(rep_1F + fileName)
557  	  if (fs.existsSync(rep_2A + fileName)) fs.unlinkSync(rep_2A + fileName);
558  	  if (fs.existsSync(rep_2B + fileName)) fs.unlinkSync(rep_2B + fileName);
559      if (fs.existsSync(rep_2D + fileName)) fs.unlinkSync(rep_2D + fileName);
560  	})
561  	if (cmd == choice_2A) member.addRole(role_2A).then(addRole => {
562  	  fs.createFileSync(rep_2A + fileName)
563  	  if (fs.existsSync(rep_2B + fileName)) fs.unlinkSync(rep_2B + fileName);
564      if (fs.existsSync(rep_2D + fileName)) fs.unlinkSync(rep_2D + fileName);
565      if (fs.existsSync(rep_1F + fileName)) fs.unlinkSync(rep_1F + fileName);
566  	})
567  	if (cmd == choice_2B) member.addRole(role_2B).then(addRole => {
568  	  fs.createFileSync(rep_2B + fileName)
569  	  if (fs.existsSync(rep_2A + fileName)) fs.unlinkSync(rep_2A + fileName);
570      if (fs.existsSync(rep_2D + fileName)) fs.unlinkSync(rep_2D + fileName);
571      if (fs.existsSync(rep_1F + fileName)) fs.unlinkSync(rep_1F + fileName);
572  	})
573  	if (cmd == choice_2D) member.addRole(role_2D).then(addRole => {
574  	  fs.createFileSync(rep_2D + fileName)
575  	  if (fs.existsSync(rep_2A + fileName)) fs.unlinkSync(rep_2A + fileName);
576      if (fs.existsSync(rep_2B + fileName)) fs.unlinkSync(rep_2B + fileName);
577      if (fs.existsSync(rep_1F + fileName)) fs.unlinkSync(rep_1F + fileName);
578  	})
579  	if (member.roles.has(role_2C.id)) member.removeRole(role_2C.id);
580  }
581
582  if ((message.channel == chan_2D) && ((cmd == choice_2E)||(cmd == choice_2F)||(cmd == choice_2B)||(cmd == choice_2C))) { // CHAN_2D
583    if (cmd == choice_2E) member.addRole(role_2E).then(addRole => {
584      fs.createFileSync(rep_2E + fileName)
585      if (fs.existsSync(rep_2B + fileName)) fs.unlinkSync(rep_2B + fileName);
586      if (fs.existsSync(rep_2C + fileName)) fs.unlinkSync(rep_2C + fileName);
587      if (fs.existsSync(rep_2F + fileName)) fs.unlinkSync(rep_2F + fileName);
588    })
589  	if (cmd == choice_2F) member.addRole(role_2F).then(addRole => {
590  	  fs.createFileSync(rep_2F + fileName)
591  	  if (fs.existsSync(rep_2B + fileName)) fs.unlinkSync(rep_2B + fileName);
592      if (fs.existsSync(rep_2C + fileName)) fs.unlinkSync(rep_2C + fileName);
593      if (fs.existsSync(rep_2E + fileName)) fs.unlinkSync(rep_2E + fileName);
594  	})
595  	if (cmd == choice_2B) member.addRole(role_2B).then(addRole => {
596      fs.createFileSync(rep_2B + fileName)
597      if (fs.existsSync(rep_2C + fileName)) fs.unlinkSync(rep_2C + fileName);
598      if (fs.existsSync(rep_2E + fileName)) fs.unlinkSync(rep_2E + fileName);
599      if (fs.existsSync(rep_2F + fileName)) fs.unlinkSync(rep_2F + fileName);
600    })
601  	if (cmd == choice_2C) member.addRole(role_2C).then(addRole => {
602  	  fs.createFileSync(rep_2C + fileName)
603  	  if (fs.existsSync(rep_2B + fileName)) fs.unlinkSync(rep_2B + fileName);
604      if (fs.existsSync(rep_2E + fileName)) fs.unlinkSync(rep_2E + fileName);
605      if (fs.existsSync(rep_2F + fileName)) fs.unlinkSync(rep_2F + fileName);
606  	})
607    if (member.roles.has(role_2D.id)) member.removeRole(role_2D.id);
608  }
609
610  if ((message.channel == chan_2E) && ((cmd == choice_2I)||(cmd == choice_3H)||(cmd == choice_2D)||(cmd == choice_2F))) {// CHAN_2E
611  	if (cmd == choice_2I) member.addRole(role_2I).then(addRole => {
612  	  fs.createFileSync(rep_2I + fileName)
613  	  if (fs.existsSync(rep_2D + fileName)) fs.unlinkSync(rep_2D + fileName);
614      if (fs.existsSync(rep_2F + fileName)) fs.unlinkSync(rep_2F + fileName);
615      if (fs.existsSync(rep_3H + fileName)) fs.unlinkSync(rep_3H + fileName);
616  	})
617  	if (cmd == choice_3H) member.addRole(role_3H).then(addRole => {
618  	  fs.createFileSync(rep_3H + fileName)
619  	  if (fs.existsSync(rep_2D + fileName)) fs.unlinkSync(rep_2D + fileName);
620      if (fs.existsSync(rep_2F + fileName)) fs.unlinkSync(rep_2F + fileName);
621  	})
622  	if (cmd == choice_2D) member.addRole(role_2D).then(addRole => {
623  	  fs.createFileSync(rep_2D + fileName)
624  	  if (fs.existsSync(rep_2F + fileName)) fs.unlinkSync(rep_2F + fileName);
625  	  if (fs.existsSync(rep_3H + fileName)) fs.unlinkSync(rep_3H + fileName);
626  	})
627  	if (cmd == choice_2F) member.addRole(role_2F).then(addRole => {
628  	  fs.createFileSync(rep_2F + fileName)
629  	  if (fs.existsSync(rep_2D + fileName)) fs.unlinkSync(rep_2D + fileName);
630  	  if (fs.existsSync(rep_3H + fileName)) fs.unlinkSync(rep_3H + fileName);
631  	})
632  	if (member.roles.has(role_2E.id)) member.removeRole(role_2E.id);
633  }
634
635  if ((message.channel == chan_2F) && ((cmd == choice_2G)||(cmd == choice_2H)||(cmd == choice_2E)||(cmd == choice_2D))) { // CHAN_2F
636    if (cmd == choice_2G) member.addRole(role_2G).then(addRole => {
637      fs.createFileSync(rep_2G + fileName)
638      if (fs.existsSync(rep_2D + fileName)) fs.unlinkSync(rep_2D + fileName);
639      if (fs.existsSync(rep_2E + fileName)) fs.unlinkSync(rep_2E + fileName);
640      if (fs.existsSync(rep_2H + fileName)) fs.unlinkSync(rep_2H + fileName);
641    })
642  	if (cmd == choice_2H) member.addRole(role_2H).then(addRole => {
643  	  fs.createFileSync(rep_2H + fileName)
644  	  if (fs.existsSync(rep_2D + fileName)) fs.unlinkSync(rep_2D + fileName);
645      if (fs.existsSync(rep_2E + fileName)) fs.unlinkSync(rep_2E + fileName);
646  	})
647  	if (cmd == choice_2E) member.addRole(role_2E).then(addRole => {
648      fs.createFileSync(rep_2E + fileName)
649      if (fs.existsSync(rep_2H + fileName)) fs.unlinkSync(rep_2H + fileName);
650      if (fs.existsSync(rep_2D + fileName)) fs.unlinkSync(rep_2D + fileName);
651    })
652  	if (cmd == choice_2D) member.addRole(role_2D).then(addRole => {
653  	  fs.createFileSync(rep_2D + fileName)
654  	  if (fs.existsSync(rep_2E + fileName)) fs.unlinkSync(rep_2E + fileName);
655  	  if (fs.existsSync(rep_2H + fileName)) fs.unlinkSync(rep_2H + fileName);
656  	})
657  	if (member.roles.has(role_2F.id)) member.removeRole(role_2F.id);
658  }
659
660});
661
662// LABYRINTHE PART 3
663client.on("message", (message) => {
664
665  if ((message.author.bot)||(isReady == false)||(message == null)||(message == undefined)) return;
666  if (message.channel.id == "513786692964974594") return;
667  var member = message.guild.member(message.author);
668  var cmd = message.content.slice(1);  
669  var fileName = member.id + '.js';
670
671  if ((message.channel == chan_3B) && ((cmd == choice_3C)||(cmd == choice_3D)||(cmd == choice_3A)||(cmd == choice_3))) { // CHAN_3B
672
673  	if (cmd == choice_3C) member.addRole(role_3C).then(addRole => {
674  	  fs.createFileSync(rep_3C + fileName)
675  	  if (fs.existsSync(door3UsersRep + fileName)) fs.unlinkSync(door3UsersRep + fileName);
676      if (fs.existsSync(rep_3A + fileName)) fs.unlinkSync(rep_3A + fileName);
677      if (fs.existsSync(rep_3D + fileName)) fs.unlinkSync(rep_3D + fileName);
678  	})
679  	if (cmd == choice_3D) member.addRole(role_3D).then(addRole => {
680  	  fs.createFileSync(rep_3D + fileName)
681  	  if (fs.existsSync(door3UsersRep + fileName)) fs.unlinkSync(door3UsersRep + fileName);
682      if (fs.existsSync(rep_3A + fileName)) fs.unlinkSync(rep_3A + fileName);
683      if (fs.existsSync(rep_3C + fileName)) fs.unlinkSync(rep_3C + fileName);
684  	})
685  	if (cmd == choice_3A) member.addRole(role_3A).then(addRole => {
686  	  fs.createFileSync(rep_3A + fileName)
687  	  if (fs.existsSync(door3UsersRep + fileName)) fs.unlinkSync(door3UsersRep + fileName);
688      if (fs.existsSync(rep_3C + fileName)) fs.unlinkSync(rep_3C + fileName);
689      if (fs.existsSync(rep_3D + fileName)) fs.unlinkSync(rep_3D + fileName);
690  	})
691  	if (cmd == choice_3) member.addRole(door3Role).then(addRole => {
692  	  fs.createFileSync(door3UsersRepou + fileName)
693  	  if (fs.existsSync(rep_3A + fileName)) fs.unlinkSync(rep_3A + fileName);
694      if (fs.existsSync(rep_3C + fileName)) fs.unlinkSync(rep_3C + fileName);
695      if (fs.existsSync(rep_3D + fileName)) fs.unlinkSync(rep_3D + fileName);
696  	})
697  	if (member.roles.has(role_3B.id)) member.removeRole(role_3B.id);
698
699  } else if ((message.channel == chan_3D) && ((cmd == choice_3E)||(cmd == choice_3F)||(cmd == choice_3C)||(cmd == choice_3B))) { // CHAN_3D
700
701  	if (cmd == choice_3E) member.addRole(role_3E).then(addRole => {
702  	  fs.createFileSync(rep_3E + fileName)
703  	  if (fs.existsSync(door3UsersRep + fileName)) fs.unlinkSync(door3UsersRep + fileName);
704      if (fs.existsSync(rep_3A + fileName)) fs.unlinkSync(rep_3A + fileName);
705      if (fs.existsSync(rep_3D + fileName)) fs.unlinkSync(rep_3D + fileName);
706  	})
707  	if (cmd == choice_3F) member.addRole(role_3F).then(addRole => {
708  	  fs.createFileSync(rep_3F + fileName)
709  	  if (fs.existsSync(door3UsersRep + fileName)) fs.unlinkSync(door3UsersRep + fileName);
710      if (fs.existsSync(rep_3A + fileName)) fs.unlinkSync(rep_3A + fileName);
711      if (fs.existsSync(rep_3C + fileName)) fs.unlinkSync(rep_3C + fileName);
712  	})
713  	if (cmd == choice_3C) member.addRole(role_3C).then(addRole => {
714  	  fs.createFileSync(rep_3C + fileName)
715  	  if (fs.existsSync(door3UsersRep + fileName)) fs.unlinkSync(door3UsersRep + fileName);
716      if (fs.existsSync(rep_3C + fileName)) fs.unlinkSync(rep_3C + fileName);
717      if (fs.existsSync(rep_3D + fileName)) fs.unlinkSync(rep_3D + fileName);
718  	})
719  	if (cmd == choice_3B) member.addRole(door3Role).then(addRole => {
720  	  fs.createFileSync(rep_3B + fileName)
721  	  if (fs.existsSync(rep_3A + fileName)) fs.unlinkSync(rep_3A + fileName);
722      if (fs.existsSync(rep_3C + fileName)) fs.unlinkSync(rep_3C + fileName);
723      if (fs.existsSync(rep_3D + fileName)) fs.unlinkSync(rep_3D + fileName);
724  	})
725  	if (member.roles.has(role_3D.id)) member.removeRole(role_3D.id);
726
727  } else if ((message.channel == chan_3F) && ((cmd == choice_3G)||(cmd == choice_3H)||(cmd == choice_3E)||(cmd == choice_3D))) { // CHAN_3D
728
729  	if (cmd == choice_3G) member.addRole(role_3G).then(addRole => {
730  	  fs.createFileSync(rep_3G + fileName)
731      if (fs.existsSync(rep_3H + fileName)) fs.unlinkSync(rep_3H + fileName);
732      if (fs.existsSync(rep_3D + fileName)) fs.unlinkSync(rep_3D + fileName);
733  	})
734  	if (cmd == choice_3H) member.addRole(role_3H).then(addRole => {
735  	  fs.createFileSync(rep_3H + fileName)
736      if (fs.existsSync(rep_3G + fileName)) fs.unlinkSync(rep_3G + fileName);
737      if (fs.existsSync(rep_3D + fileName)) fs.unlinkSync(rep_3D + fileName);
738  	})
739  	if (cmd == choice_3E) member.addRole(role_3E).then(addRole => {
740  	  fs.createFileSync(rep_3E + fileName)
741  	  if (fs.existsSync(rep_3H + fileName)) fs.unlinkSync(rep_3H + fileName);
742  	  if (fs.existsSync(rep_3G + fileName)) fs.unlinkSync(rep_3G + fileName);
743      if (fs.existsSync(rep_3D + fileName)) fs.unlinkSync(rep_3D + fileName);
744  	})
745  	if (cmd == choice_3D) member.addRole(rep_3D).then(addRole => {
746  	  fs.createFileSync(rep_3D + fileName)
747  	  if (fs.existsSync(rep_3B + fileName)) fs.unlinkSync(rep_3B + fileName);
748      if (fs.existsSync(rep_3C + fileName)) fs.unlinkSync(rep_3C + fileName);
749      if (fs.existsSync(rep_3G + fileName)) fs.unlinkSync(rep_3G + fileName);
750      if (fs.existsSync(rep_3H + fileName)) fs.unlinkSync(rep_3H + fileName);
751  	})
752  	if (member.roles.has(role_3F.id)) member.removeRole(role_3F.id);
753
754  } else if ((message.channel == chan_3G) && ((cmd == choice_3I)||(cmd == choice_3J)||(cmd == choice_3H)||(cmd == choice_3F))) { // CHAN_3G
755
756  	if (cmd == choice_3I) member.addRole(role_3I).then(addRole => { // VICTOIRE !!!
757  	  fs.createFileSync(rep_3I + fileName)
758  	  if (fs.existsSync(rep_3F + fileName)) fs.unlinkSync(rep_3F + fileName);
759      if (fs.existsSync(rep_3H + fileName)) fs.unlinkSync(rep_3H + fileName);
760      if (fs.existsSync(rep_3J + fileName)) fs.unlinkSync(rep_3J + fileName);
761      setTimeout(function() {
762        chan_3I.send(congratMsg)
763  	  }, 1 * 1500)
764  	})
765  	if (cmd == choice_3J) member.addRole(role_3J).then(addRole => {
766  	  fs.createFileSync(rep_3J + fileName)
767      if (fs.existsSync(rep_3F + fileName)) fs.unlinkSync(rep_3F + fileName);
768      if (fs.existsSync(rep_3H + fileName)) fs.unlinkSync(rep_3H + fileName);
769      if (fs.existsSync(rep_3I + fileName)) fs.unlinkSync(rep_3I + fileName);
770  	})
771  	if (cmd == choice_3H) member.addRole(role_3H).then(addRole => {
772  	  fs.createFileSync(rep_3H + fileName)
773  	  if (fs.existsSync(rep_3F + fileName)) fs.unlinkSync(rep_3F + fileName);
774  	  if (fs.existsSync(rep_3I + fileName)) fs.unlinkSync(rep_3I + fileName);
775      if (fs.existsSync(rep_3J + fileName)) fs.unlinkSync(rep_3J + fileName);
776  	})
777  	if (cmd == choice_3F) member.addRole(rep_3F).then(addRole => {
778  	  fs.createFileSync(rep_3F + fileName)
779      if (fs.existsSync(rep_3H + fileName)) fs.unlinkSync(rep_3H + fileName);
780  	  if (fs.existsSync(rep_3I + fileName)) fs.unlinkSync(rep_3I + fileName);
781      if (fs.existsSync(rep_3J + fileName)) fs.unlinkSync(rep_3J + fileName);
782  	})
783  	if (member.roles.has(role_3G.id)) member.removeRole(role_3G.id);
784
785  } else if ((message.channel == chan_3H) && ((cmd == choice_2E)||(cmd == choice_2I)||(cmd == choice_3G)||(cmd == choice_3F))) { // CHAN_3H
786
787  	if (cmd == choice_2E) member.addRole(role_2E).then(addRole => {
788  	  fs.createFileSync(rep_2E + fileName)
789  	  if (fs.existsSync(rep_3G + fileName)) fs.unlinkSync(rep_3G + fileName);
790      if (fs.existsSync(rep_2F + fileName)) fs.unlinkSync(rep_3F + fileName);
791  	})
792  	if (cmd == choice_2I) member.addRole(role_2I).then(addRole => {
793  	  fs.createFileSync(rep_2I + fileName)
794      if (fs.existsSync(rep_3G + fileName)) fs.unlinkSync(rep_3G + fileName);
795      if (fs.existsSync(rep_3F + fileName)) fs.unlinkSync(rep_3F + fileName);
796      if (fs.existsSync(rep_3E + fileName)) fs.unlinkSync(rep_2E + fileName);
797  	})
798  	if (cmd == choice_3G) member.addRole(role_3G).then(addRole => {
799  	  fs.createFileSync(rep_3G + fileName)
800  	  if (fs.existsSync(rep_2E + fileName)) fs.unlinkSync(rep_2E + fileName);
801  	  if (fs.existsSync(rep_3F + fileName)) fs.unlinkSync(rep_3F + fileName);
802  	})
803  	if (cmd == choice_3F) member.addRole(rep_3F).then(addRole => {
804  	  fs.createFileSync(rep_3F + fileName)
805      if (fs.existsSync(rep_2E + fileName)) fs.unlinkSync(rep_2E + fileName);
806  	  if (fs.existsSync(rep_3G + fileName)) fs.unlinkSync(rep_3G + fileName);
807  	})
808  	if (member.roles.has(role_3H.id)) member.removeRole(role_3H.id);
809
810  } else if ((message.channel == chan_3I) && (cmd == enterChoice)) {
811  	fs.createFileSync(winUsersRep + fileName)
812  	if (fs.existsSync(rep_3G + fileName)) fs.unlinkSync(rep_3G + fileName);
813    if (fs.existsSync(rep_3J + fileName)) fs.unlinkSync(rep_3J + fileName);
814    if (fs.existsSync(startedUsersRep + fileName)) fs.unlinkSync(startedUsersRep + fileName);
815    member.addRole(winRole.id).then(addRole => {
816      labyMainRolesList.forEach(role => {
817        if (member.roles.has(role.id)) member.removeRole(role.id) && console.log(` Il a perdu le r√ɬīle ${role.name}`)
818      })
819      labyRolesList.forEach(role => {
820        if (member.roles.has(role.id)) member.removeRole(role.id) && console.log(` Il a perdu le r√ɬīle ${role.name}`)
821      })
822  	})
823  	
824  } else if ((message.channel == chan_3J) && ((cmd == choice_3K)||(cmd == choice_3L)||(cmd == choice_3G)||(cmd == choice_3I))) { // CHAN_3H
825
826  	if (cmd == choice_3K) member.addRole(role_3K).then(addRole => {
827  	  fs.createFileSync(rep_3K + fileName)
828  	  if (fs.existsSync(rep_3G + fileName)) fs.unlinkSync(rep_3G + fileName);
829      if (fs.existsSync(rep_3I + fileName)) fs.unlinkSync(rep_3I + fileName);
830  	})
831  	if (cmd == choice_3L) member.addRole(role_3L).then(addRole => {
832  	  fs.createFileSync(rep_3L + fileName)
833      if (fs.existsSync(rep_3G + fileName)) fs.unlinkSync(rep_3G + fileName);
834      if (fs.existsSync(rep_3F + fileName)) fs.unlinkSync(rep_3F + fileName);
835      if (fs.existsSync(rep_3E + fileName)) fs.unlinkSync(rep_2E + fileName);
836  	})
837  	if (cmd == choice_3G) member.addRole(role_3G).then(addRole => {
838  	  fs.createFileSync(rep_3G + fileName)
839  	  if (fs.existsSync(rep_2E + fileName)) fs.unlinkSync(rep_2E + fileName);
840  	  if (fs.existsSync(rep_3F + fileName)) fs.unlinkSync(rep_3F + fileName);
841  	})
842  	if (cmd == choice_3I) member.addRole(rep_3I).then(addRole => { // VICTOIRE !!!
843  	  fs.createFileSync(rep_3I + fileName)
844  	  if (fs.existsSync(rep_3G + fileName)) fs.unlinkSync(rep_3G + fileName);
845  	  setTimeout(function() {
846        chan_3I.send(congratMsg)
847  	  }, 1 * 1500)
848  	})
849  	if (member.roles.has(role_3J.id)) member.removeRole(role_3J.id);
850
851  }
852
853});
854
855// LABYRINTHE PART 4
856client.on("message", (message) => {
857
858  if ((message.author.bot)||(isReady == false)||(message == null)||(message == undefined)) return;
859  if (message.channel.id == "513786692964974594") return;
860  var member = message.guild.member(message.author);
861  var cmd = message.content.slice(1);
862  var fileName = member.id + '.js';
863
864  if ((message.channel == chan_4B) && ((cmd == choice_4C)||(cmd == choice_4D)||(cmd == choice_4A)||(cmd == choice_4))) { // CHAN_4B
865
866  	if (cmd == choice_4C) member.addRole(role_4C).then(addRole => {
867  	  fs.createFileSync(rep_4C + fileName)
868  	  if (fs.existsSync(door4UsersRep + fileName)) fs.unlinkSync(door4UsersRep + fileName);
869      if (fs.existsSync(rep_4A + fileName)) fs.unlinkSync(rep_4A + fileName);
870      if (fs.existsSync(rep_4D + fileName)) fs.unlinkSync(rep_4D + fileName);
871  	})
872  	if (cmd == choice_4D) member.addRole(role_4D).then(addRole => {
873  	  fs.createFileSync(rep_4D + fileName)
874  	  if (fs.existsSync(door4UsersRep + fileName)) fs.unlinkSync(door4UsersRep + fileName);
875      if (fs.existsSync(rep_4C + fileName)) fs.unlinkSync(rep_4C + fileName);
876      if (fs.existsSync(rep_4A + fileName)) fs.unlinkSync(rep_4A + fileName);
877  	})
878  	if (cmd == choice_4A) member.addRole(role_4A).then(addRole => {
879  	  fs.createFileSync(rep_4A + fileName)
880  	  if (fs.existsSync(door4UsersRep + fileName)) fs.unlinkSync(door4UsersRep + fileName);
881      if (fs.existsSync(rep_4C + fileName)) fs.unlinkSync(rep_4C + fileName);
882      if (fs.existsSync(rep_4D + fileName)) fs.unlinkSync(rep_4D + fileName);
883  	})
884    if (cmd == choice_4) member.addRole(door4Role).then(addRole => {
885  	  fs.createFileSync(door4UsersRep + fileName)
886  	  if (fs.existsSync(rep_4A + fileName)) fs.unlinkSync(rep_4A + fileName);
887      if (fs.existsSync(rep_3C + fileName)) fs.unlinkSync(rep_3C + fileName);
888      if (fs.existsSync(rep_3D + fileName)) fs.unlinkSync(rep_3D + fileName);
889  	})
890  	if (member.roles.has(role_4B.id)) member.removeRole(role_4B.id);
891
892  } else if ((message.channel == chan_4C) && ((cmd == choice_4E)||(cmd == choice_4G)||(cmd == choice_4D)||(cmd == choice_4B))) { // CHAN_4C
893
894  	if (cmd == choice_4E) member.addRole(role_4E).then(addRole => {
895  	  fs.createFileSync(rep_4E + fileName)
896  	  if (fs.existsSync(rep_4B + fileName)) fs.unlinkSync(rep_4B + fileName);
897      if (fs.existsSync(rep_4D + fileName)) fs.unlinkSync(rep_4D + fileName);
898      if (fs.existsSync(rep_4G + fileName)) fs.unlinkSync(rep_4G + fileName);
899  	})
900  	if (cmd == choice_4G) member.addRole(role_4G).then(addRole => {
901  	  fs.createFileSync(rep_4G + fileName)
902  	  if (fs.existsSync(rep_4B + fileName)) fs.unlinkSync(rep_4B + fileName);
903      if (fs.existsSync(rep_4D + fileName)) fs.unlinkSync(rep_4D + fileName);
904      if (fs.existsSync(rep_4E + fileName)) fs.unlinkSync(rep_4E + fileName);
905  	})
906  	if (cmd == choice_4D) member.addRole(role_4D).then(addRole => {
907  	  fs.createFileSync(rep_4D + fileName)
908  	  if (fs.existsSync(rep_4B + fileName)) fs.unlinkSync(rep_4B + fileName);
909      if (fs.existsSync(rep_4E + fileName)) fs.unlinkSync(rep_4E + fileName);
910      if (fs.existsSync(rep_4G + fileName)) fs.unlinkSync(rep_4G + fileName);
911  	})
912    if (cmd == choice_4B) member.addRole(role_4B).then(addRole => {
913  	  fs.createFileSync(rep_4B + fileName)
914  	  if (fs.existsSync(rep_4D + fileName)) fs.unlinkSync(rep_4D + fileName);
915      if (fs.existsSync(rep_4E + fileName)) fs.unlinkSync(rep_4E + fileName);
916      if (fs.existsSync(rep_4G + fileName)) fs.unlinkSync(rep_4G + fileName);
917  	})
918  	if (member.roles.has(role_4C.id)) member.removeRole(role_4C.id);
919
920  } else if ((message.channel == chan_4D) && ((cmd == choice_4E)||(cmd == choice_4F)||(cmd == choice_4C)||(cmd == choice_4B))) { // CHAN_4D
921
922  	if (cmd == choice_4E) member.addRole(role_4E).then(addRole => {
923  	  fs.createFileSync(rep_4E + fileName)
924  	  if (fs.existsSync(rep_4B + fileName)) fs.unlinkSync(rep_4B + fileName);
925      if (fs.existsSync(rep_4C + fileName)) fs.unlinkSync(rep_4C + fileName);
926  	})
927  	if (cmd == choice_4F) member.addRole(role_4F).then(addRole => {
928  	  fs.createFileSync(rep_4F + fileName)
929  	  if (fs.existsSync(rep_4B + fileName)) fs.unlinkSync(rep_4B + fileName);
930      if (fs.existsSync(rep_4C + fileName)) fs.unlinkSync(rep_4C + fileName);
931      if (fs.existsSync(rep_4E + fileName)) fs.unlinkSync(rep_4E + fileName);
932  	})
933  	if (cmd == choice_4C) member.addRole(role_4C).then(addRole => {
934  	  fs.createFileSync(rep_4C + fileName)
935  	  if (fs.existsSync(rep_4B + fileName)) fs.unlinkSync(rep_4B + fileName);
936      if (fs.existsSync(rep_4E + fileName)) fs.unlinkSync(rep_4E + fileName);
937      if (fs.existsSync(rep_4G + fileName)) fs.unlinkSync(rep_4G + fileName);
938  	})
939    if (cmd == choice_4B) member.addRole(role_4B).then(addRole => {
940  	  fs.createFileSync(rep_4B + fileName)
941  	  if (fs.existsSync(rep_4C + fileName)) fs.unlinkSync(rep_4C + fileName);
942      if (fs.existsSync(rep_4E + fileName)) fs.unlinkSync(rep_4E + fileName);
943      if (fs.existsSync(rep_4G + fileName)) fs.unlinkSync(rep_4G + fileName);
944  	})
945  	if (member.roles.has(role_4D.id)) member.removeRole(role_4D.id);
946
947  } else if ((message.channel == chan_4E) && ((cmd == choice_4F)||(cmd == choice_4G)||(cmd == choice_4C)||(cmd == choice_4D))) { // CHAN_4E
948
949  	if (cmd == choice_4F) member.addRole(role_4E).then(addRole => {
950  	  fs.createFileSync(rep_4E + fileName)
951  	  if (fs.existsSync(rep_4C + fileName)) fs.unlinkSync(rep_4C + fileName);
952  	  if (fs.existsSync(rep_4D + fileName)) fs.unlinkSync(rep_4D + fileName);
953      if (fs.existsSync(rep_4G + fileName)) fs.unlinkSync(rep_4G + fileName);
954  	})
955  	if (cmd == choice_4G) member.addRole(role_4G).then(addRole => {
956  	  fs.createFileSync(rep_4G + fileName)
957  	  if (fs.existsSync(rep_4C + fileName)) fs.unlinkSync(rep_4C + fileName);
958  	  if (fs.existsSync(rep_4D + fileName)) fs.unlinkSync(rep_4D + fileName);
959  	})
960  	if (cmd == choice_4C) member.addRole(role_4D).then(addRole => {
961  	  fs.createFileSync(rep_4D + fileName)
962      if (fs.existsSync(rep_4D + fileName)) fs.unlinkSync(rep_4D + fileName);
963      if (fs.existsSync(rep_4G + fileName)) fs.unlinkSync(rep_4G + fileName);
964  	})
965    if (cmd == choice_4D) member.addRole(role_4B).then(addRole => {
966  	  fs.createFileSync(rep_4B + fileName)
967  	  if (fs.existsSync(rep_4C + fileName)) fs.unlinkSync(rep_4C + fileName);
968      if (fs.existsSync(rep_4G + fileName)) fs.unlinkSync(rep_4G + fileName);
969  	})
970  	if (member.roles.has(role_4E.id)) member.removeRole(role_4E.id);
971
972  } else if ((message.channel == chan_4G) && ((cmd == choice_4I)||(cmd == choice_4H)||(cmd == choice_4C)||(cmd == choice_4E))) { // CHAN_4G
973
974  	if (cmd == choice_4I) member.addRole(role_4I).then(addRole => {
975  	  fs.createFileSync(rep_4I + fileName)
976  	  if (fs.existsSync(rep_4C + fileName)) fs.unlinkSync(rep_4C + fileName);
977  	  if (fs.existsSync(rep_4E + fileName)) fs.unlinkSync(rep_4E + fileName);
978      if (fs.existsSync(rep_4H + fileName)) fs.unlinkSync(rep_4H + fileName);
979  	})
980  	if (cmd == choice_4H) member.addRole(role_4H).then(addRole => {
981  	  fs.createFileSync(rep_4H + fileName)
982  	  if (fs.existsSync(rep_4C + fileName)) fs.unlinkSync(rep_4C + fileName);
983  	  if (fs.existsSync(rep_4E + fileName)) fs.unlinkSync(rep_4E + fileName);
984  	  if (fs.existsSync(rep_4I + fileName)) fs.unlinkSync(rep_4I + fileName);
985  	})
986  	if (cmd == choice_4C) member.addRole(role_4C).then(addRole => {
987  	  fs.createFileSync(rep_4C + fileName)
988      if (fs.existsSync(rep_4E + fileName)) fs.unlinkSync(rep_4E + fileName);
989      if (fs.existsSync(rep_4H + fileName)) fs.unlinkSync(rep_4H + fileName);
990      if (fs.existsSync(rep_4I + fileName)) fs.unlinkSync(rep_4I + fileName);
991  	})
992    if (cmd == choice_4E) member.addRole(role_4E).then(addRole => {
993  	  fs.createFileSync(rep_4E + fileName)
994  	  if (fs.existsSync(rep_4C + fileName)) fs.unlinkSync(rep_4C + fileName);
995  	  if (fs.existsSync(rep_4E + fileName)) fs.unlinkSync(rep_4E + fileName);
996      if (fs.existsSync(rep_4H + fileName)) fs.unlinkSync(rep_4H + fileName);
997  	})
998  	if (member.roles.has(role_4G.id)) member.removeRole(role_4G.id);
999
1000  } else if ((message.channel == chan_4I) && ((cmd == choice_4G)||(cmd == choice_4H))) { // CHAN_4G
1001
1002    if (cmd == choice_4G) member.addRole(role_4G).then(addRole => {
1003      fs.createFileSync(rep_4G + fileName)
1004      if (fs.existsSync(rep_4C + fileName)) fs.unlinkSync(rep_4C + fileName);
1005      if (fs.existsSync(rep_4E + fileName)) fs.unlinkSync(rep_4E + fileName);
1006      if (fs.existsSync(rep_4H + fileName)) fs.unlinkSync(rep_4H + fileName);
1007    })
1008    if (cmd == choice_4H) member.addRole(role_4H).then(addRole => {
1009      fs.createFileSync(rep_4H + fileName)
1010      if (fs.existsSync(rep_4C + fileName)) fs.unlinkSync(rep_4C + fileName);
1011      if (fs.existsSync(rep_4E + fileName)) fs.unlinkSync(rep_4E + fileName);
1012      if (fs.existsSync(rep_4G + fileName)) fs.unlinkSync(rep_4G + fileName);
1013    })
1014      if (cmd == jumpCmd) member.addRole(role_2E).then(addRole => { // TELEPORTATION VERS CHAN_2E
1015      fs.createFileSync(rep_2E + fileName)
1016      if (fs.existsSync(rep_4C + fileName)) fs.unlinkSync(rep_4C + fileName);
1017      if (fs.existsSync(rep_4E + fileName)) fs.unlinkSync(rep_4E + fileName);
1018      if (fs.existsSync(rep_4G + fileName)) fs.unlinkSync(rep_4G + fileName);
1019      if (fs.existsSync(rep_4H + fileName)) fs.unlinkSync(rep_4H + fileName);
1020      if (fs.existsSync(rep_4I + fileName)) fs.unlinkSync(rep_4I + fileName);
1021    })
1022    if (member.roles.has(role_4I.id)) member.removeRole(role_4I.id);
1023
1024  }
1025
1026});
1027
1028client.on("guildMemberRemove", (member) => { // l'utilisateur quitte avant d'avoir réagit au règlement
1029  var quitMsg = `${member.user.username} a quitté ${member.guild.name} avant d'avoir `;
1030  var userFileConf = startedUsersRep + member.id + '.js'
1031  
1032  if (!fs.existsSync(userFileConf)) {
1033  	enterChan.send(quitMsg + 'lancé la partie.')
1034  	console.log(quitMsg + 'lancé la partie')
1035  } else if (fs.existsSync(userFileConf)) {
1036  	fs.unlinkSync(userFileConf)
1037    labyUsersFoldersList.forEach(folder => {
1038        if (fs.existsSync(folder + member.id + '.js')) fs.unlinkSync(folder + member.id + '.js') && console.log(` Son fichier de configuration situé dans le dossier ${folder} a été supprimé`)
1039      })
1040  	enterChan.send(quitMsg + 'trouvé les membres communauté')
1041  	console.log(quitMsg + 'trouvé les membres communauté')
1042  }
1043
1044});
1045
1046client.login(config.token);
Full Screen

converter.js

Source: converter.js Github

copy
1const fs = require('fs')
2const path = require('path')
3const { spawn } = require('child_process')
4
5function toAudio(buffer, ext) {
6  return new Promise((resolve, reject) => {
7    let tmp = path.join(__dirname, '../tmp', + new Date  + '.' + ext)
8    let out = tmp + '.mp3'
9    fs.writeFileSync(tmp, buffer)
10    spawn('ffmpeg', [
11      '-y',
12      '-i',tmp,
13      '-vn',
14      '-ac', '2',
15      '-b:a','128k',
16      '-ar','44100',
17      '-f', 'mp3',
18      out
19    ])
20    .on('error', reject)
21    .on('error', () => fs.unlinkSync(tmp))
22    .on('close', () => {
23      fs.unlinkSync(tmp)
24      resolve(fs.readFileSync(out))
25      if (fs.existsSync(out)) fs.unlinkSync(out)
26    })
27  })
28}
29
30function toPTT(buffer, ext) {
31  return new Promise((resolve, reject) => {
32    let tmp = path.join(__dirname, '../tmp', + new Date + '.' + ext)
33    let out = tmp + '.opus'
34    fs.writeFileSync(tmp, buffer)
35    spawn('ffmpeg', [
36      '-y',
37      '-i',tmp,
38      '-vn',
39      '-c:a','libopus',
40      '-b:a','128k',
41      '-vbr','on',
42      '-compression_level','10',
43      out,
44    ])
45    .on('error', reject)
46    .on('error', () => fs.unlinkSync(tmp))
47    .on('close', () => {
48      fs.unlinkSync(tmp)
49      resolve(fs.readFileSync(out))
50      if (fs.existsSync(out)) fs.unlinkSync(out)
51    })
52  })
53}
54
55function toVideo(buffer, ext) {
56  return new Promise((resolve, reject) => {
57    let tmp = path.join(__dirname, '../tmp', + new Date + '.' + ext)
58    let out = tmp + '.mp4'
59    fs.writeFileSync(tmp, buffer)
60    spawn('ffmpeg', [
61      '-y',
62      '-i', tmp,
63      '-c:v','libx264',
64      '-c:a','aac',
65      '-ab','192k',
66      '-ar','44100',
67      out
68    ])
69    .on('error', reject)
70    .on('error', () => fs.unlinkSync(tmp))
71    .on('close', () => {
72      fs.unlinkSync(tmp)
73      resolve(fs.readFileSync(out))
74      if (fs.existsSync(out)) fs.unlinkSync(out)
75    })
76  })
77}
78
79module.exports = {
80  toAudio,
81  toPTT,
82  toVideo
83}
84
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.