Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. const config = require('./config.json')
  2. const Discord = require('discord.js');
  3. const fs = require("fs");
  4. const bot = new Discord.Client({fetchAllMembers: true, disableEveryone: true});
  5. const monnaie = require('./monnaie.json');
  6. const exp = require('./exp.json');
  7. const DBL = require("dblapi.js");
  8. const dbl = new DBL('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjUwNTgzMDI1OTUxNDY3MTEyOSIsImJvdCI6dHJ1ZSwiaWF0IjoxNTQ3MzAwMTIyfQ.jT3fW6JWIv-3TEe3IIk0aed3pUx-PtMdMbLlGuDT-xc', bot);
  9. const { promisify } = require("util");
  10. const readdir = promisify(require("fs").readdir);
  11. const Enmap = require("enmap");
  12. const klaw = require("klaw");
  13. const path = require("path");
  14. const Collection = require("discord.js")
  15. const Client = require("discord.js");
  16.  
  17.  
  18.  
  19. class Solezi extends Client {
  20.  
  21. constructor(option) {
  22. super(option);
  23.  
  24.  
  25. this.settings = new Enmap({
  26. name: "settings",
  27. cloneLevel: "deep",
  28. fetchAll: false,
  29. autoFetch: true
  30. });
  31.  
  32. this.config = require("./config.js");
  33.  
  34. this.commands = new Collection();
  35. this.aliases = new Collection();
  36.  
  37. this.settings = new enmap({
  38. name: "settings",
  39. cloneLevel: "deep",
  40. fetchAll: false,
  41. autoFetch: true
  42. });
  43.  
  44. this.logger = require("./modules/Logger");
  45. this.wait = require("util").promisify(setTimeout);
  46. };
  47.  
  48. loadCommand(commandPath, commandName) {
  49. try{
  50. const props = new (require(`${commandPath}${path.sep}${commandName}`))(this);
  51. this.logger.log(`Chargement de la commande : ${props.help.name}`, "log");
  52. props.conf.location = commandPath;
  53. if (props.init) {
  54. props.init(this);
  55. }
  56. this.commands.set(props.help.name, props);
  57. props.conf.aliases.forEach(alias => {
  58. this.aliases.set(alias,props.help.name)
  59. });
  60. return false;
  61. } catch (e) {
  62. return `Une erreur est survenue avec la commande : ${commandName}`;
  63. }
  64. }
  65. getSettiings(guild) {
  66. const defaults = this.config.defaultSettings || {};
  67. const guildData = this.settings.get(guild.id) || {};
  68. const returnObjet = {};
  69. Object.keys(defaults).forEach(key => {
  70. returnObjet[key] = guildData[key] ? guildData[key] : defaults[key];
  71. });
  72. return returnObjet;
  73. }
  74.  
  75. }
  76.  
  77. const client = new Solezia();
  78.  
  79. //initialisation des commandes
  80. const init = async () => {
  81. klaw("./commands").on("data", item => {
  82. const cmdFile = path.parse(item.path);
  83. if (!cmdFile.ext || cmdFile.ext !== ".js ") return ;
  84. const reponse = client.loadCommand(cmdFile.dir , `${cmdFile.name}${cmdFile.ext}`);
  85. if (reponse) client.logger.error(reponse);
  86. });
  87.  
  88.  
  89. }
  90. init();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement