Initial commit
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,382 @@
|
||||
const config = require("./config.json");
|
||||
|
||||
|
||||
const Discord = require("discord.js");
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
const { ActivityType } = require('discord.js');
|
||||
const { ActionRowBuilder, ButtonBuilder, ButtonStyle, SlashCommandBuilder, Events, WebhookClient, Webhook } = require('discord.js');
|
||||
|
||||
const { ReactionRoleManager } = require('reaction-role');
|
||||
|
||||
const { Console, error } = require("node:console");
|
||||
const { request } = require("node:http");
|
||||
|
||||
const { Birthday } = require('./database');
|
||||
|
||||
const Instagram = require('instagram-web-api')
|
||||
const FileCookieStore = require('tough-cookie-filestore2')
|
||||
|
||||
|
||||
const username = config.igusername;
|
||||
const password = config.igpassword;
|
||||
|
||||
const cookieStore = new FileCookieStore('./cookies.json');
|
||||
|
||||
const igClient = new Instagram({ username, password, cookieStore });
|
||||
|
||||
let lastPostId = null;
|
||||
|
||||
|
||||
const client = new Discord.Client({
|
||||
intents: [
|
||||
Discord.GatewayIntentBits.Guilds,
|
||||
Discord.GatewayIntentBits.GuildMembers,
|
||||
Discord.GatewayIntentBits.GuildMessages,
|
||||
Discord.GatewayIntentBits.GuildMessageReactions,
|
||||
Discord.GatewayIntentBits.MessageContent,
|
||||
]
|
||||
});
|
||||
|
||||
client.once(Discord.Events.ClientReady, readyClient => {
|
||||
console.log(`Ready! Logged in as ${readyClient.user.tag}`);
|
||||
client.user.setPresence({
|
||||
activities: [{
|
||||
name: 'euch zu',
|
||||
type: ActivityType.Watching,
|
||||
//url: 'https://twitch.tv/AkiiThePanda'
|
||||
}],
|
||||
status: 'idle'
|
||||
});
|
||||
});
|
||||
|
||||
client.on('interactionCreate', async (interaction) => {
|
||||
if (!interaction.isCommand) return;
|
||||
|
||||
if (interaction.commandName === "request" && interaction.channelId == 1230998916074311680) {
|
||||
const fetch = require('node-fetch');
|
||||
|
||||
const category = interaction.options.getString("categorie");
|
||||
const film = interaction.options.getString('name');
|
||||
}
|
||||
});
|
||||
|
||||
client.on(Events.MessageCreate, async (message) => {
|
||||
if (message.channelId == 1288954051261632532 && message.content.toLowerCase() == "ping") {
|
||||
message.reply("Pong!");
|
||||
var currentCount = parseInt(message.channel.topic.replace(" Pings | Schreibt \"Ping\" & der Bot schreibt \"Pong\"", ""));
|
||||
currentCount++;
|
||||
message.channel.setTopic(currentCount + " Pings | Schreibt \"Ping\" & der Bot schreibt \"Pong\"");
|
||||
}
|
||||
if (message.channelId == 1288954051261632532 && message.content.toLowerCase() != "ping" && message.author.id != 241530175353782273 && message.author.bot == false) {
|
||||
message.delete();
|
||||
}
|
||||
if (message.channelId == 1288521679651213324 && message.content.includes("sendWebhook") && message.author.id == 277357956075356162) {
|
||||
const webhookURL = 'https://discord.com/api/webhooks/1291149416987889715/CzhpoF8RhVTqhtasRn0iCWUnLO3Y7IBJ_k3jfLQTnz-WCWobz5_R90QnKxwMwwrwFxDa'; // Replace with your webhook URL
|
||||
|
||||
const result = message.content.match(/"([^"]*)"/);
|
||||
|
||||
const content = result ? result[1] : null;
|
||||
|
||||
|
||||
/*const messagecontent = {
|
||||
content: 'Hi',
|
||||
username: content, // Optional: Set a custom username
|
||||
avatar_url: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSH9ampb82S-0VZphf-9nDx3S1oVPhpeS6HYQ&s' // Optional: Set a custom avatar
|
||||
};
|
||||
|
||||
axios.post(webhookURL, messagecontent)
|
||||
.then(response => {
|
||||
console.log('Message sent successfully:', response.data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error sending message:', error);
|
||||
});*/
|
||||
|
||||
//const webhookClient = new WebhookClient({ id: '1291149416987889715', token: 'CzhpoF8RhVTqhtasRn0iCWUnLO3Y7IBJ_k3jfLQTnz-WCWobz5_R90QnKxwMwwrwFxDa' });
|
||||
|
||||
/*webhookClient.edit({
|
||||
name: 'Some-username',
|
||||
avatar: 'https://i.imgur.com/AfFp7pu.png',
|
||||
channel: '1288954051261632532',
|
||||
});*/
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle('Some Title')
|
||||
.setColor(0x00FFFF);
|
||||
|
||||
const channel = message.channel;
|
||||
|
||||
try {
|
||||
const webhooks = await channel.fetchWebhooks();
|
||||
const webhook = webhooks.find(wh => wh.token);
|
||||
|
||||
if (!webhook) {
|
||||
return console.log('No webhook was found that I can use!');
|
||||
}
|
||||
|
||||
const commandChannel = content.replace("<#", "").replace(">", "")
|
||||
|
||||
const newmsg = message.content.replace("\"" + content + "\"", "");
|
||||
|
||||
const result2 = newmsg.match(/"([^"]*)"/);
|
||||
|
||||
const content2 = result2 ? result2[1] : null;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const newmsg2 = newmsg.replace("\"" + content2 + "\"", "");
|
||||
|
||||
const result3 = newmsg2.match(/"([^"]*)"/);
|
||||
|
||||
const content3 = result3 ? result3[1] : null;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const newmsg3 = newmsg.replace("\"" + content3 + "\"", "");
|
||||
|
||||
const result4 = newmsg3.match(/"([^"]*)"/);
|
||||
|
||||
const content4 = result4 ? result4[1] : null;
|
||||
|
||||
|
||||
|
||||
|
||||
await webhook.edit({channel: commandChannel});
|
||||
|
||||
console.log(content + "\n" + content2 + "\n" + content3 + "\n" + content4);
|
||||
|
||||
await webhook.send({
|
||||
content: content3,
|
||||
username: content2,
|
||||
avatarURL: content4,
|
||||
//embeds: [embed],
|
||||
});
|
||||
|
||||
await webhook.edit({channel: message.channelId});
|
||||
} catch (error) {
|
||||
console.error('Error trying to send a message: ', error);
|
||||
}
|
||||
}
|
||||
/*if (message.channelId == 1288527949129318443 && message.author.bot == false) {
|
||||
const exampleEmbed = new EmbedBuilder()
|
||||
.setColor(0x42DAF5)
|
||||
.setTitle('🎍Auch dieser Discord besitzt Regeln🎍')
|
||||
.addFields(
|
||||
{name: '💠 Dein Alter', value: 'Du bist mind. 13 Jahre alt.'},
|
||||
{name: '💠 Sei Kein Arsch', value: 'Sei Respektvoll & beleidige niemanden.'},
|
||||
{name: '💠 Mobbing', value: 'Mobbing jeglicher Art ist zu vermeiden, ansonsten wird der Bannhammer geschwungen.'},
|
||||
{name: '💠 Trauma Dumping', value: 'Kein Trauma Dumping, \"No Bad Vibes\" , Keine Trigger, keine Politischen und Religiösen Themen o.ä. dies ist ein Discord zum Abschalten, hier soll sich **JEDER** Wohl fühlen. Fürs Auskotzen gibt es einen Extra Channel, damit Menschen welche leicht davon Runtergezogen werden diesen Channel meiden können (<#1332358968395436075>).'},
|
||||
{name: '💠 Rassismus und ähnliches', value: 'Sehe ich hier Rassismus, Sexismus, LGBTQIA+ Feindlichkeit oder AFD Fangelaber fliegt du schneller als du gucken kannst.'},
|
||||
{name: '💠 Drogen', value: 'Verherrlichung von Drogen jeglicher Art [auch Alkohol und Nikotin.] ist untersagt. '},
|
||||
{name: '💠 Spam und Werbung', value: 'Keinen Spam, keine Fremd- oder Eigenwerbung. HÖCHSTENS auf Anfrage, direkt bei <@241530175353782273>'},
|
||||
{name: '💠 Eigene Bots Verboten', value: 'Keine eigenen Bots nutzen.'},
|
||||
{name: '💠 Gehorche oder fliege', value: 'Anweisungen der Mods und <@241530175353782273> sind Folge zu leisten!'},
|
||||
{name: '💠 NSFW', value: 'NSFW Rollen nur auf Anfrage! Obszöne Sachen nur im NSFW Channel & NICHT von Realen Menschen. '},
|
||||
{name: '💠 An die Anime Fans unter uns', value: 'Ich will hier nichts lesen von Wegen "One Piece ist besser als xyz." oder "Naruto ist Schmutz" etc. **JEDER** Mensch hat einen anderen Geschmack, **AKZEPTIERT DAS.**'},
|
||||
{name: '💠 Ableistische Sprache', value: 'Wörter wie "Behindert" "spaßt" "Schwul" etc. sind KEINE Beleidigung. Nutzt diese also bitte nicht als Beleidigung. Danke.'},
|
||||
{name: ' ', value: '\u200B'},
|
||||
{name: '💠 Discord Nutzungsbedingungen und Richtlinien', value: 'Haltet euch an die DC Nutzungsbedingungen und Richtlinien! › https://discord.com/terms '},
|
||||
{name: '💠 Einladungen und Link-Carrd', value: 'Falls ihr jemanden auf diesen DC einladen wollt, findet ihr hier alle Links zu meinen Socials. \nDort ist auch der DC Link drin. › https://akiithepanda.carrd.co/'},
|
||||
{name: ' ', value: '\u200B'},
|
||||
{name: '💠 Deine PREMIUM Panda Transformation', value: '[🐼] Klicke auf den Panda, um deine Transformation in einen PREMIUM Panda abzuschließen und einer von uns zu werden! \nDanach siehst du alle öffentlichen Channel. \Als nächstens Schritt empfehle ich dir, in die <#1288545301543518268> vorbei zu schauen. '},
|
||||
{name: ' ', value: '\u200B'},
|
||||
{name: '💠 Viel spaß in diesem Bambuswald!', value: ' '},
|
||||
)
|
||||
.setFooter({ text: 'einer von uns.. einer von uns.. einer von uns...'});
|
||||
message.channel.send({ embeds: [exampleEmbed] });
|
||||
}*/
|
||||
});
|
||||
|
||||
client.on(Events.MessageReactionAdd, async (reaction, user, channel) => {
|
||||
if(reaction.message.partial) await reaction.message.fetch();
|
||||
if(reaction.partial) await reaction.fetch();
|
||||
|
||||
if(user.bot) return;
|
||||
if(!reaction.message.guild) return;
|
||||
|
||||
console.log("emoji" + reaction.emoji.identifier);
|
||||
if(reaction.message.channel.id === '1288527949129318443' && reaction.message.id === '1332383887598419968') {
|
||||
|
||||
if(reaction.emoji.id === '8789972642138767364') {
|
||||
reaction.message.guild.members.cache.get(user.id).roles.add('8779841244749004804')
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
client.on('interactionCreate', async (interaction) => {
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
|
||||
if (interaction.commandName === "siskelshandlanger" || interaction.commandName === "trafalgar") {
|
||||
var botname, avatarurl;
|
||||
if (interaction.commandName === "siskelshandlanger") {
|
||||
botname = "Siskels Handlanger";
|
||||
avatarurl = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRU6AVzanr9v-xzYmzLgbEWOM27ycXkHCACkA&s";
|
||||
} else if (interaction.commandName === "trafalgar") {
|
||||
botname = "Trafalgar Law";
|
||||
avatarurl = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSH9ampb82S-0VZphf-9nDx3S1oVPhpeS6HYQ&s";
|
||||
}
|
||||
|
||||
const channel = interaction.options.get("channel").value;
|
||||
const message = interaction.options.get("message").value;
|
||||
|
||||
const channelGotten = await interaction.guild.channels.cache.get('1288521679651213324');
|
||||
|
||||
const webhooks = await channelGotten.fetchWebhooks();
|
||||
const webhook = await webhooks.find(wh => wh.token);
|
||||
|
||||
if (!webhook) {
|
||||
return console.log('No webhook was found that I can use!');
|
||||
}
|
||||
|
||||
await webhook.edit({channel: channel});
|
||||
|
||||
await webhook.send({
|
||||
content: message,
|
||||
username: botname,
|
||||
avatarURL: avatarurl,
|
||||
});
|
||||
|
||||
await webhook.edit({channel: '1288521679651213324'});
|
||||
|
||||
interaction.reply({content: "Message Send", ephemeral: true});
|
||||
setTimeout(function() {
|
||||
interaction.deleteReply();
|
||||
}, 10000);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
client.once('ready', () => {
|
||||
console.log(`Logged in as ${client.user.tag}!`);
|
||||
});
|
||||
|
||||
// Command prefix
|
||||
const prefix = '!';
|
||||
|
||||
// Listen for messages
|
||||
client.on('messageCreate', async (message) => {
|
||||
if (!message.content.startsWith(prefix) || message.author.bot) return;
|
||||
|
||||
const args = message.content.slice(prefix.length).trim().split(/ +/);
|
||||
const command = args.shift().toLowerCase();
|
||||
|
||||
// Add a birthday
|
||||
if (command === 'addbirthday') {
|
||||
const [month, day] = args; // Expected format: MM DD
|
||||
if (!month || !day || isNaN(month) || isNaN(day) || month < 1 || month > 12 || day < 1 || day > 31) {
|
||||
return message.reply('Please provide a valid date in MM DD format (e.g., 02 04 for February 4th).');
|
||||
}
|
||||
|
||||
const formattedDate = `${month.padStart(2, '0')}-${day.padStart(2, '0')}`; // Format as MM-DD
|
||||
|
||||
try {
|
||||
await Birthday.upsert({ userId: message.author.id, date: formattedDate });
|
||||
message.reply('Your birthday has been added!');
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
message.reply('There was an error saving your birthday.');
|
||||
}
|
||||
}
|
||||
|
||||
// View birthdays
|
||||
else if (command === 'viewbirthdays') {
|
||||
try {
|
||||
const birthdays = await Birthday.findAll();
|
||||
if (birthdays.length === 0) {
|
||||
return message.reply('No birthdays found!');
|
||||
}
|
||||
|
||||
const birthdayList = birthdays.map((b) => `<@${b.userId}>: ${b.date}`).join('\n');
|
||||
message.reply(`Here are the saved birthdays:\n${birthdayList}`);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
message.reply('There was an error retrieving the birthdays.');
|
||||
}
|
||||
}
|
||||
|
||||
// Notify about today's birthdays
|
||||
else if (command === 'todaybirthdays') {
|
||||
const today = new Date();
|
||||
const formattedToday = `${String(today.getMonth() + 1).padStart(2, '0')}-${String(today.getDate()).padStart(2, '0')}`; // Format as MM-DD
|
||||
|
||||
try {
|
||||
const birthdays = await Birthday.findAll({ where: { date: formattedToday } });
|
||||
if (birthdays.length === 0) {
|
||||
return message.reply('No birthdays today!');
|
||||
}
|
||||
|
||||
const birthdayList = birthdays.map((b) => `<@${b.userId}>`).join(', ');
|
||||
message.reply(`🎉 Today's birthdays: ${birthdayList}! 🎂`);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
message.reply('There was an error retrieving today\'s birthdays.');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const schedule = require('node-schedule');
|
||||
|
||||
// Schedule a job to check for birthdays at midnight UTC every day
|
||||
schedule.scheduleJob('9 0 * * *', async () => {
|
||||
const today = new Date();
|
||||
const formattedToday = `${String(today.getMonth() + 1).padStart(2, '0')}-${String(today.getDate()).padStart(2, '0')}`; // Format as MM-DD
|
||||
|
||||
try {
|
||||
const birthdays = await Birthday.findAll({ where: { date: formattedToday } });
|
||||
if (birthdays.length > 0) {
|
||||
const channel = client.channels.cache.get('1288521679651213324'); // Replace with your channel ID
|
||||
const birthdayList = birthdays.map((b) => `<@${b.userId}>`).join(', ');
|
||||
channel.send(`🎉 Today's birthdays: ${birthdayList}! 🎂`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error checking birthdays:', error);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
client.login(config.token);
|
||||
|
||||
async function everyMinute() {
|
||||
while (true) {
|
||||
await sleep(10000);
|
||||
}
|
||||
}
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
/*
|
||||
async function checkInstagramPosts() {
|
||||
try {
|
||||
await igClient.login();
|
||||
while (true) {
|
||||
const posts = await igClient.getPhotosByUsername({ username: "AkiiThePanda" });
|
||||
|
||||
if (posts && posts.user && posts.user.edge_owner_to_timeline_media && posts.user.edge_owner_to_timeline_media.edges.length > 0) {
|
||||
const latestPost = posts.user.edge_owner_to_timeline_media.edges[0].node;
|
||||
if (lastPostId !== latestPost.id) {
|
||||
lastPostId = latestPost.id;
|
||||
const postUrl = `https://www.instagram.com/p/${latestPost.shortcode}/`;
|
||||
const messageContent = `New post from ${config.igusername}: ${postUrl}`;
|
||||
|
||||
const channel = client.channels.cache.get(config.discordChannelId);
|
||||
if (channel) {
|
||||
channel.send(messageContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
await sleep(30000); // Check every minute
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error fetching Instagram posts: ', error);
|
||||
}
|
||||
}
|
||||
|
||||
checkInstagramPosts();*/
|
||||
@@ -0,0 +1,3 @@
|
||||
class customMessageHandler {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"token": "MTI4ODU1NDEwMzg3MzczNjc4NQ.GyFiFO.iFteN1oTfNUJpJOzjSEKuuDBjyaHxgYBFO6WqY",
|
||||
"handlename": "siskeldevbot",
|
||||
"igusername": "siskeldevbot",
|
||||
"igpassword": "LuckyAimie1",
|
||||
"discordChannelId": "1288521679651213324"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"www.instagram.com":{"/":{"ig_cb":{"key":"ig_cb","value":"1","domain":"www.instagram.com","path":"/","hostOnly":true,"pathIsDefault":true,"creation":"2025-01-27T14:25:34.117Z","lastAccessed":"2025-03-12T07:36:02.430Z"}}}}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
const { Sequelize, DataTypes } = require('sequelize');
|
||||
|
||||
// Initialize SQLite database
|
||||
const sequelize = new Sequelize({
|
||||
dialect: 'sqlite',
|
||||
storage: './birthdays.sqlite',
|
||||
});
|
||||
|
||||
// Define the Birthday model
|
||||
const Birthday = sequelize.define('Birthday', {
|
||||
userId: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
unique: true,
|
||||
},
|
||||
date: {
|
||||
type: DataTypes.STRING, // Store as MM-DD
|
||||
allowNull: false,
|
||||
},
|
||||
});
|
||||
|
||||
// Sync the database
|
||||
(async () => {
|
||||
await sequelize.sync({ alter: true });
|
||||
console.log('Database synced!');
|
||||
})();
|
||||
|
||||
module.exports = { sequelize, Birthday };
|
||||
Generated
+3144
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"axios": "^1.7.7",
|
||||
"cheerio": "^1.0.0",
|
||||
"discord.js": "^14.17.3",
|
||||
"dotenv": "^16.4.7",
|
||||
"instagram-private-api": "^1.46.1",
|
||||
"instagram-web-api": "^2.2.2",
|
||||
"node-fetch": "^2.7.0",
|
||||
"node-schedule": "^2.1.1",
|
||||
"reaction-role": "^5.0.1",
|
||||
"sequelize": "^6.37.5",
|
||||
"sqlite3": "^5.1.7",
|
||||
"tmi.js": "^1.8.5",
|
||||
"tough-cookie-filestore2": "^1.0.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
const config = require("./config.json");
|
||||
const {REST, Routes, ApplicationCommandOptionType } = require("discord.js");
|
||||
|
||||
var guildid = "1288521679206748260";
|
||||
var clientId = "1288554103873736785";
|
||||
|
||||
const rest = new REST({version: '10'}).setToken(config.token);
|
||||
|
||||
|
||||
const commands = [
|
||||
{
|
||||
name: 'trafalgar',
|
||||
description: 'Sende eine Nachricht als "Trafalgar Law"',
|
||||
options: [
|
||||
{
|
||||
name: 'channel',
|
||||
description: 'Der Channel in den die Nachricht geschickt werden soll',
|
||||
type: ApplicationCommandOptionType.Channel,
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
name: 'message',
|
||||
description: 'Die Nachricht die der Bot schreiben soll',
|
||||
type: ApplicationCommandOptionType.String,
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'siskelshandlanger',
|
||||
description: 'Sende eine Nachricht als "Siskels Handlanger"',
|
||||
options: [
|
||||
{
|
||||
name: 'channel',
|
||||
description: 'Der Channel in den die Nachricht geschickt werden soll',
|
||||
type: ApplicationCommandOptionType.Channel,
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
name: 'message',
|
||||
description: 'Die Nachricht die der Bot schreiben soll',
|
||||
type: ApplicationCommandOptionType.String,
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
(async () => {
|
||||
temp = await rest.get("/applications/" + clientId + "/commands");
|
||||
|
||||
await temp.forEach((item) => {
|
||||
rest.delete(Routes.applicationCommand(clientId, item.id))
|
||||
.then(() => console.log('Successfully deleted guild command: ' + item.name))
|
||||
.catch(console.error);
|
||||
});
|
||||
|
||||
await sleep(1000);
|
||||
|
||||
console.log("\nSuccessfully Deleted all Command -> Now Adding new and Readding all Commands\n");
|
||||
|
||||
await sleep(1000);
|
||||
|
||||
try {
|
||||
let listOfAllCommands = "";
|
||||
|
||||
commands.forEach((item) => {
|
||||
if (listOfAllCommands != "") {
|
||||
listOfAllCommands += ", ";
|
||||
}
|
||||
listOfAllCommands += "/" + item.name;
|
||||
});
|
||||
|
||||
if (listOfAllCommands == "") {
|
||||
listOfAllCommands = "Empty List";
|
||||
}
|
||||
|
||||
console.log("Registering Commands: " + listOfAllCommands);
|
||||
|
||||
await rest.put(
|
||||
Routes.applicationCommands(clientId),
|
||||
{
|
||||
body: commands
|
||||
}
|
||||
);
|
||||
|
||||
console.log("Registered");
|
||||
} catch (error) {
|
||||
console.log(`error: ${error}`);
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,39 @@
|
||||
const axios = require('axios');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
const getLatestPost = async (username) => {
|
||||
try {
|
||||
// Fetch the Instagram page
|
||||
const response = await axios.get(`https://www.instagram.com/${username}/`);
|
||||
const html = response.data;
|
||||
|
||||
// Load the HTML into cheerio
|
||||
const $ = cheerio.load(html);
|
||||
|
||||
|
||||
// Extract the script tag containing the JSON data
|
||||
const scriptTag = $('script[type="text/javascript"]').get().find(script => script.children[0].data.includes('window._sharedData'));
|
||||
console.log(scriptTag);
|
||||
const jsonData = scriptTag.children[0].data.split(' = ')[1].slice(0, -1);
|
||||
const data = JSON.parse(jsonData);
|
||||
|
||||
// Get the latest post
|
||||
const latestPost = data.entry_data.ProfilePage[0].graphql.user.edge_owner_to_timeline_media.edges[0].node;
|
||||
|
||||
// Extract relevant information
|
||||
const postDetails = {
|
||||
id: latestPost.id,
|
||||
shortcode: latestPost.shortcode,
|
||||
imageUrl: latestPost.display_url,
|
||||
caption: latestPost.edge_media_to_caption.edges[0]?.node.text || 'No caption',
|
||||
timestamp: latestPost.taken_at_timestamp,
|
||||
};
|
||||
|
||||
console.log(postDetails);
|
||||
} catch (error) {
|
||||
console.error('Error fetching the latest post:', error);
|
||||
}
|
||||
};
|
||||
|
||||
// Replace 'instagram' with the desired username
|
||||
getLatestPost('instagram');
|
||||
Reference in New Issue
Block a user