Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.16 KB | None | 0 0
  1. const Discord = require("discord.js");
  2. const client = new Discord.Client();
  3. const jimp = require("jimp")
  4. const Enmap = require('Enmap')
  5. const fs = require('fs')
  6. const config = require("./config.json");
  7. client.commands = new Enmap();
  8.  
  9. fs.readdir("./events/", (err, files) => {
  10. if (err) return console.error(err);
  11. files.forEach(file => {
  12. // If the file is not a JS file, ignore it (thanks, Apple)
  13. if (!file.endsWith(".js")) return;
  14. // Load the event file itself
  15. const event = require(`./events/${file}`);
  16. // Get just the event name from the file name
  17. let eventName = file.split(".")[0];
  18. // super-secret recipe to call events with all their proper arguments *after* the `client` var.
  19. // without going into too many details, this means each event will be called with the client argument,
  20. // followed by its "normal" arguments, like message, member, etc etc.
  21. // This line is awesome by the way. Just sayin'.
  22. client.on(eventName, event.bind(null, client));
  23. delete require.cache[require.resolve(`./events/${file}`)];
  24. });
  25. });
  26.  
  27. fs.readdir("./commands/", (err, files) => {
  28. if (err) return console.error(err);
  29. files.forEach(file => {
  30. if (!file.endsWith(".js")) return;
  31. // Load the command file itself
  32. let props = require(`./commands/${file}`);
  33. // Get just the command name from the file name
  34. let commandName = file.split(".")[0];
  35. console.log(`Attempting to load command ${commandName}`);
  36. // Here we simply store the whole thing in the command Enmap. We're not running it right now.
  37. client.commands.set(commandName, props);
  38. });
  39. });
  40.  
  41.  
  42. client.on("ready", () => {
  43. console.log(`Bot foi iniciado, com ${client.users.size} usuários, em ${client.channels.size} canais, em ${client.guilds.size} servidores.`);
  44. client.user.setPresence({ game: { name: 'teste' , type: 'WATCHING' }, status: 'idle' })
  45. });
  46.  
  47. client.on("guildMemberAdd", async member => {
  48.  
  49. let canal = client.channels.get("612838303414353920")
  50. let canalbv = client.channels.get("622882451672530974")
  51. let fonte = await jimp.loadFont(jimp.FONT_SANS_32_BLACK)
  52. let mask = await jimp.read('mascara.png')
  53. let fundo = await jimp.read('fundo.png')
  54.  
  55. jimp.read(member.user.displayAvatarURL).then(avatar => {
  56. avatar.resize(130, 130)
  57. mask.resize(130, 130)
  58. avatar.mask(mask)
  59. fundo.print(fonte, 195, 175, member.user.username)
  60. fundo.composite(avatar, 40, 90).write('bemvindo.png')
  61. canalbv.send(`${member.user} entrou no servidor!`)
  62. canalbv.send(``, { files: ["bemvindo.png"]})
  63.  
  64. console.log('Imagem enviada para o discord')
  65. })
  66.  
  67. .catch(err => {
  68. console.log('Erro ao carregar a imagem')
  69. })
  70. })
  71.  
  72. client.on("guildCreate", guild => {
  73. console.log(`O bot entrou nos servidores: ${guild.name} (id: ${guild.id}). População: ${guild.memberCount} membros!`)
  74. client.user.setActivity('YouTube', { type: 'WATCHING' });
  75. });
  76.  
  77. client.on("guildDelete", guild => {
  78. console.log(`O bot foi removido do servidor: ${guild.name} (id: ${guild.id})`);
  79. });
  80.  
  81. client.on("message", async message => {
  82. });
  83.  
  84. client.login(config.token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement