npm const { Client, GatewayIntentBits } = require('discord.js');
const dotenv = require('dotenv');
const fetch = require('node-fetch');
const { Configuration, OpenAIApi } = require('openai');
dotenv.config();
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] });
// إعداد OpenAI
const openai = new OpenAIApi(new Configuration({
apiKey: process.env.OPENAI_API_KEY,
}));
client.once('ready', () => {
console.log(`✅ Logged in as ${client.user.tag}`);
});
client.on('messageCreate', async message => {
if (message.author.bot) return;
const content = message.content.toLowerCase();
// 🎮 لعبة بسيطة
if (content === '!لعبة') {
const games = ['حجرة 🪨', 'مقص ✂️', 'ورقة 📄'];
const botChoice = games[Math.floor(Math.random() * games.length)];
message.reply(`أنا اخترت: ${botChoice}`);
}
// ✅ تفعيل
if (content.startsWith('!تفعيل')) {
message.reply('✅ تم تفعيل حسابك! مرحباً بك.');
}
// 🖼️ صور عشوائية
if (content === '!صورة') {
const url = 'https://source.unsplash.com/random/400x300';
message.reply({ content: '📸 إليك صورة عشوائية:', files: [url] });
}
// 🧠 ذكاء اصطناعي (GPT)
if (content.startsWith('!ذكي')) {
const userPrompt = content.replace('!ذكي', '').trim();
if (!userPrompt) return message.reply('🧠 اكتب شيء بعد الأمر !ذكي');
try {
const response = await openai.createChatCompletion({
model: "gpt-3.5-turbo",
messages: [{ role: "user", content: userPrompt }],
});
const reply = response.data.choices[0].message.content;
message.reply(reply);
} catch (err) {
console.error(err);
message.reply('❌ حصل خطأ أثناء محاولة الرد.');
}
}
});
client.login(process.env.DISCORD_TOKEN);
-
npm install discord.js dotenv openai node-fetch
DISCORD_TOKEN=توكن_البوت
OPENAI_API_KEY=مفتاح_API_من_OpenAI
const { Client, GatewayIntentBits } = require('discord.js');
const dotenv = require('dotenv');
const fetch = require('node-fetch');
const { Configuration, OpenAIApi } = require('openai');
dotenv.config();
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] });
// إعداد OpenAI
const openai = new OpenAIApi(new Configuration({
apiKey: process.env.OPENAI_API_KEY,
}));
client.once('ready', () => {
console.log(`✅ Logged in as ${client.user.tag}`);
});
client.on('messageCreate', async message => {
if (message.author.bot) return;
const content = message.content.toLowerCase();
// 🎮 لعبة بسيطة
if (content === '!لعبة') {
const games = ['حجرة 🪨', 'مقص ✂️', 'ورقة 📄'];
const botChoice = games[Math.floor(Math.random() * games.length)];
message.reply(`أنا اخترت: ${botChoice}`);
}
// ✅ تفعيل
if (content.startsWith('!تفعيل')) {
message.reply('✅ تم تفعيل حسابك! مرحباً بك.');
}
// 🖼️ صور عشوائية
if (content === '!صورة') {
const url = 'https://source.unsplash.com/random/400x300';
message.reply({ content: '📸 إليك صورة عشوائية:', files: [url] });
}
// 🧠 ذكاء اصطناعي (GPT)
if (content.startsWith('!ذكي')) {
const userPrompt = content.replace('!ذكي', '').trim();
if (!userPrompt) return message.reply('🧠 اكتب شيء بعد الأمر !ذكي');
try {
const response = await openai.createChatCompletion({
model: "gpt-3.5-turbo",
messages: [{ role: "user", content: userPrompt }],
});
const reply = response.data.choices[0].message.content;
message.reply(reply);
} catch (err) {
console.error(err);
message.reply('❌ حصل خطأ أثناء محاولة الرد.');
}
}
});
client.login(process.env.DISCORD_TOKEN);
Responds with a simple greeting - act - Miniforge