-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
153 lines (129 loc) · 6.04 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
const { EmbedBuilder, WebhookClient, ActionRowBuilder, ButtonBuilder, Events, Modal, TextInputBuilder, OAuth2Scopes, Partials, resolveColor, Client, Collection, GatewayIntentBits, SelectMenuBuilder, ActivityType, PermissionsBitField, AttachmentBuilder } = require("discord.js");
const { exit } = require("process");
const fs = require("node:fs");
const client = global.client = new Client({ fetchAllMembers: true, intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildModeration, GatewayIntentBits.GuildEmojisAndStickers, GatewayIntentBits.GuildIntegrations, GatewayIntentBits.GuildWebhooks, GatewayIntentBits.GuildInvites, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.GuildPresences, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildMessageReactions, GatewayIntentBits.GuildMessageTyping, GatewayIntentBits.MessageContent], scopes: [OAuth2Scopes.Bot, OAuth2Scopes.ApplicationsCommands], partials: [Partials.Message, Partials.Channel, Partials.Reaction, Partials.User, Partials.GuildMember, Partials.ThreadMember, Partials.GuildScheduledEvent], ws: { version: "10" } });
const config = global.config = require("./config");
// var events = require("./events");
const wait = require("timers/promises").setTimeout;
// START | To be moved!
if(config.V !== "0.0.4"){
console.error("Config version does not match, please update your config.js file");
exit();
}
if(config.token == null || config.token == ""){
console.error("The token cannot be left as null, please update your config.js file");
exit();
}
if(config.webHookURL == null || config.webHookURL == ""){
console.error("The webHookURL cannot be left as null, please update your config.js file");
exit();
}
// if(config.TagID == null || config.TagID == [""]){
// console.error("The TagID cannot be left as null, please update your config.js file");
// exit();
// }
if(config.clientId == null || config.clientId == ""){
console.error("The clientId cannot be left as null, please update your config.js file");
exit();
}
if(config.guildId == null || config.guildId == ""){
console.error("Currently the guildId cannot be left as null, please update your config.js file");
exit();
}
// END
const invites = global.invites = new Collection();
client.commands = new Collection();
const webhookClient = new WebhookClient({ url: config.webHookURL });
if(config.webHookFULLURL){
webhookClientFULL = new WebhookClient({ url: config.webHookFULLURL });
console.log("Extra WebHook is connected");
}
async function logger(embed, userID, extra, file = null) {
embed.setColor("#e36464");
embed.setTimestamp();
embed.setFooter({ text: 'Logger • v1.10.31 by AFuxy', iconURL: 'https://avatars.githubusercontent.com/u/38048026?v=4' });
// if(userID !== config.TagID) return;
let tagged = fs.readFileSync("./tagged.json");
let taggedParsed = JSON.parse(tagged);
if(!taggedParsed.includes(userID)) return;
webhookClient.send({
content: extra,
username: 'Logger',
avatarURL: client.user.avatarURL(),
embeds: [embed],
files: file ? file : []
}).catch(console.error);
}
async function fulllogs(guildID, username, icon, message, file = null) {
if(guildID !== config.TagGuildID) return;
webhookClientFULL.send({
username: username,
avatarURL: icon,
content: message ? message : "Probably a system message.",
files: file ? file : []
})
}
module.exports = { logger, fulllogs };
var normalizedPathEvents = require("path").join(__dirname, "events");
var foldersPath = require("path").join(__dirname, "commands");
require("fs").readdirSync(normalizedPathEvents).forEach(function(file) {
require("./events/" + file);
console.log("Events: " + file);
});
// require("fs").readdirSync(normalizedPathCommands).forEach(function(file) {
// require("./commands/" + file);
// console.log("Commands: " + file);
// });
const commandFolders = require("fs").readdirSync(foldersPath);
for (const folder of commandFolders) {
const commandsPath = require("path").join(foldersPath, folder);
const commandFiles = require("fs").readdirSync(commandsPath).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const filePath = require("path").join(commandsPath, file);
const command = require(filePath);
// Set a new item in the Collection with the key as the command name and the value as the exported module
if ('data' in command && 'execute' in command) {
client.commands.set(command.data.name, command);
console.log("Commands: " + file);
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
}
// //
client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isChatInputCommand()) return;
const command = interaction.client.commands.get(interaction.commandName);
if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`);
return;
}
try {
await command.execute(interaction);
} catch (error) {
console.error(error);
if (interaction.replied || interaction.deferred) {
await interaction.followUp({ content: 'There was an error while executing this command!', ephemeral: true });
} else {
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}
}
});
client.on("ready", async () => {
console.log(`bot online | ${client.user.tag} | Logger`);
client.user.setPresence({ activities: [{ name: config.presence, type: ActivityType.Custom }], status: "dnd" })
let tagged = fs.readFileSync("./tagged.json");
let taggedParsed = JSON.parse(tagged);
taggedParsed.forEach(async (userID) => {
client.users.fetch(userID).then((user) => {
console.log(`${user.tag} | Tagged!`)
})
})
await wait(1000);
client.guilds.cache.forEach(async (guild) => {
const firstInvites = await guild.invites.fetch();
invites.set(guild.id, new Collection(firstInvites.map((invite) => [invite.code, invite.uses])));
console.log(`Guild: ${guild.name} | Invites: ${invites.get(guild.id).size}`);
});
})
client.login(config.token);