Guest User

Untitled

a guest
Oct 27th, 2023
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. const Discord = require("discord.js");
  2. const { Client, GatewayIntentBits, Partials } = require("discord.js");
  3. const client = new Client({
  4. partials: [
  5. Partials.Message, // para mensagens
  6. Partials.Channel, // para canais de texto
  7. Partials.GuildMember, // para membros do servidor
  8. Partials.Reaction, // para reações a mensagens
  9. ],
  10. intents: [
  11. GatewayIntentBits.Guilds, // para ações relacionadas ao servidor
  12. GatewayIntentBits.GuildInvites, // para gerenciar convites do servidor
  13. GatewayIntentBits.GuildMessages, // para mensagens do servidor
  14. GatewayIntentBits.GuildMessageReactions, // para reações a mensagens
  15. GatewayIntentBits.MessageContent, // ative se você precisar de informações de conteúdo de mensagem
  16. ],
  17. });
  18. const fs = require("fs");
  19. const config = require("./config.json");
  20. client.config = config;
  21.  
  22. /* Carregar todos os eventos (baseados no Discord) */
  23.  
  24. fs.readdir("./events/discord", (_err, files) => {
  25. files.forEach(file => {
  26. if (!file.endsWith(".js")) return;
  27. const event = require(`./events/discord/${file}`);
  28. let eventName = file.split(".")[0];
  29. console.log(`[Evento] ✅ Carregado: ${eventName}`);
  30. client.on(eventName, event.bind(null, client));
  31. delete require.cache[require.resolve(`./events/discord/${file}`)];
  32. });
  33. });
  34.  
  35. // Permitir que comandos sejam uma nova coleção (comandos de mensagens)
  36. client.commands = new Discord.Collection();
  37. /* Carregar todos os comandos */
  38. fs.readdir("./commands/", (_err, files) => {
  39. files.forEach(file => {
  40. if (!file.endsWith(".js")) return;
  41. let props = require(`./commands/${file}`);
  42. let commandName = file.split(".")[0];
  43. client.commands.set(commandName, {
  44. name: commandName,
  45. ...props
  46. });
  47. console.log(`[Comando] ✅ Carregado: ${commandName}`);
  48. });
  49. });
  50.  
  51. // Permitir que interações sejam uma nova coleção (comandos de barra)
  52. client.interactions = new Discord.Collection();
  53. // Criar um array vazio para registrar comandos de barra
  54. client.register_arr = [];
  55. /* Carregar todos os comandos de barra */
  56. fs.readdir("./slash/", (_err, files) => {
  57. files.forEach(file => {
  58. if (!file.endsWith(".js")) return;
  59. let props = require(`./slash/${file}`);
  60. let commandName = file.split(".")[0];
  61. client.interactions.set(commandName, {
  62. name: commandName,
  63. ...props
  64. });
  65. client.register_arr.push(props);
  66. });
  67. });
  68.  
  69. // Fazer login através do cliente
  70. client.login(config.token);
  71.  
Add Comment
Please, Sign In to add comment