const Discord = require('discord.js'); const client = new Discord.Client(); const prefix = '#'; var author = " "; var storedLink = " "; var link = new Discord.MessageAttachment(); var messageId; var yes = false; client.once('ready', () => { console.log('Im online!'); }); client.on('message', message => { const args = message.content.split(' '); //storedMessages.push(message.content); let msg = message.content.toLowerCase(); if(message.attachments.first() === undefined){ } if (message.content.startsWith("http")){ author = message.author.username; storedLink = message.content; messageId = message.id; yes = true; } else if(message.attachments.first() != undefined){ let storedMessage = message.attachments.first(); link = new Discord.MessageAttachment(storedMessage.url); messageId = message.id; yes = true; } if(msg.startsWith("henlo") && message.author.bot == false){ var emojis = ["🥰", "🐄", "🐮", "❤️", "👋", "🤠", "😊"]; let randomNum = Math.floor(Math.random() * 7); message.channel.send("Henlooo " + message.author.username + " " + emojis[randomNum]); } else if (message.mentions.channels.first() && yes){ if (args.length === 1){ message.react('🐮'); let channelId = ""; let channelIdArray = message.content.split(''); channelIdArray.splice(0, 2); channelIdArray.pop(); for (i = 0; i < channelIdArray.length; i++){ channelId += channelIdArray[i]; } message.delete({timeout: 5000}); var toDelete = message.channel.messages.cache.get(messageId); toDelete.delete(); let getChannel = client.channels.cache.get(channelId); getChannel.send(author + "\n" + storedLink); } yes = false; } else if (msg.startsWith("how ye") && message.author.bot === false){ let randomNum = Math.floor(Math.random() * 5); var responses = ["Not bad, how yee?", "MOOdie", "A bit sad 😢", "Good, how yee?", "I'm fine, how yee?"]; message.channel.send(responses[randomNum]); } else if (msg.startsWith("tylko jedno")){ message.channel.send("Koksu pięć gram odlecieć sam"); } }); client.login(process.env.token);