-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
222 lines (191 loc) · 7.6 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
const { Client, GatewayIntentBits, Partials, PermissionsBitField, REST, Routes } = require('discord.js')
const fs = require('fs')
var colors = require('colors')
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.DirectMessages
],
partials: [
Partials.Message,
Partials.Channel,
Partials.Reaction
]
})
client.commands = new Map()
client.slashCommands = new Map()
const prefix = "!"
const token = "TOKEN_KAMU" // Ganti dengan token bot Discord Anda
const CLIENT_ID = "KLIENID_KAMU" // Client id di developer portal do o2auth
const TEST_GUILD = "SERVER_KAMU" // Server Lu
const commandFiles = fs.readdirSync('./perintah').filter(file => file.endsWith('.js'))
for (const file of commandFiles) {
const command = require(`./perintah/${file}`)
client.commands.set(command.perintah, command)
}
const api = new REST({ version: '10' }).setToken(token)
let slashfolder = fs.readdirSync('./slash')
var slash_commands = []
slashfolder.forEach(dir => {
const slashcmd = fs.readdirSync(`./slash/${dir}`).filter(f => f.endsWith('.js'))
for (var i in slashcmd) {
var slashcmdFile = require(`./slash/${dir}/${slashcmd[i]}`)
if (slashcmdFile) {
client.slashCommands.set(slashcmdFile.perintah, slashcmdFile)
slash_commands.push({
perintah: slashcmdFile.perintah,
description: slashcmdFile.description,
const { Client, GatewayIntentBits, Partials, PermissionsBitField, REST, Routes } = require('discord.js')
const fs = require('fs')
var colors = require('colors')
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.DirectMessages
],
partials: [
Partials.Message,
Partials.Channel,
Partials.Reaction
]
})
client.commands = new Map()
client.slashCommands = new Map()
const prefix = "!"
const token = "TOKEN_KAMU" // Ganti dengan token bot Discord Anda
const CLIENT_ID = "KLIENID_KAMU" // Client id di developer portal do o2auth
const TEST_GUILD = "SERVER_KAMU" // Server Lu
const commandFiles = fs.readdirSync('./perintah').filter(file => file.endsWith('.js'))
for (const file of commandFiles) {
const command = require(`./perintah/${file}`)
client.commands.set(command.perintah, command)
}
const api = new REST({ version: '10' }).setToken(token)
let slashfolder = fs.readdirSync('./slash')
var slash_commands = []
slashfolder.forEach(dir => {
const slashcmd = fs.readdirSync(`./slash/${dir}`).filter(f => f.endsWith('.js'))
for (var i in slashcmd) {
var slashcmdFile = require(`./slash/${dir}/${slashcmd[i]}`)
if (slashcmdFile) {
client.slashCommands.set(slashcmdFile.perintah, slashcmdFile)
slash_commands.push({
perintah: slashcmdFile.perintah,
description: slashcmdFile.description,
type: slashcmdFile.type,
options: slashcmdFile.options || null,
default_permission: slashcmdFile.default_permission || null,
default_member_permission: slashcmdFile.default_member_permissions ? PermissionsBitField.resolve(slashcmdFile.default_member_permissions).toString() : null
})
}
}
})
const apps = fs.readdirSync(`./apps/`).filter(f => f.endsWith('.js'))
for (var i in apps) {
var app = require(`./apps/${apps[i]}`)
if (app) {
client.slashCommands.set(app.name, app)
slash_commands.push({
name: app.name,
type: app.type,
default_permission: app.default_permission || null,
default_member_permission: app.default_member_permissions ? PermissionsBitField.resolve(app.default_member_permissions).toString() : null
})
}
}
// Put Commands to Discord API
(async () => {
try {
if (TEST_GUILD) {
await api.put(Routes.applicationGuildCommands(CLIENT_ID, TEST_GUILD), { body: slash_commands })
} else {
await api.put(Routes.applicationCommands(CLIENT_ID), { body: slash_commands })
}
console.log(`[ INFO ] Berhasil Terdaftar Slash Commands & Apps`.brightGreen)
} catch (error) {
console.log(error)
}
})()
client.once("ready", () => {
console.log(`[STATUS] ${client.user.tag} Sudah Online!\n[INFO] Bot by Renki INC\n[INFO] Bot serving on Ready to serve in ${client.guilds.cache.size} ${client.users.cache.size} users\n`)
const activities = [
{ name: `My Renki`, type: 2 },
{ name: `${client.users.cache.size} users`, type: 0 },
{ name: `Type .menu to see menus!`, type: 3 },
]
let i = 0
setInterval(() => {
if (i >= activities.length) i = 0
client.user.setActivity(activities[i].name, { type: activities[i].type })
client.user.setStatus('idle')
i++
}, 5000)
})
client.on('messageCreate', async message => {
if (!message.content.startsWith(prefix) || message.author.bot) return
const args = message.content.slice(prefix.length).trim().split(/ +/)
const commandName = args.shift().toLowerCase()
console.log(`[ SERVER ]: ${message.guild.name}`)
console.log(`[ PERINTAH ]: ${commandName}`)
console.log(`[ PESAN ]: ${message.content}`)
if (!client.commands.has(commandName)) return
const command = client.commands.get(commandName)
try {
await command.sekai(client, message, args)
} catch (error) {
console.error(error)
message.reply('There was an error executing that command!')
}
})
client.login(token)
Enter type: slashcmdFile.type,
options: slashcmdFile.options || null,
default_permission: slashcmdFile.default_permission || null,
default_member_permission: slashcmdFile.default_member_permissions ? PermissionsBitField.resolve(slashcmdFile.default_member_permissions).toString() : null
})
}
}
})
const apps = fs.readdirSync(`./apps/`).filter(f => f.endsWith('.js'))
for (var i in apps) {
var app = require(`./apps/${apps[i]}`)
if (app) {
client.slashCommands.set(app.name, app)
slash_commands.push({
name: app.name,
type: app.type,
default_permission: app.default_permission || null,
default_member_permission: app.default_member_permissions ? PermissionsBitField.resolve(app.default_member_permissions).toString() : null
})
}
}
// Put Commands to Discord API
(async () => {
try {
if (TEST_GUILD) {
await api.put(Routes.applicationGuildCommands(CLIENT_ID, TEST_GUILD), { body: slash_commands })
} else {
await api.put(Routes.applicationCommands(CLIENT_ID), { body: slash_commands })
}
console.log(`[ INFO ] Berhasil Terdaftar Slash Commands & Apps`.brightGreen)
} catch (error) {
console.log(error)
}
})()
client.once("ready", () => {
console.log(`[STATUS] ${client.user.tag} Sudah Online!\n[INFO] Bot by Renki INC\n[INFO] Bot serving on Ready to serve in ${client.guilds.cache.size} ${client.users.cache.size} users\n`)
const activities = [
{ name: `My Renki`, type: 2 },
{ name: `${client.users.cache.size} users`, type: 0 },
{ name: `Type .menu to see menus!`, type: 3 },
]
let i = 0
setInterval(() => {
if (i >= activities.length) i = 0
client.user.setActivity(activities[i].name, { type: activities[i].type })
client.user.setStatus('idle')
i++