Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require("discord.js");
- const client = new Discord.Client();
- const jimp = require("jimp")
- const Enmap = require('Enmap')
- const fs = require('fs')
- const config = require("./config.json");
- client.commands = new Enmap();
- fs.readdir("./events/", (err, files) => {
- if (err) return console.error(err);
- files.forEach(file => {
- // If the file is not a JS file, ignore it (thanks, Apple)
- if (!file.endsWith(".js")) return;
- // Load the event file itself
- const event = require(`./events/${file}`);
- // Get just the event name from the file name
- let eventName = file.split(".")[0];
- // super-secret recipe to call events with all their proper arguments *after* the `client` var.
- // without going into too many details, this means each event will be called with the client argument,
- // followed by its "normal" arguments, like message, member, etc etc.
- // This line is awesome by the way. Just sayin'.
- client.on(eventName, event.bind(null, client));
- delete require.cache[require.resolve(`./events/${file}`)];
- });
- });
- fs.readdir("./commands/", (err, files) => {
- if (err) return console.error(err);
- files.forEach(file => {
- if (!file.endsWith(".js")) return;
- // Load the command file itself
- let props = require(`./commands/${file}`);
- // Get just the command name from the file name
- let commandName = file.split(".")[0];
- console.log(`Attempting to load command ${commandName}`);
- // Here we simply store the whole thing in the command Enmap. We're not running it right now.
- client.commands.set(commandName, props);
- });
- });
- client.on("ready", () => {
- console.log(`Bot foi iniciado, com ${client.users.size} usuários, em ${client.channels.size} canais, em ${client.guilds.size} servidores.`);
- client.user.setPresence({ game: { name: 'teste' , type: 'WATCHING' }, status: 'idle' })
- });
- client.on("guildMemberAdd", async member => {
- let canal = client.channels.get("612838303414353920")
- let canalbv = client.channels.get("622882451672530974")
- let fonte = await jimp.loadFont(jimp.FONT_SANS_32_BLACK)
- let mask = await jimp.read('mascara.png')
- let fundo = await jimp.read('fundo.png')
- jimp.read(member.user.displayAvatarURL).then(avatar => {
- avatar.resize(130, 130)
- mask.resize(130, 130)
- avatar.mask(mask)
- fundo.print(fonte, 195, 175, member.user.username)
- fundo.composite(avatar, 40, 90).write('bemvindo.png')
- canalbv.send(`${member.user} entrou no servidor!`)
- canalbv.send(``, { files: ["bemvindo.png"]})
- console.log('Imagem enviada para o discord')
- })
- .catch(err => {
- console.log('Erro ao carregar a imagem')
- })
- })
- client.on("guildCreate", guild => {
- console.log(`O bot entrou nos servidores: ${guild.name} (id: ${guild.id}). População: ${guild.memberCount} membros!`)
- client.user.setActivity('YouTube', { type: 'WATCHING' });
- });
- client.on("guildDelete", guild => {
- console.log(`O bot foi removido do servidor: ${guild.name} (id: ${guild.id})`);
- });
- client.on("message", async message => {
- });
- client.login(config.token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement