-
Notifications
You must be signed in to change notification settings - Fork 1
/
Bot.js
440 lines (428 loc) · 20.4 KB
/
Bot.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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
const { Client, IntentsBitField, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuBuilder, ChannelType, PermissionsBitField, ModalBuilder, TextInputBuilder, TextInputStyle, UserSelectMenuBuilder } = require('discord.js')
const client = new Client({
intents: [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.GuildVoiceStates,
IntentsBitField.Flags.MessageContent
]
})
const chalk = require('chalk')
const Express = require('express')
const App = Express()
App.listen(8000, async() => console.log(chalk.green('The Express Server has been Started')))
App.get('/', async(Req, Res) => Res.send('THE DEVELOPERS :: ₦ł₵₭ ₣ɄⱤɎ'))
const db = require('pro.db')
const BotConfig = require('./Bot.json')
client.on('ready', async () => {
console.log(chalk.blue('The Client has been Connected to : ') + chalk.red(client.user.username))
})
client.on('messageCreate', async Message => {
if (!BotConfig.OwnersId.includes(Message.author.id)) return;
if (!Message.content.startsWith(BotConfig.Prefix)) return;
const Cmd = Message.content.slice(BotConfig.Prefix.length).trim().split(' ')
const Command = Cmd.shift()
if (Command == 'setup') {
Message.delete()
const Embed = new EmbedBuilder()
.setAuthor({ name: 'Temporary Voice Dashboard', iconURL: client.user.displayAvatarURL() })
.setDescription(`Click on the Button to Control your Temporary Channel`)
.setTimestamp()
.setFooter({ text: Message.guild.name, iconURL: Message.guild.iconURL() })
const Menu = new StringSelectMenuBuilder()
.setCustomId('Menu')
.setMaxValues(1)
.setMinValues(1)
.setPlaceholder('Limit Users')
.addOptions([
{ label: '0', value: '0' },
{ label: '1', value: '1' },
{ label: '2', value: '2' },
{ label: '3', value: '3' },
{ label: '4', value: '4' },
{ label: '5', value: '5' },
{ label: '10', value: '10' },
{ label: '15', value: '15' },
{ label: '20', value: '20' },
{ label: '25', value: '25' },
{ label: '30', value: '30' },
{ label: '35', value: '35' },
{ label: '40', value: '40' },
{ label: '45', value: '45' },
{ label: '50', value: '50' },
{ label: '55', value: '55' },
{ label: '60', value: '60' },
{ label: '65', value: '65' }
])
// const RowOne = new ActionRowBuilder() make sure you have to change.
.addComponents(
new ButtonBuilder()
.setStyle(ButtonStyle.Secondary)
.setEmoji('1079515867374698538')
.setLabel('Lock')
.setCustomId('LockChannel'),
new ButtonBuilder()
.setStyle(ButtonStyle.Secondary)
.setEmoji('1079515869320855624')
.setLabel('Unlock')
.setCustomId('UnlockChannel'),
new ButtonBuilder()
.setStyle(ButtonStyle.Secondary)
.setEmoji('1084858277730455683')
.setLabel('Hide')
.setCustomId('HideChannel'),
new ButtonBuilder()
.setStyle(ButtonStyle.Secondary)
.setEmoji('1084859746605076480')
.setLabel('Unhide')
.setCustomId('UnhideChannel'))
const RowTwo = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setStyle(ButtonStyle.Secondary)
.setEmoji('1079515864891674694')
.setLabel('Mute')
.setCustomId('Mute'),
new ButtonBuilder()
.setStyle(ButtonStyle.Secondary)
.setEmoji('1079515872118444062')
.setLabel('Unmute')
.setCustomId('Unmute'),
new ButtonBuilder()
.setStyle(ButtonStyle.Secondary)
.setEmoji('1084915797463404614')
.setLabel('Customize Users')
.setCustomId('Customize_UserLimit'),
new ButtonBuilder()
.setStyle(ButtonStyle.Danger)
.setEmoji('1079515860516999290')
.setLabel('Disconnect')
.setCustomId('Disconnect'))
const RowThree = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setStyle(ButtonStyle.Secondary)
.setEmoji('1085174405895835699')
.setLabel('Users Manager')
.setCustomId('UsersManager'),
new ButtonBuilder()
.setStyle(ButtonStyle.Primary)
.setEmoji('1079515862928740363')
.setLabel('Delete Channel')
.setCustomId('Delete_Channel'),
new ButtonBuilder()
.setStyle(ButtonStyle.Primary)
.setEmoji('🗒️')
.setLabel('Rename')
.setCustomId('RenameChannel')
)
const RowFour = new ActionRowBuilder()
.addComponents([Menu])
Message.channel.send({ embeds: [Embed], components: [RowOne, RowTwo, RowThree, RowFour] })
}
})
client.on('voiceStateUpdate', async (OldVoice, NewVoice) => {
if (NewVoice.channelId == BotConfig.ChannelId) {
await NewVoice.guild.channels.create({
name: `${NewVoice.member.user.username}'s Channel`,
type: ChannelType.GuildVoice,
parent: BotConfig.CategoryId || NewVoice.member.voice.channel.parentId,
userLimit: BotConfig.MaxUsers || NewVoice.member.voice.channel.userLimit
}).then(async Channel => {
db.set(`Temporary_${Channel.id}_${OldVoice.member.user.id}`, Channel.id)
await NewVoice.member.voice.setChannel(Channel)
})
}
setInterval(async () => {
if (OldVoice.channelId !== null && db.has(`Temporary_${OldVoice.channelId}_${OldVoice.member.user.id}`)) {
if (OldVoice.channel.members.filter(x => !x.user.bot).size == 0) {
let channel = OldVoice.guild.channels.cache.get(OldVoice.channelId)
await channel.delete();
await db.delete(`Temporary_${OldVoice.channelId}_${OldVoice.member.user.id}`);
}
}
}, 1000)
})
client.on('interactionCreate', async Interaction => {
if (Interaction.isButton()) {
const Channel = Interaction.member.voice.channel;
if (!Channel) return Interaction.reply({ content: `You are not in voice channel.`, ephemeral: true })
const Data = db.get(`Temporary_${Channel.id}_${Interaction.user.id}`)
if (Data !== Channel.id) return Interaction.reply({ content: `You are not a owner if the temporary channel`, ephemeral: true })
switch (Interaction.customId) {
case 'LockChannel': {
await Interaction.deferUpdate().catch(() => { })
Interaction.member.voice.channel.permissionOverwrites.set([
{
id: Interaction.guild.roles.everyone.id,
deny: [
PermissionsBitField.Flags.Connect
]
},
{
id: Interaction.user.id,
allow: [
PermissionsBitField.Flags.Connect
]
}
])
}
break;
case 'UnlockChannel': {
await Interaction.deferUpdate().catch(() => { })
Interaction.member.voice.channel.permissionOverwrites.set([
{
id: Interaction.guild.roles.everyone.id,
allow: [
PermissionsBitField.Flags.Connect
]
}
])
}
break;
case 'HideChannel': {
await Interaction.deferUpdate().catch(() => { })
Interaction.member.voice.channel.permissionOverwrites.set([
{
id: Interaction.guild.roles.everyone.id,
deny: [
PermissionsBitField.Flags.ViewChannel
]
},
{
id: Interaction.user.id,
allow: [
PermissionsBitField.Flags.ViewChannel
]
}
])
}
break;
case 'UnhideChannel': {
await Interaction.deferUpdate().catch(() => { })
Interaction.member.voice.channel.permissionOverwrites.set([
{
id: Interaction.guild.roles.everyone.id,
allow: [
PermissionsBitField.Flags.ViewChannel
]
}
])
}
break;
case 'RenameChannel': {
const Modal = new ModalBuilder()
.setCustomId('RenameModal')
.setTitle('Rename Channel')
const Name = new TextInputBuilder()
.setStyle(TextInputStyle.Short)
.setLabel('THE NEW NAME')
.setMaxLength(50)
.setCustomId('Name')
.setRequired(true)
const Row = new ActionRowBuilder().addComponents(Name)
Modal.addComponents(Row)
Interaction.showModal(Modal)
}
break;
case 'Mute': {
await Interaction.deferUpdate().catch(() => { })
Channel.members.forEach(async Members => {
const Member = Interaction.guild.members.cache.get(Members.id)
if (Member.id !== Interaction.user.id) Member.voice.setMute(true)
})
}
break;
case 'Unmute': {
await Interaction.deferUpdate().catch(() => { })
Channel.members.forEach(async Members => {
const Member = Interaction.guild.members.cache.get(Members.id)
if (Member.id !== Interaction.user.id) Member.voice.setMute(false)
})
}
break;
case 'Disconnect': {
await Interaction.deferUpdate().catch(() => { })
Channel.members.forEach(async Members => {
const Member = Interaction.guild.members.cache.get(Members.id)
if (Member.id !== Interaction.user.id) Member.voice.disconnect()
})
}
break;
case 'Delete_Channel': {
await Interaction.deferUpdate().catch(() => { })
db.delete(`Temporary_${Channel.id}_${Interaction.user.id}`)
await Channel.delete()
}
break;
case 'Ban_Member': {
const User = new UserSelectMenuBuilder().setPlaceholder('Select the User').setCustomId('UserMenu').setMaxValues(1)
const Row = new ActionRowBuilder().addComponents(User)
Interaction.reply({ content: `_ _`, components: [Row], ephemeral: true })
}
break;
case 'UsersManager': {
const Row = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setStyle(ButtonStyle.Secondary)
.setEmoji('1085177845065728062')
.setLabel('Mute')
.setCustomId('UsersManager_Mute'),
new ButtonBuilder()
.setStyle(ButtonStyle.Secondary)
.setEmoji('1085177849322946612')
.setLabel('Unmute')
.setCustomId('UsersManager_Unmute'),
new ButtonBuilder()
.setStyle(ButtonStyle.Secondary)
.setEmoji('1085177846911221770')
.setLabel('Deafen')
.setCustomId('UsersManager_Deafen'),
new ButtonBuilder()
.setStyle(ButtonStyle.Secondary)
.setEmoji('1085177842016452698')
.setLabel('Undeafen')
.setCustomId('UsersManager_Undeafen'))
Interaction.reply({ content: '_ _', components: [Row], ephemeral: true })
}
break;
case 'Customize_UserLimit': {
const Modal = new ModalBuilder()
.setCustomId('Customize_UsersLimit')
.setTitle('Customize Users Limit')
const Number = new TextInputBuilder()
.setStyle(TextInputStyle.Short)
.setLabel('The Number')
.setMaxLength(2)
.setCustomId('The_Number')
.setRequired(true)
const Row = new ActionRowBuilder().addComponents(Number)
Modal.addComponents(Row)
Interaction.showModal(Modal)
}
}
} else if (Interaction.isStringSelectMenu()) {
const Channel = Interaction.member.voice.channel;
if (!Channel) return Interaction.reply({ content: `You are not in voice channel.`, ephemeral: true })
const Data = db.get(`Temporary_${Channel.id}_${Interaction.user.id}`)
if (Data !== Channel.id) return Interaction.reply({ content: `You are not a owner if the temporary channel`, ephemeral: true })
if (Interaction.customId == 'Menu') {
await Interaction.deferUpdate().catch(() => { })
if (Interaction.guild.channels.cache.get(Channel.id).type === ChannelType.GuildVoice) {
Interaction.guild.channels.cache.get(Channel.id).setUserLimit(Interaction.values[0])
}
}
} else if (Interaction.isModalSubmit()) {
const Channel = Interaction.member.voice.channel;
if (!Channel) return Interaction.reply({ content: `You are not in voice channel.`, ephemeral: true })
const Data = db.get(`Temporary_${Channel.id}_${Interaction.user.id}`)
if (Data !== Channel.id) return Interaction.reply({ content: `You are not a owner if the temporary channel`, ephemeral: true })
if (Interaction.customId == 'RenameModal') {
const Name = Interaction.fields.getTextInputValue('Name')
await Channel.setName(Name)
Interaction.reply({ content: `The channel has been successfully changed.`, ephemeral: true })
} else if (Interaction.customId == 'Customize_UsersLimit') {
const Number = Interaction.fields.getTextInputValue('The_Number')
if (Channel.userLimit == Number) return Interaction.reply({ content: `The users limit is already \`${Number}\``, ephemeral: true })
Interaction.reply({ content: `The users limit has been changed from \`${Channel.userLimit || '0'}\` to \`${Number}\``, ephemeral: true })
await Channel.setUserLimit(Number)
}
}
})
/* Users Manager */
client.on('interactionCreate', async Interaction => {
if (Interaction.isButton()) {
const Channel = Interaction.member.voice.channel;
if (!Channel) return Interaction.reply({ content: `You are not in voice channel.`, ephemeral: true })
const Data = db.get(`Temporary_${Channel.id}_${Interaction.user.id}`)
if (Data !== Channel.id) return Interaction.reply({ content: `You are not a owner if the temporary channel`, ephemeral: true })
switch (Interaction.customId) {
case 'UsersManager_Mute': {
const Row = new ActionRowBuilder()
.addComponents(
new UserSelectMenuBuilder()
.setPlaceholder('Select the User from the Menu')
.setCustomId('UserManager_Mute')
.setMaxValues(1)
)
Interaction.reply({ content: '_ _', components: [Row], ephemeral: true })
}
break;
case 'UsersManager_Unmute': {
const Row = new ActionRowBuilder()
.addComponents(
new UserSelectMenuBuilder()
.setPlaceholder('Select the User from the Menu')
.setCustomId('UserManager_Unmute')
.setMaxValues(1))
Interaction.reply({ content: '_ _', components: [Row], ephemeral: true })
}
break;
case 'UsersManager_Deafen': {
const Row = new ActionRowBuilder()
.addComponents(
new UserSelectMenuBuilder()
.setPlaceholder('Select the User from the Menu')
.setCustomId('UserManager_Deafen')
.setMaxValues(1)
)
Interaction.reply({ content: '_ _', components: [Row], ephemeral: true })
}
break;
case 'UsersManager_Undeafen': {
const Row = new ActionRowBuilder()
.addComponents(
new UserSelectMenuBuilder()
.setPlaceholder('Select the User from the Menu')
.setCustomId('UserManager_Undeafen')
.setMaxValues(1)
)
Interaction.reply({ content: '_ _', components: [Row], ephemeral: true })
}
}
} else if (Interaction.isUserSelectMenu()) {
const Channel = Interaction.member.voice.channel;
if (!Channel) return Interaction.reply({ content: `You are not in voice channel.`, ephemeral: true })
const Data = db.get(`Temporary_${Channel.id}_${Interaction.user.id}`)
if (Data !== Channel.id) return Interaction.reply({ content: `You are not a owner if the temporary channel`, ephemeral: true })
switch (Interaction.customId) {
case 'UserManager_Mute': {
await Interaction.deferUpdate().catch(() => { })
Interaction.member.voice.channel.members.filter((Member) => Member.user.id == Interaction.values[0]).forEach((User) => {
const Member = Interaction.guild.members.cache.get(User.id)
Member.voice.setMute(true)
})
}
break;
case 'UserManager_Unmute': {
await Interaction.deferUpdate().catch(() => { })
Interaction.member.voice.channel.members.filter((Member) => Member.user.id == Interaction.values[0]).forEach((User) => {
const Member = Interaction.guild.members.cache.get(User.id)
Member.voice.setMute(false)
})
}
break;
case 'UserManager_Deafen': {
await Interaction.deferUpdate().catch(() => { })
Interaction.member.voice.channel.members.filter((Member) => Member.user.id == Interaction.values[0]).forEach((User) => {
const Member = Interaction.guild.members.cache.get(User.id)
Member.voice.setDeaf(true)
})
}
break;
case 'UserManager_Undeafen': {
await Interaction.deferUpdate().catch(() => { })
Interaction.member.voice.channel.members.filter((Member) => Member.user.id == Interaction.values[0]).forEach((User) => {
const Member = Interaction.guild.members.cache.get(User.id)
Member.voice.setDeaf(false)
})
}
}
}
})
client.login("prosess.env.token").catch(() => {
console.log(chalk.red('The Token is not valid ❌'))
})
process.on('uncaughtException', async () => { return })
process.on('uncaughtExceptionMonitor', async () => { return })
process.on('unhandledRejection', async () => { return })