-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
94 lines (78 loc) · 2.26 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
const Discord = require("discord.js");
const fs = require("fs");
const db = require('croxydb')
const config = require("./config.json");
const Rest = require("@discordjs/rest");
const DiscordApi = require("discord-api-types/v10");
const { GatewayIntentBits, Partials } = require('discord.js')
const client = new Discord.Client({
intents: [
"AutoModerationConfiguration",
"AutoModerationExecution",
"DirectMessageReactions",
"DirectMessageTyping",
"DirectMessages",
"GuildBans",
"GuildEmojisAndStickers",
"GuildIntegrations",
"GuildInvites",
"GuildMembers",
"GuildMessageReactions",
"GuildMessageTyping",
"GuildMessages",
"GuildModeration",
"GuildPresences",
"GuildScheduledEvents",
"GuildVoiceStates",
"GuildWebhooks",
"Guilds",
"MessageContent"
],
partials: [
Partials.Channel,
Partials.GuildMember,
Partials.Message
],
});
global.client = client;
client.commands = (global.commands = []);
//
console.log(`[-] ${fs.readdirSync("./commands").length} komut algılandı.`)
for(let commandName of fs.readdirSync("./commands")) {
if(!commandName.endsWith(".js")) return;
const command = require(`./commands/${commandName}`);
client.commands.push({
name: command.name.toLowerCase(),
description: command.description.toLowerCase(),
options: command.options,
dm_permission: false,
type: 1
});
console.log(`[+] ${commandName} komutu başarıyla yüklendi.`)
}
console.log(`[-] ${fs.readdirSync("./events").length} olay algılandı.`)
for(let eventName of fs.readdirSync("./events")) {
if(!eventName.endsWith(".js")) return;
const event = require(`./events/${eventName}`);
const evenet_name = eventName.split(".")[0];
client.on(event.name, (...args) => {
event.run(client, ...args)
});
console.log(`[+] ${eventName} olayı başarıyla yüklendi.`)
}
//
client.once("ready", async() => {
const rest = new Rest.REST({ version: "10" }).setToken(config.token);
try {
await rest.put(DiscordApi.Routes.applicationCommands(client.user.id), {
body: client.commands, //
});
console.log(`${client.user.tag} Aktif! 💕`);
} catch (error) {
throw error;
}
});
client.login(config.token)
.catch((err) => {
console.log(`[x] Discord API'ye istek gönderimi başarısız(token girmeyi unutmuşsun).` + err);
});