Skip to content
This repository was archived by the owner on Sep 28, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ const client = new Client({
initializationMoonlink(client);

client.commands = new Collection();
client.status = "online";

process.on("message", (message) => {
if (message && message.operation) {
if (message.operation == "offline") {
client.status = "dnd";
} else if (message.operation == "online") {
client.status = "online";
}
}
});

const functions = fs.readdirSync("./functions").filter(file => file.endsWith(".js"));
const eventFiles = fs.readdirSync("./events").filter(file => file.endsWith(".js"));
Expand Down
11 changes: 11 additions & 0 deletions events/interactionCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,17 @@ module.exports = {
async execute(interaction, client) {
const locale = new Locale(interaction.locale);

if (client.status != "online") {
return await interaction.reply({
embeds: [
new EmbedBuilder()
.setColor(Colors.Red)
.setTitle(locale.getLocaleString("interaction.client.notOnline"))
],
ephemeral: true
});
}

await handleInteraction(interaction, client, locale);

try {
Expand Down
13 changes: 9 additions & 4 deletions events/ready.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@ module.exports = {
"🎵 /play to play song",
];

client.user.setActivity({
name: status[currentStatus],
type: ActivityType.Custom
client.user.setPresence({
status: client.status,
activities: [
{
name: status[currentStatus],
type: ActivityType.Custom
}
]
});

if (currentStatus >= status.length - 1) {
Expand All @@ -37,7 +42,7 @@ module.exports = {

console.log(`[${client.shard.ids}] Ready! Logged in as ${client.user.tag}`);
console.log(`[${client.shard.ids}] Server Count: ${client.guilds.cache.size.toLocaleString()}`);

console.log(`[${client.shard.ids}] Member Count: ${client.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0).toLocaleString()}`);
setInterval(setActivity, 5 * 1000);

if (mongoDBUrl) {
Expand Down
41 changes: 41 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { REST } = require("@discordjs/rest");
const { Routes } = require("discord-api-types/v10");
const express = require("express");
const cors = require("cors");
const readline = require("readline");
const handleCommands = require("./utils/commands");

const package = require("./package.json");
Expand Down Expand Up @@ -116,4 +117,44 @@ require("dotenv").config();
api.listen(port, () => {
console.log(`\n\n🚀 Status page server is running at http://localhost:${port}/status\n\n`);
});

// Handle Console Input
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});

rl.on("line", async (input) => {
const cmdCommand = input.trim().toLowerCase();

switch (cmdCommand) {
case 'offline': {
console.log("🛑 Soft Offline all shards...");
await manager.broadcast({ operation: "offline", value: true });
console.log("✅ All shards soft offline successfully.");
break;
}
case 'online': {
console.log("🟢 Online all shards...");
await manager.broadcast({ operation: "online", value: true });
console.log("✅ All shards online successfully.");
break;
}
case 'restart': {
console.log("🔄 Restarting all shards...")
try {
// Restart all shards
await manager.respawnAll();
console.log("✅ All shards restarted successfully.");
} catch (error) {
console.error("❌ Error while restarting shards:", error);
}
break;
}
default: {
console.log(`Unknown command: ${input}`);
break;
}
}
});
})();
3 changes: 2 additions & 1 deletion locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,6 @@
"command.setting.search.saved": "💾 Saved default source with `{0}`",
"command.setting.search.save.fail": "❌ Fail to save default source with `{0}`",
"youtube.direct.disable.text": "# Want to listen to music directly from YouTube?\nYou can easily order through the HStudio website\n\n**[Support Discord](https://discord.gg/GzTbuZHTEx)**",
"youtube.direct.disable.button.text": "Buy now"
"youtube.direct.disable.button.text": "Buy now",
"interaction.client.notOnline": "❌ The bot is not online"
}