Skip to content

Commit dc6a35a

Browse files
committed
Linting and prettifying
1 parent 65c6e03 commit dc6a35a

File tree

5 files changed

+53
-64
lines changed

5 files changed

+53
-64
lines changed

commands/wordle.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ module.exports = {
190190
for (let j = 0; j < 6; j++) {
191191
const imageNums = getAnswer(answer, guesses[j]);
192192
for (let i = 0; i < 5; i++) {
193-
// eslint-disable-next-line no-undef
194193
const imageNumber = imageNums[i];
195194
square = square_arr[imageNumber];
196195

events/createvc.js

Lines changed: 53 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -4,80 +4,73 @@ const fs = require("fs");
44
// The function has 2 parts to it. The first part is that which deletes all the channels from the saved file that are deleted in the channel.
55
// In the second part, we delete all the temporary channels that have no user in it.
66

7-
/* eslint-disable */
8-
97
module.exports = {
108
name: "ready",
119
once: true,
1210
execute(client) {
1311
const timer = setInterval(function () {
14-
// const temp_data = [];
1512
// Reading data from the file
1613
fs.readFile("./data/createvc.json", "utf-8", (err, jsonString) => {
1714
if (err) {
1815
console.log("Error reading file from disk:", err);
1916
return;
2017
} else {
21-
// Converting the data to a dictionary
22-
const data = JSON.parse(jsonString);
23-
24-
// Deleting all the channels, that should have been deleted
25-
const b = data.channels.filter((e) => e.delete == true);
26-
b.forEach((f) =>
27-
data.channels.splice(
28-
data.channels.findIndex((e) => e.delete === f.delete),
29-
1,
30-
),
31-
);
32-
33-
fs.writeFileSync(
34-
"./data/createvc.json",
35-
JSON.stringify({ users: data.users, channels: data.channels }, null, 4),
36-
);
37-
38-
// console.log(data);
39-
40-
data.channels.forEach((item) => {
41-
// item here is the channel id
42-
if (item.delete == false) {
43-
client.channels
44-
.fetch(item.channel_id)
45-
.then((channel) => {
46-
channel
47-
.fetch()
48-
.then((channel) => {
49-
if (channel.members.size == 0) {
50-
// console.log(channel.name);
51-
// console.log(channel.members.size);
52-
53-
item.delete = true;
54-
fs.writeFileSync(
55-
"./data/createvc.json",
56-
JSON.stringify(
57-
{
58-
users: data.users,
59-
channels: data.channels,
60-
},
61-
null,
62-
4,
63-
),
64-
);
65-
channel
66-
.delete()
67-
.then(console.log)
68-
.catch(console.error);
69-
}
70-
})
71-
.catch(console.error);
72-
})
73-
.catch(console.error);
74-
}
75-
});
76-
77-
// console.log(data.channels);
18+
deleteExistentChannels(client, jsonString);
7819
}
7920
});
8021
// Write back to the file
8122
}, 60 * 60 * 1000);
8223
},
8324
};
25+
26+
function deleteExistentChannels(client, jsonString) {
27+
// Converting the data to a dictionary
28+
const data = JSON.parse(jsonString);
29+
30+
// Deleting all the channels, that should have been deleted
31+
const b = data.channels.filter((e) => e.delete == true);
32+
b.forEach((f) =>
33+
data.channels.splice(
34+
data.channels.findIndex((e) => e.delete === f.delete),
35+
1,
36+
),
37+
);
38+
39+
fs.writeFileSync(
40+
"./data/createvc.json",
41+
JSON.stringify({ users: data.users, channels: data.channels }, null, 4),
42+
);
43+
44+
// console.log(data);
45+
46+
data.channels.forEach((item) => {
47+
// item here is the channel id
48+
if (item.delete == false) {
49+
client.channels
50+
.fetch(item.channel_id)
51+
.then((channel) => {
52+
channel
53+
.fetch()
54+
.then((vcChannel) => {
55+
if (vcChannel.members.size == 0) {
56+
item.delete = true;
57+
fs.writeFileSync(
58+
"./data/createvc.json",
59+
JSON.stringify(
60+
{
61+
users: data.users,
62+
channels: data.channels,
63+
},
64+
null,
65+
4,
66+
),
67+
);
68+
vcChannel.delete().then(console.log).catch(console.error);
69+
}
70+
})
71+
.catch(console.error);
72+
})
73+
.catch(console.error);
74+
}
75+
});
76+
}

events/faq_ready.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// @ts-check
22
const { DBFaq } = require("../lib/database/faq");
3-
/* eslint-disable */
43

54
module.exports = {
65
name: "ready",

events/reactrole_read.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const { DBReactRole } = require("../lib/database/dbreactrole");
2-
/* eslint-disable */
32

43
module.exports = {
54
name: "ready",

events/schedulepost_ready.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const { DBSchedulePost } = require("../lib/database/dbschedulepost");
2-
/* eslint-disable */
32

43
module.exports = {
54
name: "ready",

0 commit comments

Comments
 (0)