Skip to content

Update | Multi Instance #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 0 additions & 3 deletions .env.example

This file was deleted.

23 changes: 17 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- [x] MessageButton
- [x] No Database
- [x] Easy to use
- [x] Multi Bot Login (Per Prefix!) [Unlimited Bot Added]

## 🎶 Support Source
- [x] Youtube
Expand Down Expand Up @@ -32,12 +33,22 @@ After installation finishes you can use `node .` to start the bot. or `Run Start

## 📚 Configuration

Copy or Rename `.env.example` to `.env` and fill out the values:

```.env
TOKEN=replace_on_here
PREFIX=!
OWNER_ID=replace_on_here
Copy or Rename `config.json.example` to `config.json` and fill out the values:

```json
{
"TOKEN": [
"TOKEN_BOT_1",
"TOKEN_BOT_2",
"TOKEN_BOT_3"
],
"PREFIX": [
"-",
"+",
"!"
],
"OWNER_ID": "YOUR_DISCORD_ID"
}
```

## 📄 Features & Commands
Expand Down
8 changes: 4 additions & 4 deletions commands/music/autoplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ module.exports = {
client.distube.toggleAutoplay(message);

const embed = new EmbedBuilder()
.setColor(message.client.color)
.setDescription(`\`⏯\` Activate **Autoplay** mode.`)
.setColor("#000001")
.setDescription(`\`⏯\` Activate **Autoplay** mode.`);

msg.edit({ content: ' ', embeds: [embed] });
} else {
client.distube.toggleAutoplay(message);

const embed = new EmbedBuilder()
.setColor(message.client.color)
.setDescription(`\`⏯\` Disable **Autoplay** mode.`)
.setColor("#000001")
.setDescription(`\`⏯\` Disable **Autoplay** mode.`);

msg.edit({ content: ' ', embeds: [embed] });
}
Expand Down
2 changes: 1 addition & 1 deletion commands/music/queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {
const queue = client.distube.getQueue(message);
if (!queue) message.channel.send(`There is nothing in the queue right now!`)
const { channel } = message.member.voice;
if (!channel || message.member.voice.channel !== message.guild.me.voice.channel) return message.channel.send("You need to be in a same/voice channel.")
if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return message.channel.send("You need to be in a same/voice channel.")

const pagesNum = Math.ceil(queue.songs.length / 10);
if(pagesNum === 0) pagesNum = 1;
Expand Down
13 changes: 13 additions & 0 deletions config.json.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"TOKEN": [
"TOKEN_BOT_1",
"TOKEN_BOT_2",
"TOKEN_BOT_3"
],
"PREFIX": [
"-",
"+",
"!"
],
"OWNER_ID": "YOUR_DISCORD_ID"
}
58 changes: 0 additions & 58 deletions disspace.js

This file was deleted.

37 changes: 15 additions & 22 deletions events/client/ready.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
const figlet = require('figlet');
const chalk = require('chalk');

module.exports = async (client) => {
figlet(client.user.tag, function(err, data) {
if (err) {
console.log('Something went wrong...');
console.dir(err);
return;
}
console.log(chalk.red.bold(data));
});
console.log(`Logged in as ${client.user.tag}!`);

let guilds = client.guilds.cache.size;
let users = client.users.cache.size;
let channels = client.channels.cache.size;
let guilds = client.guilds.cache.size;
let users = client.users.cache.size;
let channels = client.channels.cache.size;

const activities = [
`${client.prefix}help | ${guilds} servers`,
`${client.prefix}play <input> | ${users} users`,
`${client.prefix}filterlist | ${channels} channels`,
]
const activities = [
`${client.prefix}help | ${guilds} servers`,
`${client.prefix}play <input> | ${users} users`,
`${client.prefix}filterlist | ${channels} channels`,
];

setInterval(() => {
client.user.setActivity(`${activities[Math.floor(Math.random() * activities.length)]}`, { type: 'WATCHING' });
}, 15000)
setInterval(() => {
client.user.setPresence({
activities: [{ name: `${activities[Math.floor(Math.random() * activities.length)]}`, type: 2 }],
status: 'online',
});
}, 15000)
}
2 changes: 1 addition & 1 deletion events/client/shardDisconnect.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const chalk = require("chalk");

module.exports = (client, event, id) => {
console.log(chalk.redBright(`[${String(new Date).split(" ", 5).join(" ")}] || ==> || Shard #${id} Disconnected`))
// console.log(chalk.redBright(`[${String(new Date).split(" ", 5).join(" ")}] || ==> || Shard #${id} Disconnected`))
}
2 changes: 1 addition & 1 deletion events/client/shardError.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const chalk = require("chalk");

module.exports = (client, error, id) => {
console.log(chalk.red(`[${String(new Date).split(" ", 5).join(" ")}] || ==> || Shard #${id} Errored`))
// console.log(chalk.red(`[${String(new Date).split(" ", 5).join(" ")}] || ==> || Shard #${id} Errored`))
}
4 changes: 2 additions & 2 deletions events/client/shardReady.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ const chalk = require("chalk");
const delay = require("delay");

module.exports = async (client, id) => {
await delay(2000);
console.log(chalk.greenBright(`[${String(new Date).split(" ", 5).join(" ")}] || ==> || Shard #${id} Ready`))
// await delay(2000);
// console.log(chalk.greenBright(`[${String(new Date).split(" ", 5).join(" ")}] || ==> || Shard #${id} Ready`))
}
2 changes: 1 addition & 1 deletion events/client/shardReconnecting.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const chalk = require("chalk");

module.exports = (client, id) => {
console.log(chalk.yellowBright(`[${String(new Date).split(" ", 5).join(" ")}] || ==> || Shard #${id} Reconnecting`))
// console.log(chalk.yellowBright(`[${String(new Date).split(" ", 5).join(" ")}] || ==> || Shard #${id} Reconnecting`))
}
2 changes: 1 addition & 1 deletion events/client/shardResume.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const chalk = require("chalk");

module.exports = (client, id, replayedEvents) => {
console.log(chalk.yellow(`[${String(new Date).split(" ", 5).join(" ")}] || ==> || Shard #${id} Resumed`))
// console.log(chalk.yellow(`[${String(new Date).split(" ", 5).join(" ")}] || ==> || Shard #${id} Resumed`))
}
2 changes: 1 addition & 1 deletion events/guild/messageCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = async (client, message) => {
if(!message.guild.members.me.permissions.has(PermissionsBitField.Flags.SendMessages)) return await message.author.dmChannel.send({ content: `I don't have perm **\`SEND_MESSAGES\`** permission in <#${message.channelId}> to execute command!` }).catch(() => {});
if(!message.guild.members.me.permissions.has(PermissionsBitField.Flags.EmbedLinks)) return await message.channel.send({ content: `I don't have perm **\`EMBED_LINKS\`** to execute command!` }).catch(() => {});

console.log(`[COMMAND] ${command.config.name} executed by ${message.author.tag}`);
console.log(`[COMMAND] ${command.config.name} executed by ${message.author.tag} | [${client.user.tag}] in ${message.guild.name} (${message.guild.id})`);

try {
command.run(client, message, args);
Expand Down
4 changes: 2 additions & 2 deletions handlers/loadCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ module.exports = async (client) => {
};
};
["music", "filters", "utilities"].forEach(x => load(x));
await delay(4000);
console.log(chalk.greenBright(`[INFORMATION] Command Events Loaded`));
// await delay(4000);
// console.log(chalk.greenBright(`[INFORMATION] Command Events Loaded`));
};
4 changes: 2 additions & 2 deletions handlers/loadDistube.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ module.exports = async (client) => {
} catch (e) {
console.log(e);
}
await delay(4000);
console.log(chalk.greenBright(`[INFORMATION] Distube Events Loaded`));
// await delay(4000);
// console.log(chalk.greenBright(`[INFORMATION] Distube Events Loaded`));
};
4 changes: 2 additions & 2 deletions handlers/loadEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ module.exports = async (client, message) => {
};
};
["client", "guild"].forEach(x => load(x));
await delay(4000);
console.log(chalk.greenBright(`[INFORMATION] Global Events Loaded`));
// await delay(4000);
// console.log(chalk.greenBright(`[INFORMATION] Global Events Loaded`));
};
58 changes: 54 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,57 @@
const { Client, Collection, GatewayIntentBits } = require("discord.js");
const { DisTube } = require('distube');
const { SoundCloudPlugin } = require('@distube/soundcloud');
const { SpotifyPlugin } = require('@distube/spotify');
const { YtDlpPlugin } = require("@distube/yt-dlp");

const MainClient = require("./disspace");
const client = new MainClient();
/// Call Config
const { TOKEN, PREFIX, OWNER_ID } = require("./config.json");

client.connect()
process.on('unhandledRejection', error => console.log(error));
process.on('uncaughtException', error => console.log(error));

module.exports = client;
/// Multi bot login support
for (let i = 0; i < TOKEN.length ; i++) {
const client = new Client({
shards: "auto",
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.MessageContent,
],
allowedMentions: {
parse: ["roles", "users", "everyone"],
repliedUser: false
},
});

client.config = require('./config.json');
// Print prefix
client.prefix = PREFIX[i];
client.owner = OWNER_ID;

// Print bot token
if (!client.token) client.token = TOKEN[i];

client.distube = new DisTube(client, {
searchSongs: 0, /// SET TO 5 FOR ENABLE SEARCH MODE!
searchCooldown: 30,
leaveOnEmpty: true,
emptyCooldown: 60,
leaveOnFinish: true,
leaveOnStop: true,
plugins: [
new SoundCloudPlugin(),
new SpotifyPlugin({
emitEventsAfterFetching: true
}),
new YtDlpPlugin()],
});

["aliases", "commands"].forEach(x => client[x] = new Collection());
["loadCommands", "loadEvents", "loadDistube"].forEach(x => require(`./handlers/${x}`)(client));

client.login(client.token);
}
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
"delay": "^5.0.0",
"discord.js": "^14.1.2",
"distube": "^4.0.3",
"dotenv": "^14.3.2",
"ffmpeg-static": "^4.4.1",
"figlet": "^1.5.2",
"libsodium-wrappers": "^0.7.9",
"lyrics-finder": "^21.7.0",
"opusscript": "^0.0.8"
Expand Down
7 changes: 0 additions & 7 deletions settings/config.js

This file was deleted.