TikTok support

This commit is contained in:
Levi 2022-09-26 18:03:47 +02:00
parent bb33055946
commit 53c7cf71fc
5 changed files with 2784 additions and 2800 deletions

View file

@ -10,13 +10,13 @@
"rules": {
"arrow-spacing": ["warn", { "before": true, "after": true }],
"brace-style": ["error", "stroustrup", { "allowSingleLine": true }],
"comma-dangle": ["error", "always-multiline"],
"comma-dangle": ["error", "only-multiline"],
"comma-spacing": "error",
"comma-style": "error",
"curly": ["error", "multi-line", "consistent"],
"dot-location": ["error", "property"],
"handle-callback-err": "off",
"indent": ["error", "tab"],
"indent": ["error", 4],
"keyword-spacing": "error",
"max-nested-callbacks": ["error", { "max": 4 }],
"max-statements-per-line": ["error", { "max": 2 }],

View file

@ -1,7 +1,7 @@
{
"token": "your-token-goes-here",
"port": "4000",
"tweetParser": "https://fxtwitter.com/",
"instaParser": "https://ddinstagram.com/",
"tiktokParser": "https://www.vxtiktok.com/"
"token": "your-token-goes-here",
"port": "4000",
"tweetParser": "https://fxtwitter.com/",
"instaParser": "https://ddinstagram.com/",
"tiktokParser": "https://www.vxtiktok.com/"
}

168
index.js
View file

@ -1,112 +1,112 @@
const {
Client,
GatewayIntentBits
Client,
GatewayIntentBits
} = require('discord.js');
const {
token,
port,
tweetParser,
instaParser,
tiktokParser,
token,
port,
tweetParser,
instaParser,
tiktokParser
} = require('./config.json');
const http = require('http');
// Create a new client instance
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],
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(port);
// When the client is ready, run this code (only once)
client.once('ready', () => {
console.log('Ready!');
console.log('Ready!');
});
// Response
client.on('messageCreate', async message => {
if(message.content.startsWith('https://twitter.com/')) {
const tweetURL = message.content.substring(20, message.content.length);
message.suppressEmbeds(true);
const newmsg = tweetParser + tweetURL;
message.reply({
content: newmsg,
allowedMentions: {
repliedUser: false
}
});
}
if (message.content.startsWith('https://twitter.com/')) {
const tweetURL = message.content.substring(20, message.content.length);
message.suppressEmbeds(true);
const newmsg = tweetParser + tweetURL;
message.reply({
content: newmsg,
allowedMentions: {
repliedUser: false
}
});
}
});
client.on('messageCreate', async message => {
if(message.content.startsWith('https://mobile.twitter.com/')) {
const mobiletweetURL = message.content.substring(27, message.content.length);
message.suppressEmbeds(true);
const newmsg = tweetParser + mobiletweetURL;
message.reply({
content: newmsg,
allowedMentions: {
repliedUser: false
}
});
}
if (message.content.startsWith('https://mobile.twitter.com/')) {
const mobiletweetURL = message.content.substring(27, message.content.length);
message.suppressEmbeds(true);
const newmsg = tweetParser + mobiletweetURL;
message.reply({
content: newmsg,
allowedMentions: {
repliedUser: false
}
});
}
});
client.on('messageCreate', async message => {
if(message.content.startsWith('https://instagram.com/')) {
const instaURL = message.content.substring(22, message.content.length);
message.suppressEmbeds(true);
const newmsg = instaParser + instaURL;
message.reply({
content: newmsg,
allowedMentions: {
repliedUser: false
}
});
}
if (message.content.startsWith('https://instagram.com/')) {
const instaURL = message.content.substring(22, message.content.length);
message.suppressEmbeds(true);
const newmsg = instaParser + instaURL;
message.reply({
content: newmsg,
allowedMentions: {
repliedUser: false
}
});
}
});
client.on('messageCreate', async message => {
if(message.content.startsWith('https://www.instagram.com/')) {
const instaURL2 = message.content.substring(26, message.content.length);
message.suppressEmbeds(true);
const newmsg = instaParser + instaURL2;
message.reply({
content: newmsg,
allowedMentions: {
repliedUser: false
}
});
}
if (message.content.startsWith('https://www.instagram.com/')) {
const instaURL2 = message.content.substring(26, message.content.length);
message.suppressEmbeds(true);
const newmsg = instaParser + instaURL2;
message.reply({
content: newmsg,
allowedMentions: {
repliedUser: false
}
});
}
});
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
}
});
}
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
}
});
}
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);

5354
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,26 +1,26 @@
{
"name": "mediafixer",
"version": "1.2.5",
"description": "Fixes broken twitter embeds by replying with a reformatted link.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/LeviSnoot/MediaFixer.git"
},
"keywords": ["discord", "twitter", "embeds"],
"author": "Yber0 & LeviSnoot",
"license": "ISC",
"dependencies": {
"discord.js": "^14.4.0"
},
"bugs": {
"url": "https://github.com/LeviSnoot/MediaFixer/issues"
},
"homepage": "https://github.com/LeviSnoot/MediaFixer#readme",
"devDependencies": {
"eslint": "^8.23.1"
}
"name": "mediafixer",
"version": "1.2.5",
"description": "Fixes broken twitter embeds by replying with a reformatted link.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/LeviSnoot/MediaFixer.git"
},
"keywords": ["discord", "twitter", "embeds"],
"author": "Yber0 & LeviSnoot",
"license": "ISC",
"dependencies": {
"discord.js": "^14.4.0"
},
"bugs": {
"url": "https://github.com/LeviSnoot/MediaFixer/issues"
},
"homepage": "https://github.com/LeviSnoot/MediaFixer#readme",
"devDependencies": {
"eslint": "^8.23.1"
}
}