-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.js
130 lines (120 loc) · 3.87 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
/*
Make Online your Bot in Discord.js V14
Hope you Enjoy, Made with 🤍 by CalledMasih
GitHub: https://github.com/calledmasih | Don't forget to ⭐
Website: https://calledmasih.ir/
Copyright Masih 2024 All Right Reserved!
*/
const {
Client,
GatewayIntentBits,
EmbedBuilder,
ActivityType,
} = require("discord.js");
const { joinVoiceChannel } = require("@discordjs/voice");
const config = require("./config.json");
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildPresences,
],
});
client.on("ready", async () => {
const voiceChannel = client.channels.cache.get(config.voiceChannelId);
// Make Random status and Activity
async function changeStatus() {
const members = await voiceChannel.guild.members.fetch({
withPresences: true,
});
const onlineMembersCount = members.filter(
(m) =>
m.presence?.status === "online" ||
m.presence?.status === "idle" ||
m.presence?.status === "dnd"
).size;
const activeMicsCount = members.filter((m) => m.voice.channel).size;
const activityName = [
`${voiceChannel.guild.name}`, // Guild Name
`${voiceChannel.guild.memberCount} Members`, // Guild Members Count
`${onlineMembersCount} Online`, // Online Guild Members Count
`${activeMicsCount} Active Mics`, // Total Members that Join to a Voice Channel
];
const activityType = [
ActivityType.Competing,
ActivityType.Watching,
ActivityType.Watching,
ActivityType.Listening,
];
const status = ["online", "idle", "dnd"];
const random = Math.floor(Math.random() * activityName.length);
client.user.setPresence({
status: status[random],
activities: [{ name: activityName[random], type: activityType[random] }],
});
}
// Refresh the Info every 15s
setInterval(changeStatus, 15_000);
// Join to a Voice Channel
function joinVoice() {
joinVoiceChannel({
channelId: voiceChannel.id,
guildId: voiceChannel.guild.id,
selfDeaf: true, // Also you change it to false for unDeafen in Voice Channel
adapterCreator: voiceChannel.guild.voiceAdapterCreator,
});
}
setInterval(joinVoice, 30_000);
// RGB Role (Edit your Role with random color)
function editRole() {
const rgbRole = voiceChannel.guild.roles.cache.get(config.rgbRoleId);
rgbRole.edit({ color: "Random" });
}
// Edit the Role color every 5 minutes
setInterval(editRole, 300_000);
console.log(
`Logged in as ${client.user.tag}\nGitHub: https://github.com/calledmasih | Don't forget to ⭐`
);
});
client.on("messageCreate", async (message) => {
// Advanced Ping Command
if (message.content.startsWith(`${config.prefix}ping`)) {
await message.channel.sendTyping();
const pingEmbed = new EmbedBuilder()
.setTitle(client.user.username + " - Pong!")
.setThumbnail(client.user.displayAvatarURL({ size: 1024 }))
.addFields(
{
name: `🛰 Message Ping:`,
value: `${Date.now() - message.createdTimestamp}ms`,
},
{
name: `📊 API Latency:`,
value: `${Math.round(client.ws.ping)}ms`,
},
{
name: `⏳ Uptime:`,
value: `<t:${Math.round(
client.readyTimestamp / 1000
)}:f> | <t:${Math.round(client.readyTimestamp / 1000)}:R>`,
}
)
.setColor(message.guild.members.me.displayHexColor)
.setFooter({
text: `Requested by ${message.author.username}`,
iconURL: message.author.displayAvatarURL({ size: 1024 }),
})
.setTimestamp();
message.reply({
embeds: [pingEmbed],
allowedMentions: {
repliedUser: false,
},
});
message.react("✅");
}
});
// Log in to Your Application Bot
client.login(config.botToken);