From 44fa8d22631c0ee9ec01d05abc145ee1bf2dc23f Mon Sep 17 00:00:00 2001 From: Parsa Date: Tue, 26 Oct 2021 10:54:05 +0330 Subject: [PATCH] better v1 :+1: --- Commands/biography.command.js | 6 +-- Commands/botInfo.command.js | 7 +-- Commands/falHafez.command.js | 10 ++-- Commands/ghazal.js | 68 +++++++++++------------ Commands/hafezPicture.command.js | 92 ++++++++++++++++---------------- Commands/help.command.js | 7 +-- index.js | 16 +++--- 7 files changed, 104 insertions(+), 102 deletions(-) diff --git a/Commands/biography.command.js b/Commands/biography.command.js index 2f6a3bb..5151c21 100644 --- a/Commands/biography.command.js +++ b/Commands/biography.command.js @@ -1,8 +1,9 @@ const Discord = require("discord.js"); + module.exports.run = async (bot, message) => { - let embed1 = new Discord.MessageEmbed() + const embed = new Discord.MessageEmbed() .setColor("#fffff0") .setDescription(`📔 **زندگی نامه حافظ** 📔`) .addField( @@ -19,8 +20,7 @@ module.exports.run = async (bot, message) => message.author.displayAvatarURL({ dynamic: true }) ); - await message.channel.send(embed1); - + await message.channel.send(embed); }; module.exports.help = diff --git a/Commands/botInfo.command.js b/Commands/botInfo.command.js index 9ea0e6d..8c1f417 100644 --- a/Commands/botInfo.command.js +++ b/Commands/botInfo.command.js @@ -1,9 +1,10 @@ -const { MessageEmbed } = require("discord.js"); -const os = require("os"); +const os = require("os"), + Discord = require("discord.js"); + module.exports.run = async (client, message) => { - const embed = new MessageEmbed() + const embed = new Discord.MessageEmbed() .setThumbnail(client.user.displayAvatarURL()) .setTitle("📔 **آمار بات الایت حافظ** 📔") .setFooter( diff --git a/Commands/falHafez.command.js b/Commands/falHafez.command.js index 9c2b281..db0b415 100644 --- a/Commands/falHafez.command.js +++ b/Commands/falHafez.command.js @@ -1,5 +1,6 @@ -const Discord = require("discord.js"); -const axios = require("axios"); +const axios = require("axios"), + Discord = require("discord.js"); + module.exports.run = async (bot, message) => { @@ -17,7 +18,7 @@ module.exports.run = async (bot, message) => explanation = `${data.explanation}`, - embed1 = new Discord.MessageEmbed() + embed = new Discord.MessageEmbed() .setColor("#fffff0") .setDescription(`📔 **(${numberRandom}) فال حافظ** 📔`) .addField( @@ -33,8 +34,7 @@ module.exports.run = async (bot, message) => message.author.displayAvatarURL({ dynamic: true }) ); - await message.channel.send(embed1); - + await message.channel.send(embed); }; module.exports.help = diff --git a/Commands/ghazal.js b/Commands/ghazal.js index 5745e06..4618cfa 100644 --- a/Commands/ghazal.js +++ b/Commands/ghazal.js @@ -1,41 +1,41 @@ -const Discord = require("discord.js"); -const axios = require("axios"); +const axios = require("axios"), + Discord = require("discord.js"); + module.exports.run = async (bot, message) => { - const number_random = Math.floor(Math.random() * 495), - - getInfo = async () => - { - let response = await axios.get(`https://api.falehafez.org/`); - return response.data; - }, - - data = await getInfo(), - - poem = `${data.poem[0]} — ${data.poem[1]}\n> ${data.poem[2]} — ${data.poem[3]}\n> ${data.poem[4]} — ${data.poem[5]}\n> ${data.poem[6]} — ${data.poem[7]}\n> ${data.poem[8]} — ${data.poem[9]}\n> ${data.poem[10]} — ${data.poem[11]}`, - - embed1 = new Discord.MessageEmbed() - .setColor("#fffff0") - .setDescription(`📔 **(${number_random}) غزلیات حافظ** 📔`) - .addField( - "**: شعر 📔**", - `> ${poem}` - ) - - .setImage( - "https://cdn.discordapp.com/attachments/776425421968244768/832315187830849576/Hafez.jpg" - ) - .setFooter( - " : درخواست شده توسط " + message.member.displayName, - message.author.displayAvatarURL({ dynamic: true }) - ); - await message.channel.send(embed1); - + const number_random = Math.floor(Math.random() * 495), + + getInfo = async () => + { + let response = await axios.get(`https://api.falehafez.org/`); + return response.data; + }, + + data = await getInfo(), + + poem = `${data.poem[0]} — ${data.poem[1]}\n> ${data.poem[2]} — ${data.poem[3]}\n> ${data.poem[4]} — ${data.poem[5]}\n> ${data.poem[6]} — ${data.poem[7]}\n> ${data.poem[8]} — ${data.poem[9]}\n> ${data.poem[10]} — ${data.poem[11]}`, + + embed1 = new Discord.MessageEmbed() + .setColor("#fffff0") + .setDescription(`📔 **(${number_random}) غزلیات حافظ** 📔`) + .addField( + "**: شعر 📔**", + `> ${poem}` + ) + + .setImage( + "https://cdn.discordapp.com/attachments/776425421968244768/832315187830849576/Hafez.jpg" + ) + .setFooter( + " : درخواست شده توسط " + message.member.displayName, + message.author.displayAvatarURL({ dynamic: true }) + ); + await message.channel.send(embed1); }; module.exports.help = { - name: "ghazal", - aliases: ["poem"] -}; + name: "ghazal", + aliases: ["poem"] + }; diff --git a/Commands/hafezPicture.command.js b/Commands/hafezPicture.command.js index 382b12a..3df5a49 100644 --- a/Commands/hafezPicture.command.js +++ b/Commands/hafezPicture.command.js @@ -1,54 +1,54 @@ -const Discord = require("discord.js"); -const axios = require("axios"); +const axios = require("axios"), + Discord = require("discord.js"); + module.exports.run = async (bot, message) => { - const numberRandom = Math.floor(Math.random() * 495), - - getInfo = async () => - { - let response = await axios.get(`https://api.falehafez.org/`); - return response.data; - }, - - data = await getInfo(), - - poem = `${data.poem[0]} — ${data.poem[1]}`, - - repliesPic = - [ - "https://cdn.discordapp.com/attachments/760896469023850588/832576634489929728/782482961-talab-org.jpg", - "https://cdn.discordapp.com/attachments/760896469023850588/832576633667715112/1.jpg", - "https://cdn.discordapp.com/attachments/760896469023850588/832576633901678602/b5759593fdad5a8d.jpg", - "https://cdn.discordapp.com/attachments/760896469023850588/832576634078625832/ef6cdaaf78ea9696.jpg", - "https://cdn.discordapp.com/attachments/760896469023850588/832576634279428136/Hamgardi_0349zvzbc89_resize.jpg", - "https://cdn.discordapp.com/attachments/760896469023850588/832577287551451177/1660401.jpg", - "https://cdn.discordapp.com/attachments/760896469023850588/832577287693533194/e67ebce5d3751d45.png" - ], - - ranNum = Math.floor(Math.random() * 7), - - image = repliesPic[ranNum]; - - - const embed1 = new Discord.MessageEmbed() - .setColor("#fffff0") - .setDescription(`📔 **(${numberRandom}) عکس حافظ** 📔`) - .addField( - "**: شعر 📔**", - `> ${poem}` - ) - .setImage(image) - .setFooter( - " : درخواست شده توسط " + message.member.displayName, - message.author.displayAvatarURL({ dynamic: true }) - ); - - await message.channel.send(embed1); + const numberRandom = Math.floor(Math.random() * 495), + + getInfo = async () => + { + let response = await axios.get(`https://api.falehafez.org/`); + return response.data; + }, + + data = await getInfo(), + + poem = `${data.poem[0]} — ${data.poem[1]}`, + + repliesPic = + [ + "https://cdn.discordapp.com/attachments/760896469023850588/832576634489929728/782482961-talab-org.jpg", + "https://cdn.discordapp.com/attachments/760896469023850588/832576633667715112/1.jpg", + "https://cdn.discordapp.com/attachments/760896469023850588/832576633901678602/b5759593fdad5a8d.jpg", + "https://cdn.discordapp.com/attachments/760896469023850588/832576634078625832/ef6cdaaf78ea9696.jpg", + "https://cdn.discordapp.com/attachments/760896469023850588/832576634279428136/Hamgardi_0349zvzbc89_resize.jpg", + "https://cdn.discordapp.com/attachments/760896469023850588/832577287551451177/1660401.jpg", + "https://cdn.discordapp.com/attachments/760896469023850588/832577287693533194/e67ebce5d3751d45.png" + ], + + ranNum = Math.floor(Math.random() * 7), + + image = repliesPic[ranNum], + + embed = new Discord.MessageEmbed() + .setColor("#fffff0") + .setDescription(`📔 **(${numberRandom}) عکس حافظ** 📔`) + .addField( + "**: شعر 📔**", + `> ${poem}` + ) + .setImage(image) + .setFooter( + " : درخواست شده توسط " + message.member.displayName, + message.author.displayAvatarURL({ dynamic: true }) + ); + + await message.channel.send(embed); }; module.exports.help = { - name: "", - aliases: ["p"] + name: "", + aliases: ["p"] }; diff --git a/Commands/help.command.js b/Commands/help.command.js index 451981b..def8c4a 100644 --- a/Commands/help.command.js +++ b/Commands/help.command.js @@ -1,9 +1,10 @@ -const { MessageEmbed } = require("discord.js"); -const { prefix } = require("../config.json"); +const Discord = require("discord.js"), + { prefix } = require("../config.json"); + module.exports.run = async (bot, message) => { - const embed = new MessageEmbed() + const embed = new Discord.MessageEmbed() .setThumbnail(bot.user.displayAvatarURL()) .setTitle("📔 **صفحه راهنمایی** 📔") .setDescription( diff --git a/index.js b/index.js index 8fb77ec..512729a 100644 --- a/index.js +++ b/index.js @@ -1,9 +1,8 @@ -const Discord = require("discord.js"); -const { MessageEmbed } = require("discord.js"); -const fs = require("fs"); -const { prefix, token } = require("config.json") +const fs = require("fs"), + Discord = require("discord.js"), + { prefix, token } = require("config.json"), -const bot = new Discord.Client({ ws: { properties: { $browser: "Discord iOS" } }}) + bot = new Discord.Client({ ws: { properties: { $browser: "Discord iOS" } }}) bot.commands = new Discord.Collection(); bot.aliases = new Discord.Collection(); @@ -19,12 +18,13 @@ fs.readdir("./commands/", (err, files) => return; } - file.forEach((f, i) => + file.forEach((f) => { let props = require(`./commands/${f}`); console.log(`| ✅ ${f} loaded! `); bot.commands.set(props.help.name, props); - props.help.aliases.forEach((alias) => { + props.help.aliases.forEach((alias) => + { bot.aliases.set(alias, props.help.name); }); }); @@ -76,7 +76,7 @@ bot.on("message", async message => { const prefixRegex = new RegExp(`^(<@!?${bot.user.id}>)\\s*`), - embed = new MessageEmbed() + embed = new Discord.MessageEmbed() .setColor('#fffff0') .setTitle(`پری فیکس من ❗ ${prefix}\` است`);