Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Extract the required classes from the discord.js module
- const { Client, MessageAttachment } = require('discord.js');
- // Create an instance of a Discord client
- const client = new Client();
- /**
- * The ready event is vital, it means that only _after_ this will your bot start reacting to information
- * received from Discord
- */
- client.on('ready', () => {
- console.log('I am ready!');
- });
- client.on('message', message => {
- //if bot sends something
- if(message.author.bot) return;
- // If the message contains attachments
- if (message.attachments && message.attachments.length > 0) {
- //iterate trough attachments
- message.attachments.forEach(element => {
- // Send the attachment in the message channel with a content
- message.channel.send(`${message.author},`, element);
- });
- }
- });
- client.login('your token here');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement