diff --git a/index.js b/index.js index 488245c..5544514 100644 --- a/index.js +++ b/index.js @@ -1,40 +1,36 @@ -const mySecret = process.env['TOKEN'] // Require the necessary discord.js classes -const { Client, Intents } = require('discord.js'); +const { Client, GatewayIntentBits } = require('discord.js'); +const { token, tweetParser } = require('./config.json'); const http = require('http'); -require('discord-reply'); // IMPORTANT: put this before your discord.Client() // Create a new client instance -const client = new Client({ - intents: [ - Intents.FLAGS.GUILDS, - Intents.FLAGS.GUILD_MESSAGES - ] - }); +const client = new Client({ + intents: [ + GatewayIntentBits.Guilds, + GatewayIntentBits.GuildMessages, + GatewayIntentBits.MessageContent, + ], +}); http.createServer((req, res) => { - res.writeHead(200, { - 'Content-type': 'text/plain' - }); - res.write('Hey'); - res.end(); + res.writeHead(200, { 'Content-type': 'text/plain' }); + res.write('Hey'); + res.end(); }).listen(4000); // When the client is ready, run this code (only once) client.once('ready', () => { - console.log('Ready!'); - console.log() + console.log('Ready!'); }); // Response client.on('messageCreate', async message => { - if (message.content.startsWith("https://twitter.com/")) { - var tweetURL = message.content.substring(20, message.content.length); - message.delete(); + if (message.content.startsWith('https://twitter.com/')) { + const tweetURL = message.content.substring(20, message.content.length); + message.suppressEmbeds(true); - var newmsg = "https://fxtwitter.com/" + tweetURL; - message.channel.send(newmsg); - } + const newmsg = tweetParser + tweetURL; + message.reply({ content: newmsg, allowedMentions: { repliedUser: false } }); + } }); - // Login to Discord with your client's token -client.login(mySecret); \ No newline at end of file +client.login(token);