Mega_jeux

Untitled

Jul 13th, 2023 (edited)
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. // index.js
  2.  
  3. const Discord = require('discord.js')
  4. const intents = new Discord.IntentsBitField(3276799)
  5. const bot = new Discord.Client({intents})
  6. const loadCommands = require('./loader/LoadCommands.js')
  7. const loadEvents = require('./loader/LoadEvent.js')
  8.  
  9. bot.commands = new Discord.Collection()
  10. loadCommands(bot)
  11. loadEvents(bot)
  12.  
  13. bot.login("le token")
  14.  
  15. // Commandes
  16.  
  17. // ping.js
  18.  
  19. const Discord = require('discord.js');
  20.  
  21. module.exports = {
  22.  
  23. name: "ping",
  24.  
  25. async run(bot, message) {
  26.  
  27. await message.reply(`Ping : \`${bot.ws.ping}\``)
  28. }
  29. }
  30.  
  31. // Events
  32.  
  33. // messageCreate.js
  34.  
  35. const Discord = require('discord.js')
  36.  
  37. module.exports = async (bot, message) => {
  38.  
  39. let prefix = "?";
  40.  
  41. let messageArray = message.content.split(" ")
  42. let commandname = messageArray[0].slice(prefix.length)
  43. let args = messageArray.slice(1)
  44.  
  45. if (!message.content.startsWith(prefix)) return;
  46.  
  47. let command = require(`../commandes/${commandname}`)
  48. if (!command) return message.reply("Cette commande n'existe pas.")
  49.  
  50. command.run(bot, message, args)
  51. }
  52.  
  53. // ready.js
  54.  
  55. const Discord = require('discord.js');
  56.  
  57. module.exports = async bot => {
  58.  
  59. console.log(`${bot.user.tag} est en ligne !`);
  60.  
  61. }
  62.  
  63. // Loader
  64.  
  65. // LoadCommands.js
  66.  
  67. const fs = require('fs');
  68.  
  69. module.exports = async bot => {
  70.  
  71. fs.readdirSync("./commandes").filter(f => f.endsWith(".js")).forEach(async file => {
  72.  
  73. let command = require(`../commandes/${file}`);
  74. if(!command.name || typeof command.name !== "string") throw new TypeError(`La Commande ${file.slice(0, file.lengh - 3)} n'a pas de nom !`)
  75. bot.commands.set(command.name, command);
  76. console.log(`Commande ${command.name} chargée`)
  77. })
  78. }
  79.  
  80. // LoadEvent.js
  81.  
  82. const fs = require('fs');
  83.  
  84. module.exports = async bot => {
  85.  
  86. fs.readdirSync("./Events").filter(f => f.endsWith(".js")).forEach(async file => {
  87.  
  88. let Events = require(`../Events/${file}`);
  89. bot.on(file.split(".js").join(""), Events.bind(null, bot))
  90. console.log(`Evènement ${file} Chargé avec succès !`)
  91. })
  92. }
Advertisement
Add Comment
Please, Sign In to add comment