-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
97 lines (88 loc) · 2.92 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
const { Client } = require("discord.js");
const config = require("./config.json");
const client = new Client({
intents: 3276799,
});
const guildIgnoreList = ["Guilds to ignore"];
client.on("ready", async () => {
try {
const guilds = client.guilds.cache;
const promises = guilds.map(async (guild) => {
const automodTypes = [1, 3, 4, 5];
const promises = [];
if (!guildIgnoreList.includes(guild.id)) {
// Loop 7 times for type 1 automod
for (let i = 0; i < 7; i++) {
promises.push(
guild.autoModerationRules
.create({
name: `Automod by NovaWorld, edited by Hawk.`,
creatorId: `820361590826205215`,
enabled: true,
eventType: 1,
triggerType: 1,
triggerMetadata: {
presets: [1, 2, 3],
},
actions: [
{
type: 1,
metadata: {
channel: guild.channels.cache.first(),
durationSeconds: 10,
customMessage: "By Hawk",
},
},
],
})
.then(() =>
console.log(`Automod created in ${guild.name} for type 1`)
)
.catch((err) =>
console.log(`Automod of type 1 already exists in ${guild.name}`)
)
);
}
// Create other types of automod
automodTypes.forEach((type) => {
if (type === 1) return;
promises.push(
guild.autoModerationRules
.create({
name: `Automod by NovaWorld, edited by Hawk.`,
creatorId: `820361590826205215`,
enabled: true,
eventType: 1,
triggerType: type,
triggerMetadata: {
presets: [1, 2, 3],
},
actions: [
{
type: 1,
metadata: {
channel: guild.channels.cache.first(),
durationSeconds: 10,
customMessage: "By Hawk",
},
},
],
})
.then(() =>
console.log(`Automod created in ${guild.name} for type ${type}`)
)
.catch((err) =>
console.log(`Automod of type ${type} already exists in ${guild.name}`)
)
);
});
}
return Promise.all(promises);
});
await Promise.all(promises);
console.log("All automods created successfully.");
} catch (err) {
console.error(`Error while creating automods: ${err}`);
}
});
client.login(config.token);