質問編集履歴
2
現時点のコードに変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -14,41 +14,28 @@
|
|
14
14
|
const client = new Client();
|
15
15
|
const fs = require("fs");
|
16
16
|
|
17
|
-
var nw = JSON.parse(fs.readFileSync('./Desktop/test.json', 'utf8'));
|
18
|
-
|
19
17
|
client.on('message', async msg => {
|
18
|
+
//var nw = JSON.parse(fs.readFileSync('./Desktop/test.json', 'utf8'));
|
19
|
+
nw.ng = [];
|
20
20
|
|
21
21
|
const args = msg.content.split(' ');
|
22
22
|
const cmd = args.shift();
|
23
23
|
|
24
|
-
|
25
|
-
if(msg.content.
|
24
|
+
if(nw.ng.some( item => msg.content.indexOf(item ) > -1)){
|
26
25
|
msg.delete(10);
|
27
26
|
}
|
28
27
|
|
29
28
|
if(msg.content.startsWith('/add')){
|
29
|
+
//const args = msg.content.split(' ');
|
30
|
-
|
30
|
+
//var newNg = args[1];
|
31
|
+
nw.ng.push("単語3");
|
32
|
+
}
|
31
33
|
|
32
|
-
|
34
|
+
if(msg.content.startsWith('/rm')){
|
33
|
-
|
35
|
+
var target = "単語2";
|
34
|
-
|
35
|
-
var place = './Desktop/test.json';
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
delete nw.ng[target];
|
39
|
-
|
37
|
+
}
|
40
|
-
|
38
|
+
|
41
|
-
if(msg.content.startsWith('/remove')){
|
42
|
-
ngWord = args[1];
|
43
|
-
|
44
|
-
var charset = 'utf-8';
|
45
|
-
|
46
|
-
var place = './Desktop/test.json';
|
47
|
-
|
48
|
-
|
49
|
-
fs.writeFileSync(place, JSON.stringify(nw), charset);
|
50
|
-
}
|
51
|
-
*/
|
52
39
|
});
|
53
40
|
|
54
41
|
```
|
1
jsonの記載がなかったので追加しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -53,6 +53,13 @@
|
|
53
53
|
|
54
54
|
```
|
55
55
|
|
56
|
+
```json
|
57
|
+
{
|
58
|
+
"ng" : "単語1",
|
59
|
+
"ng" : "単語2"
|
60
|
+
}
|
61
|
+
```
|
62
|
+
|
56
63
|
### 試したこと
|
57
64
|
|
58
65
|
そのままのソースコードで試しましたがうまくいかずに止まっています。
|