Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //اول شي سوي 3 ملفات
- //trgmh.json / asr3.json / fkk.json
- //اخر شي بتلاقي وش رح تكتب فيهم
- //هذا الكود تحطه بملفك الأساسي
- const Discord = require("discord.js");
- const bot = new Discord.Client({ disableEveryone: false });
- const mysql = require("mysql");
- var con = mysql.createConnection({
- host: "",//الهوست
- user: "",//اليوزرنيم
- password: "",//الباسورد
- database: ""// اسم الداتابيز
- });
- con.connect(function () {
- console.log("Connected to database")
- con.query("SHOW TABLES", console.log)
- setInterval(() => {
- con.query("select 1");
- }, 45000)
- })
- bot.on(`ready`, () => {
- function HelloCODESXD() { //فنكشن ماله داعي م عليكم منه XD
- console.log(`Logged in as ${bot.user.tag}!`);
- con.query('CREATE TABLE IF NOT EXISTS points(' //هذا عشان يسويلك تيبل اسمه بوينتز عشان يتخزن فيه النقاط
- + 'id VARCHAR(50) NOT NULL,'
- + 'PRIMARY KEY(id),'
- + 'points INT(11) NOT NULL'
- + ')', function (err) {
- if (err) console.log(err);
- });
- }
- HelloCODESXD();
- bot.user.setStatus("online")
- bot.user.setActivity('I\'m Lonely...', {
- type: "STREAMING",
- url: "https://www.twitch.tv/azoqzmj"
- });
- });
- bot.on('error', console.error);
- bot.on('message', async message => {
- let prefix = `$`
- let messageArray = message.content.split(" ");
- let msg = message;
- let cmd = messageArray[0];
- let args = messageArray.slice(1);
- if (!message.content.startsWith(prefix)) return
- function generatePoints() {
- return Math.floor(Math.random() * 1 - 0 + 1) + 0
- }
- con.query(`insert ignore into points(id, points) values("${message.author.id}", 0)`)
- if (cmd === `${prefix}اسرع`) {
- const stuff = require("./asr3.json")
- const Azoqz = stuff[[Math.floor(Math.random() * stuff.length)]];
- const filter = response => {
- return Azoqz.answer.some(answer => answer.toLowerCase() === response.content.toLowerCase());
- };
- let embed = new Discord.RichEmbed()
- .setColor('#109ae2')
- .setThumbnail(bot.user.avatarURL)
- .addField("اكتبها بدون حركات", `${Azoqz.Question}`)
- message.channel.send(embed).then(() => {
- message.channel.awaitMessages(filter, { maxMatches: 1, time: 10000, errors: ['time'] })
- .then((collected) => {
- let won = collected.first().author;
- con.query(`UPDATE points SET points = points + ${generatePoints()} WHERE id = "${won.id}"`)
- con.query(`SELECT * FROM points WHERE id = '${collected.first().author.id}'`, (err, rows) => {
- if (err) console.log(err)
- let points = rows[0].points;
- let embed = new Discord.RichEmbed()
- .setDescription("**أجابة صحيحة**")
- .addField("تمت الأجابة من قبل", `${won}`)
- .addField("النقاط الحالية", `${points}`)
- .setThumbnail(`${won.avatarURL}`)
- message.channel.send(embed);
- })
- }).catch(collected => {
- message.channel.send(`**الوقت انتهى ولم يتمكن اي شخص من الأجابة**`);
- })
- })
- }
- if (cmd === `${prefix}فكك`) {
- const stuff = require("./fkk.json")
- const Azoqz = stuff[[Math.floor(Math.random() * stuff.length)]];
- const filter = response => {
- return Azoqz.answer.some(answer => answer.toLowerCase() === response.content.toLowerCase());
- }
- let embed = new Discord.RichEmbed()
- .setColor('#109ae2')
- .setTitle("فكك الكلمة في الأسفل")
- .setThumbnail(bot.user.avatarURL)
- .setDescription(`${Azoqz.Question}`)
- message.channel.send(embed).then(() => {
- message.channel.awaitMessages(filter, { maxMatches: 1, time: 10000, errors: ['time'] })
- .then((collected) => {
- let won = collected.first().author;
- con.query(`UPDATE points SET points = points + ${generatePoints()} WHERE id = "${won.id}"`)
- con.query(`SELECT * FROM points WHERE id = '${collected.first().author.id}'`, (err, rows) => {
- if (err) console.log(err)
- let points = rows[0].points;
- let embed = new Discord.RichEmbed()
- .setDescription("**أجابة صحيحة**")
- .addField("تمت الأجابة من قبل", `${won}`)
- .addField("النقاط الحالية", `${points}`)
- .setThumbnail(`${won.avatarURL}`)
- message.channel.send(embed);
- })
- }).catch(collected => {
- message.channel.send(`**الوقت انتهى ولم يتمكن اي شخص من الأجابة**`);
- })
- })
- }
- if (cmd === `${prefix}ترجمة`) {
- const stuff = require("./trgmh.json")
- const Azoqz = stuff[[Math.floor(Math.random() * stuff.length)]];
- const filter = response => {
- return Azoqz.answer.some(answer => answer.toLowerCase() === response.content.toLowerCase());
- }
- let embed = new Discord.RichEmbed()
- .setColor('#109ae2')
- .setThumbnail(bot.user.avatarURL)
- .setTitle("ترجم الكلمة في الأسفل")
- .setDescription(`${Azoqz.Question}`)
- message.channel.send(embed).then(() => {
- message.channel.awaitMessages(filter, { maxMatches: 1, time: 10000, errors: ['time'] })
- .then((collected) => {
- let won = collected.first().author;
- con.query(`UPDATE points SET points = points + ${generatePoints()} WHERE id = "${won.id}"`)
- con.query(`SELECT * FROM points WHERE id = '${collected.first().author.id}'`, (err, rows) => {
- if (err) console.log(err)
- let points = rows[0].points;
- let embed = new Discord.RichEmbed()
- .setDescription("**أجابة صحيحة**")
- .addField("تمت الأجابة من قبل", `${won}`)
- .addField("النقاط الحالية", `${points}`)
- .setThumbnail(`${won.avatarURL}`)
- message.channel.send(embed);
- })
- }).catch(collected => {
- message.channel.send(`**الوقت انتهى ولم يتمكن اي شخص من الأجابة**`);
- })
- })
- }
- if (cmd === `${prefix}points`) {
- let target = message.guild.member(message.mentions.users.first() || message.author);
- con.query(`SELECT * FROM points WHERE id = '${target.id}'`, (err, rows) => {
- if (!rows[0]) return message.channel.send("No points registered")
- let points = rows[0].points;
- let target1 = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
- if (target1) {
- var embedd = new Discord.RichEmbed()
- .setColor('#109ae2')
- .setFooter("Azoqz From Codes")
- .setDescription(`**${target} has ${points} points**`)
- message.channel.send(embedd)
- } else if (target) {
- let embedddd = new Discord.RichEmbed()
- .setColor('#109ae2')
- .setFooter("Azoqz From Codes")
- .setDescription(`**You have ${points} points**`)
- message.channel.send(embedddd)
- }
- });
- }
- })
- bot.login("token")
- //هذا الكود تحطه بملف trgmh.json
- // [
- // {
- // "Question": "Hello",
- // "answer": ["مرحبا","مرحبًا","اهلاً"]
- // },
- // {
- // "Question": "Water",
- // "answer": ["ماء"]
- // },
- // {
- // "Question": "Watermelon",
- // "answer": ["بطيخ","حبحب"]
- // },
- // {
- // "Question": "Kill me",
- // "answer": ["اقتلني"]
- // },
- // {
- // "Question": "Milk",
- // "answer": ["حليب"]
- // },
- // {
- // "Question": "Man",
- // "answer": ["رجل"]
- // },
- // {
- // "Question": "Keyboard",
- // "answer": ["لوحة مفاتيح"]
- // },
- // {
- // "Question": "Rat",
- // "answer": ["جرذ","فار"]
- // },
- // {
- // "Question": "Key",
- // "answer": ["مفتاح"]
- // }
- // ]
- //هذا الكود الي رح تحطه في ars3.json
- // [
- // {
- // "Question": "الُسلاٌُم علًٍُيُكَم",
- // "answer": ["السلام عليكم"]
- // },
- // {
- // "Question": "كيف اُلًًحًاًل",
- // "answer": ["كيف الحال"]
- // },
- // {
- // "Question": "سيرُفر كودَز هٍو الأفًضل",
- // "answer": ["سيرفر كودز هو الأفضل", "سيرفر كودز هو الافضل"]
- // },
- // {
- // "Question": "عًز مبرٍمج فِاشل",
- // "answer": ["عز مبرمج فاشل","عز مبرمج جيد"]
- // },
- // {
- // "Question": "الممٍلكة العربيًة السعوديٍة",
- // "answer": ["المملكة العربية السعودية"]
- // },
- // {
- // "Question": "الأنمٍي ليًس للأَطفال",
- // "answer": ["الأنمي ليس للأطفال"]
- // },
- // {
- // "Question": "مسطرٍب أحمًق",
- // "answer": ["مسطرب أحمق"]
- // },
- // {
- // "Question": "ايًدٍت نوٍب",
- // "answer": ["ايدت نوب"]
- // },
- // {
- // "Question": "مسٍطرب صاحُب الذًكاء المٍخي والفطرًي",
- // "answer": ["مسطرب صاحب الذكاء المخي والفطري"]
- // },
- // {
- // "Question": "عزً و بُروم و مسٍطرب يًسيطرون علىٍ اُلعالم",
- // "answer": ["عز و بروم و مسطرب يسيطرون على العالم"]
- // }
- // ]
- //هذا الكود الي رح تحطه في fkk.json
- // [
- // {
- // "Question": "رتبة",
- // "answer": ["ر ت ب ة"]
- // },
- // {
- // "Question": "السعودية",
- // "answer": ["ا ل س ع و د ي ة"]
- // },
- // {
- // "Question": "كودز",
- // "answer": ["ك و د ز"]
- // },
- // {
- // "Question": "عبدالعزيز",
- // "answer": ["ع ب د ا ل ع ز ي ز"]
- // },
- // {
- // "Question": "جهاز",
- // "answer": ["ج ه ا ز"]
- // },
- // {
- // "Question": "ايفون",
- // "answer": ["ا ي ف و ن"]
- // },
- // {
- // "Question": "مال",
- // "answer": ["م ا ل"]
- // },
- // {
- // "Question": "جالاكسي",
- // "answer": ["ج ا ل ا ك س ي"]
- // },
- // {
- // "Question": "سوف اقتلك",
- // "answer": ["س و ف ا ق ت ل ك"]
- // },
- // {
- // "Question": "كمبيوتر",
- // "answer": ["ك م ب ي و ت ر"]
- // }
- // ]
- //تحياتي لكم ...
- //Azoqz From Codes
Advertisement
Add Comment
Please, Sign In to add comment