From c7e9f1ba5b505834ff2e660e5ffa2209f0b44652 Mon Sep 17 00:00:00 2001 From: Levi Date: Mon, 26 Sep 2022 17:33:10 +0200 Subject: [PATCH] TikTok support --- config.json | 5 +++-- index.js | 31 ++++++++++++++++++++++++++++--- package-lock.json | 2 +- package.json | 2 +- 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/config.json b/config.json index 1d4a2c6..2e9c325 100644 --- a/config.json +++ b/config.json @@ -2,5 +2,6 @@ "token": "your-token-goes-here", "port": "4000", "tweetParser": "https://fxtwitter.com/", - "instaParser": "https://ddinstagram.com/" -} + "instaParser": "https://ddinstagram.com/", + "tiktokParser": "https://www.vxtiktok.com/" +} \ No newline at end of file diff --git a/index.js b/index.js index 059bc9a..06540e9 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,11 @@ -// Require the necessary discord.js classes const { Client, GatewayIntentBits } = require('discord.js'); -const { token, port, tweetParser, instaParser } = require('./config.json'); +const { + token, + port, + tweetParser, + instaParser, + tiktokParser, +} = require('./config.json'); const http = require('http'); // Create a new client instance const client = new Client({ @@ -63,5 +68,25 @@ client.on('messageCreate', async message => { } }); +client.on('messageCreate', async message => { + if (message.content.startsWith('https://tiktok.com/')) { + const tiktokURL = message.content.substring(19, message.content.length); + message.suppressEmbeds(true); + + const newmsg = tiktokParser + tiktokURL; + message.reply({ content: newmsg, allowedMentions: { repliedUser: false } }); + } +}); + +client.on('messageCreate', async message => { + if (message.content.startsWith('https://www.tiktok.com/')) { + const tiktokURL2 = message.content.substring(23, message.content.length); + message.suppressEmbeds(true); + + const newmsg = tiktokParser + tiktokURL2; + message.reply({ content: newmsg, allowedMentions: { repliedUser: false } }); + } +}); + // Login to Discord with your client's token -client.login(token); +client.login(token); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 5c2929d..7f43e5a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "mediafixer", - "version": "1.2.4", + "version": "1.2.5", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index edec194..8268881 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mediafixer", - "version": "1.2.4", + "version": "1.2.5", "description": "Fixes broken twitter embeds by replying with a reformatted link.", "main": "index.js", "scripts": {