const admin = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent
]
});
admin.on(Events.MessageCreate, async (message) => {
if (!message.guild || message.author.bot) return;
const args = message.content.trim().split(/ +/);
const command = args[0]?.toLowerCase();
if (!owners.has(message.author.id)) return;
if (command === "addtoken") {
const newToken = args[1];
if (!newToken) return message.reply("ex: addtoken [token_bot]");
const tokens = loadTokens();
if (tokens.includes(newToken)) return message.react("❌");
tokens.push(newToken);
saveTokens(tokens);
startBot(newToken);
message.react("✅");
}
const failedTokens =[];
if (command === "info-tokens") {
const descriptionLines = [];
bots.forEach(bot => {
const nameTag = bot.user?.tag || "Unknown#0000";
const _1 = bot.user?.id || "1";
const tokenPreview = bot.token?.slice(0, 10) || "??????????";
descriptionLines.push(
`[${nameTag}](https://discord.com/oauth2/authorize?client_id=${_1}&permissions=0&integration_type=0&scope=bot) [token: ${tokenPreview}...]`
);
});
if (failedTokens.length > 0) {
failedTokens.forEach(t => {
descriptionLines.push(`[FAILED] [token: ${t.slice(0, 10)}...] ❌`);
});
}
const MAX_LENGTH = 4000;
const embeds = [];
let lines = [];
let length = 0;
for (const line of descriptionLines) {
const lineLength = line.length + 1;
if (length + lineLength > MAX_LENGTH) {
embeds.push(
new EmbedBuilder()
.setTitle("حالة التوكنات")
.setDescription(lines.join("\n"))
.setColor("Blue")
);
lines = [];
length = 0;
}
lines.push(line);
length += lineLength;
}
if (lines.length > 0) {
embeds.push(
new EmbedBuilder()
.setTitle("حالة التوكنات")
.setDescription(lines.join("\n"))
.setColor("Blue")
);
}
for (const embed of embeds) {
await message.channel.send({ embeds: [embed] });
}
}
});
admin.login(config.main_bot);