474 lines
19 KiB
JavaScript
474 lines
19 KiB
JavaScript
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}!`);
|
||
});
|
||
|
||
client.on(Discord.Events.MessageCreate, async (message) => {
|
||
if (message.content === "pur" && message.author.id === "277357956075356162" && message.channel.id === "1288545301543518268") {
|
||
const colors = new Discord.EmbedBuilder()
|
||
.setColor(0x0068f0)
|
||
.setTitle('GÖNN DIR NE ROLLE <:Akii_Love:1170797779443003515>')
|
||
.addFields(
|
||
{name: '✨ Wuthering Waves', value: ''},
|
||
{name: '💫 Hoyo-fans', value: ''},
|
||
{name: '😂 Fun Ecke', value: ''},
|
||
{name: '', value: ''},
|
||
{name: '❌ NSFW - Gibt es nur auf Nachfrage!', value: ''},
|
||
)
|
||
.setFooter({ text: 'Reagiere mit dem entsprechenden Emote <:cute_cat:1318049193646100540>\nNachdem du die Reaktion angeklickt hast,\nwird die Rolle deinem Profil hinzugefügt'});
|
||
|
||
//message.channel.send({ embeds: [rules] });
|
||
|
||
const channel1 = message.channel;
|
||
const messageId1 = '1366567818572599317';
|
||
|
||
try {
|
||
const msgToEdit = await channel1.messages.fetch(messageId1);
|
||
await msgToEdit.edit({ embeds: [colors] });
|
||
} catch (error) {
|
||
message.channel.send({ embeds: [rules] });
|
||
}
|
||
|
||
message.delete();
|
||
}
|
||
|
||
if (message.content === "purpur" && message.author.id === "277357956075356162" && message.channel.id === "1288545301543518268") {
|
||
const channel1 = message.channel;
|
||
const messageId1 = '1366567818572599317';
|
||
|
||
try {
|
||
const msgToEdit = await channel1.messages.fetch(messageId1);
|
||
await msgToEdit.react("✨");
|
||
await msgToEdit.react("💫");
|
||
await msgToEdit.react("😂");
|
||
} catch (error) {
|
||
|
||
}
|
||
|
||
message.delete();
|
||
}
|
||
})
|
||
|
||
// Willkommens Nachrichten (Random out of 10)
|
||
client.on(Discord.Events.GuildMemberAdd, (member) => {
|
||
const channel = member.guild.channels.cache.get("1288525935338983466");
|
||
const randomInt = Math.round(Math.round(Math.random() * 100) / 10);
|
||
|
||
switch (randomInt) {
|
||
case 1:
|
||
channel.send(`Ein herzliches Willkommen, ${member}! Deine Anwesenheit bringt Licht und Freude in den Bambuswald!`);
|
||
break;
|
||
|
||
case 2:
|
||
channel.send(`Willkommen, ${member}! Der Bambuswald öffnet seine Arme für dich und das Abenteuer beginnt!`);
|
||
break;
|
||
|
||
case 3:
|
||
channel.send(`Hallo ${member}! Ein neuer Sprössling im Bambuswald! Möge das Chaos mit dir sein!`);
|
||
break;
|
||
|
||
case 4:
|
||
channel.send(`Willkommen, ${member}, im bunten Chaos! Dein Eintritt in den Bambuswald wird sicher unvergesslich!`);
|
||
break;
|
||
|
||
case 5:
|
||
channel.send(`Willkommen im Wahnsinn, ${member}! Du bist auf dem weise gewählten Weg auf diesen Server!`);
|
||
break;
|
||
|
||
case 6:
|
||
channel.send(`Sei gegrüßt, ${member}, im Bambuswald! Hier gibt es gratis Kekse mit einem Hauch Chaos.`);
|
||
break;
|
||
|
||
case 7:
|
||
channel.send(`Willkommen, ${member}, im Herzen des Chaos! Deine Reise im Bambuswald beginnt jetzt – viel Spaß dabei!`);
|
||
break;
|
||
|
||
case 8:
|
||
channel.send(`Ein Klatsch, ein Schrei, ${member}! Komm ruhig herbei – und bleib gefälligst auch hier.`);
|
||
break;
|
||
|
||
case 9:
|
||
channel.send(`Sei willkommen, ${member}, und danke, dass du Teil unserer verrückten Gemeinschaft bist! Hier im Bambuswald ist immer etwas los!`);
|
||
break;
|
||
|
||
default:
|
||
channel.send(`Willkommen, ${member}, du mutiger Entdecker! Der Bambuswald freut sich, dich in seinen Reihen zu haben!`);
|
||
break;
|
||
}
|
||
})
|
||
|
||
// 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();*/ |