added MemberJoin

This commit is contained in:
DeSqBlocki
2024-08-06 11:54:27 +02:00
parent 9dac81db9b
commit d7c3bdb5f7
12 changed files with 794 additions and 1208 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 536 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

+81 -81
View File
@@ -1,82 +1,82 @@
const { EmbedBuilder, UserSelectMenuBuilder, ActionRowBuilder } = require("discord.js")
const { mClient } = require("../..")
require('dotenv').config()
module.exports = {
name: 'quotes_list_left',
description: 'navigate left',
async execute(interaction) {
let oldEmbed = interaction.message.embeds[0].data
if (!oldEmbed.footer) { return interaction.reply({ content: 'Please use a Filter', ephemeral: true }) }
if (oldEmbed.fields && oldEmbed.fields[0].value == 0) { return interaction.reply({ content: 'This User has no Quotes', ephemeral: true }) }
let userID = interaction.message.embeds[0].data.footer.text.split(' ')[5].slice(2, -1)
const target = await interaction.guild.members.fetch(userID)
if (!target) { return interaction.reply({ content: 'Please use a Filter', ephemeral: true }) }
const db = mClient.db(process.env.M_DB)
const quotesColl = db.collection('quotes')
const quotes = await quotesColl.find({ by: target.id }).toArray()
var index = Number((await interaction.message.embeds[0].data.title).split(' ')[2].slice(1))
if (!index) { index = 0 }
index = index - 2
if (index < 1) { index = 0 }
const found = quotes[index]
const guild = await interaction.client.guilds.fetch(found.guildID)
const channel = await guild.channels.fetch(found.channelID)
const message = await channel.messages.fetch(found.messageID)
var msgData = {
content: message.content,
author: await message.author,
reference: await message.reference,
embed: await message.embeds ? 'embed' : null
} // debug
if (msgData.reference) {
let refMessage = await channel.messages.fetch(msgData.reference.messageId)
var refData = {
content: refMessage.content,
author: await refMessage.author,
embed: await refMessage.embeds.length > 0 ? 'embed' : null
}
}
var description = ''
if (refData) {
description += `> ${refData.author}`
if (refData.embed) {
description += '*an embed / a command* '
} else {
description += refData.content
}
description += `\r\n`
}
let messageLink = `https://discord.com/channels/${found.guildID}/${found.channelID}/${found.messageID}`
description += `${msgData.author} ${msgData.content}\r\n\r\n${messageLink}`
let timestamp = new Date(message.createdTimestamp)
let footer = timestamp.toDateString().toString()
const embed = new EmbedBuilder()
.setThumbnail(msgData.author.displayAvatarURL())
.setURL(messageLink)
.setTitle(`- Quote #${index + 1} -`)
.setDescription(description)
.setFooter({ text: (`${footer} #${found.messageID} <@${found.by}>`) })
const select = new ActionRowBuilder()
.addComponents(
new UserSelectMenuBuilder()
.setCustomId('quotes_list_mentionable')
.setPlaceholder('Filter By User')
)
const row = interaction.message.components[1]
await interaction.update({
embeds: [embed],
components: [select, row]
})
}
const { EmbedBuilder, UserSelectMenuBuilder, ActionRowBuilder } = require("discord.js")
const { mClient } = require("../..")
require('dotenv').config()
module.exports = {
name: 'quotes_list_left',
description: 'navigate left',
async execute(interaction) {
let oldEmbed = interaction.message.embeds[0].data
if (!oldEmbed.footer) { return interaction.reply({ content: 'Please use a Filter', ephemeral: true }) }
if (oldEmbed.fields && oldEmbed.fields[0].value == 0) { return interaction.reply({ content: 'This User has no Quotes', ephemeral: true }) }
let userID = interaction.message.embeds[0].data.footer.text.split(' ')[5].slice(2, -1)
const target = await interaction.guild.members.fetch(userID)
if (!target) { return interaction.reply({ content: 'Please use a Filter', ephemeral: true }) }
const db = mClient.db(process.env.M_DB)
const quotesColl = db.collection('quotes')
const quotes = await quotesColl.find({ by: target.id }).toArray()
var index = Number((await interaction.message.embeds[0].data.title).split(' ')[2].slice(1))
if (!index) { index = 0 }
index = index - 2
if (index < 1) { index = 0 }
const found = quotes[index]
const guild = await interaction.client.guilds.fetch(found.guildID)
const channel = await guild.channels.fetch(found.channelID)
const message = await channel.messages.fetch(found.messageID)
var msgData = {
content: message.content,
author: await message.author,
reference: await message.reference,
embed: await message.embeds ? 'embed' : null
} // debug
if (msgData.reference) {
let refMessage = await channel.messages.fetch(msgData.reference.messageId)
var refData = {
content: refMessage.content,
author: await refMessage.author,
embed: await refMessage.embeds.length > 0 ? 'embed' : null
}
}
var description = ''
if (refData) {
description += `> ${refData.author}`
if (refData.embed) {
description += '*an embed / a command* '
} else {
description += refData.content
}
description += `\r\n`
}
let messageLink = `https://discord.com/channels/${found.guildID}/${found.channelID}/${found.messageID}`
description += `${msgData.author} ${msgData.content}\r\n\r\n${messageLink}`
let timestamp = new Date(message.createdTimestamp)
let footer = timestamp.toDateString().toString()
const embed = new EmbedBuilder()
.setThumbnail(msgData.author.displayAvatarURL())
.setURL(messageLink)
.setTitle(`- Quote #${index + 1} -`)
.setDescription(description)
.setFooter({ text: (`${footer} #${found.messageID} <@${found.by}>`) })
const select = new ActionRowBuilder()
.addComponents(
new UserSelectMenuBuilder()
.setCustomId('quotes_list_mentionable')
.setPlaceholder('Filter By User')
)
const row = interaction.message.components[1]
await interaction.update({
embeds: [embed],
components: [select, row]
})
}
}
+81 -81
View File
@@ -1,82 +1,82 @@
const { EmbedBuilder, UserSelectMenuBuilder, ActionRowBuilder } = require("discord.js")
const { mClient } = require("../..")
require('dotenv').config()
module.exports = {
name: 'quotes_list_right',
description: 'navigate right',
async execute(interaction) {
let oldEmbed = interaction.message.embeds[0].data
if (!oldEmbed.footer) { return interaction.reply({ content: 'Please use a Filter', ephemeral: true }) }
if (oldEmbed.fields && oldEmbed.fields[0].value == 0) { return interaction.reply({ content: 'This User has no Quotes', ephemeral: true }) }
let userID = interaction.message.embeds[0].data.footer.text.split(' ')[5].slice(2, -1)
const target = await interaction.guild.members.fetch(userID)
if (!target) { return interaction.reply({ content: 'Please use a Filter', ephemeral: true }) }
const db = mClient.db(process.env.M_DB)
const quotesColl = db.collection('quotes')
const quotes = await quotesColl.find({ by: target.id }).toArray()
var index = Number((await interaction.message.embeds[0].data.title).split(' ')[2].slice(1))
if (!index) { index = 0 }
//if (index >= quotes.length){ return interaction.reply({content: 'Max Quotes Reached', ephemeral: true})}
if (index >= quotes.length) { index-- }
// will automatically reflect the next index due to how arrays think
const found = quotes[index]
const guild = await interaction.client.guilds.fetch(found.guildID)
const channel = await guild.channels.fetch(found.channelID)
const message = await channel.messages.fetch(found.messageID)
var msgData = {
content: message.content,
author: await message.author,
reference: await message.reference,
embed: await message.embeds ? 'embed' : null
} // debug
if (msgData.reference) {
let refMessage = await channel.messages.fetch(msgData.reference.messageId)
var refData = {
content: refMessage.content,
author: await refMessage.author,
embed: await refMessage.embeds.length > 0 ? 'embed' : null
}
}
var description = ''
if (refData) {
description += `> ${refData.author}`
if (refData.embed) {
description += '*an embed / a command* '
} else {
description += refData.content
}
description += `\r\n`
}
let messageLink = `https://discord.com/channels/${found.guildID}/${found.channelID}/${found.messageID}`
description += `${msgData.author} ${msgData.content}\r\n\r\n${messageLink}`
let timestamp = new Date(message.createdTimestamp)
let footer = timestamp.toDateString().toString()
const embed = new EmbedBuilder()
.setThumbnail(msgData.author.displayAvatarURL())
.setURL(messageLink)
.setTitle(`- Quote #${index + 1} -`)
.setDescription(description)
.setFooter({ text: (`${footer} #${found.messageID} <@${found.by}>`) })
const select = new ActionRowBuilder()
.addComponents(
new UserSelectMenuBuilder()
.setCustomId('quotes_list_mentionable')
.setPlaceholder('Filter By User')
)
const row = interaction.message.components[1]
await interaction.update({
embeds: [embed],
components: [select, row]
})
}
const { EmbedBuilder, UserSelectMenuBuilder, ActionRowBuilder } = require("discord.js")
const { mClient } = require("../..")
require('dotenv').config()
module.exports = {
name: 'quotes_list_right',
description: 'navigate right',
async execute(interaction) {
let oldEmbed = interaction.message.embeds[0].data
if (!oldEmbed.footer) { return interaction.reply({ content: 'Please use a Filter', ephemeral: true }) }
if (oldEmbed.fields && oldEmbed.fields[0].value == 0) { return interaction.reply({ content: 'This User has no Quotes', ephemeral: true }) }
let userID = interaction.message.embeds[0].data.footer.text.split(' ')[5].slice(2, -1)
const target = await interaction.guild.members.fetch(userID)
if (!target) { return interaction.reply({ content: 'Please use a Filter', ephemeral: true }) }
const db = mClient.db(process.env.M_DB)
const quotesColl = db.collection('quotes')
const quotes = await quotesColl.find({ by: target.id }).toArray()
var index = Number((await interaction.message.embeds[0].data.title).split(' ')[2].slice(1))
if (!index) { index = 0 }
//if (index >= quotes.length){ return interaction.reply({content: 'Max Quotes Reached', ephemeral: true})}
if (index >= quotes.length) { index-- }
// will automatically reflect the next index due to how arrays think
const found = quotes[index]
const guild = await interaction.client.guilds.fetch(found.guildID)
const channel = await guild.channels.fetch(found.channelID)
const message = await channel.messages.fetch(found.messageID)
var msgData = {
content: message.content,
author: await message.author,
reference: await message.reference,
embed: await message.embeds ? 'embed' : null
} // debug
if (msgData.reference) {
let refMessage = await channel.messages.fetch(msgData.reference.messageId)
var refData = {
content: refMessage.content,
author: await refMessage.author,
embed: await refMessage.embeds.length > 0 ? 'embed' : null
}
}
var description = ''
if (refData) {
description += `> ${refData.author}`
if (refData.embed) {
description += '*an embed / a command* '
} else {
description += refData.content
}
description += `\r\n`
}
let messageLink = `https://discord.com/channels/${found.guildID}/${found.channelID}/${found.messageID}`
description += `${msgData.author} ${msgData.content}\r\n\r\n${messageLink}`
let timestamp = new Date(message.createdTimestamp)
let footer = timestamp.toDateString().toString()
const embed = new EmbedBuilder()
.setThumbnail(msgData.author.displayAvatarURL())
.setURL(messageLink)
.setTitle(`- Quote #${index + 1} -`)
.setDescription(description)
.setFooter({ text: (`${footer} #${found.messageID} <@${found.by}>`) })
const select = new ActionRowBuilder()
.addComponents(
new UserSelectMenuBuilder()
.setCustomId('quotes_list_mentionable')
.setPlaceholder('Filter By User')
)
const row = interaction.message.components[1]
await interaction.update({
embeds: [embed],
components: [select, row]
})
}
}
+39
View File
@@ -0,0 +1,39 @@
const { SlashCommandBuilder, Events } = require('discord.js')
module.exports = {
data: new SlashCommandBuilder()
.setName('simjoin')
.setDescription('simulates a join event')
.addMentionableOption((option) =>
option.setName('target').setDescription('user')),
async execute(interaction) {
if(!interaction.member.permissions.has("ADMINISTRATOR")){
return await interaction.reply({
content: "Unprivileged Access!",
ephemeral: true
})
}
let target = interaction.options.getMentionable('target')
if(!target){
target = interaction.member
}
try {
if(target.user.username){
interaction.client.emit(Events.GuildMemberAdd, target)
await interaction.reply({
content: "Done!",
ephemeral: true
})
}
} catch (error) {
await interaction.reply({
content: "Invalid Mentionable!",
ephemeral: true
})
}
}
}
-10
View File
@@ -1,10 +0,0 @@
module.exports = {
name: 'DistubeError',
once: true,
async execute(channel, error) {
console.log({
channel: channel,
error: error
})
}
}
+77
View File
@@ -0,0 +1,77 @@
const { Events } = require('discord.js');
const { createCanvas, loadImage } = require('canvas');
const path = require('node:path');
require('dotenv').configDotenv();
module.exports = {
name: Events.GuildMemberAdd,
once: false,
async execute(member, client) {
const guild = client.guilds.cache.get(process.env.D_GuildID);
const channel = guild.channels.cache.get(process.env.D_WelcomeID);
console.log(`${member.user.username} joined the Server`);
// Create Canvas
let canvasWidth = 600;
let canvasHeight = 250;
const canvas = new createCanvas(canvasWidth, canvasHeight);
const ctx = canvas.getContext('2d');
// Draw Initial Image
const background = await loadImage(
path.join(__dirname, '../assets/background.png')
);
let x = 0;
let y = 0;
ctx.drawImage(background, x, y);
// Create Profile Picture
const pfp = await loadImage(
member.user.displayAvatarURL({
extension: 'jpg',
size: 64,
})
);
// Draw Profile Picture on Top of Background
x = canvas.width / 2 - pfp.width / 2;
y = 20;
ctx.drawImage(pfp, x, y);
// Set styles for text
ctx.font = '35px sans-serif';
ctx.fillStyle = '#ffffff'; // White text
ctx.strokeStyle = '#000000'; // Black outline
ctx.lineWidth = 3; // Thickness of the outline
let text = `Willkommen, ${member.user.username}!`;
let textWidth = ctx.measureText(text).width;
let textX = canvas.width / 2 - textWidth / 2;
let textHeight = 35; // Approximate height of the text
// Draw the text with black outline
ctx.strokeText(text, textX, 60 + pfp.height);
ctx.fillText(text, textX, 60 + pfp.height);
ctx.font = '30px sans-serif';
text = `auf dem ✨Olymp✨`;
textWidth = ctx.measureText(text).width;
textX = canvas.width / 2 - textWidth / 2;
textHeight = 30; // Approximate height of the text
// Draw the second line of text with black outline
ctx.strokeText(text, textX, 100 + pfp.height);
ctx.fillText(text, textX, 100 + pfp.height);
const banner = canvas.toBuffer();
channel.send({
content: `Bitte guck einmal in die <#850491176540700703> ${member}`,
files: [{
attachment: banner,
name: 'banner.png',
description: 'a welcome banner'
}]
});
}
};
+2 -2
View File
@@ -8,10 +8,10 @@ module.exports = (client) => {
const filePath = path.join(eventsPath, file)
const event = require(filePath)
if (event.once) {
client.once(event.name, (...args) => event.execute(...args))
client.once(event.name, (...args) => event.execute(...args, client))
// added client to commomerate global usage
} else {
client.on(event.name, (...args) => event.execute(...args))
client.on(event.name, (...args) => event.execute(...args, client))
// added client to commomerate global usage
}
}
+3 -15
View File
@@ -1,7 +1,5 @@
const { Client, GatewayIntentBits, Collection, Partials } = require('discord.js')
const { MongoClient } = require('mongodb')
const { DisTube } = require('distube');
const { YtDlpPlugin } = require('@distube/yt-dlp')
require('dotenv').config()
const mClient = new MongoClient(process.env.M_URI)
exports.mClient = mClient;
@@ -9,7 +7,8 @@ const fs = require('node:fs')
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildMessageReactions,
@@ -27,19 +26,8 @@ client.aliases = new Collection() // list of command aliases
client.buttons = new Collection() // list of buttons
client.selectMenus = new Collection() // list of selectMenus
// Initialize DisTube with YtDlpPlugin and request options
const distube = new DisTube(client, {
plugins: [
new YtDlpPlugin(),
],
});
client.distube = distube
fs.readdirSync('./handlers').forEach((handler) => {
require(`./handlers/${handler}`)(client)
});
distube.on('error', (channel, error) => {client.emit('DistubeError', (channel, error))})
client.login(process.env.D_Token)
client.login(process.env.D_Token)
+463 -965
View File
File diff suppressed because it is too large Load Diff
+2 -8
View File
@@ -20,16 +20,10 @@
},
"homepage": "https://github.com/DeSqBlocki/Arthonor-3#readme",
"dependencies": {
"@discordjs/opus": "^0.9.0",
"@discordjs/voice": "^0.17.0",
"@distube/yt-dlp": "^2.0.1",
"canvas": "^2.11.2",
"discord.js": "^14.15.3",
"distube": "^5.0.2",
"dotenv": "^16.4.5",
"mongodb": "^6.8.0",
"node-pre-gyp": "^0.17.0",
"nodemon": "^3.1.4",
"rebuild": "^0.1.2",
"sodium-native": "^4.1.1"
"nodemon": "^3.1.4"
}
}
+46 -46
View File
@@ -1,47 +1,47 @@
const { EmbedBuilder, ActionRowBuilder, UserSelectMenuBuilder, PermissionFlagsBits, RoleSelectMenuComponent, UserSelectMenuComponent } = require("discord.js")
const { mClient } = require("../..")
require('dotenv').config()
module.exports = {
name: 'quotes_list_mentionable',
description: 'handles quotes list mentionables',
async execute(interaction) {
const embedData = await interaction.message.embeds[0].data
const embed = new EmbedBuilder()
if (!interaction.members) {
embed.setTitle(embedData.title)
.setThumbnail(embedData.thumbnail.url)
.setDescription(embedData.description);
} else {
const target = await interaction.guild.members.fetch(interaction.members.keys().next().value)
const db = mClient.db(process.env.M_DB)
const quotesColl = db.collection('quotes')
const quotes = await quotesColl.find({ by: target.id }).toArray()
const member = interaction.message.guild.members.cache.get(target.user.id)
const memberRoles = member.roles.cache
.filter((roles) => roles.id !== interaction.message.guild.id)
.map((role) => role.toString())
const description = String(`${target}\r\n\r\n${memberRoles}`).replaceAll(',', ' ')
embed.setTitle(`- User Stats -`)
.setDescription(description)
.setThumbnail(target.displayAvatarURL())
.addFields({
name: 'Number of Quotes:', value: `${quotes.length}`, inline: true
})
.setFooter({ text: (`${new Date().toLocaleDateString('en-US', { weekday: 'short' })} ${new Date().toLocaleDateString('en-US', { month: 'short' })} ${new Date().getDate()} ${new Date().getFullYear()} UserID <@${member.id}>`) })
}
const select = new ActionRowBuilder()
.addComponents(
new UserSelectMenuBuilder()
.setCustomId('quotes_list_mentionable')
.setPlaceholder('Filter By User')
)
const row = interaction.message.components[1]
await interaction.update({
embeds: [embed],
components: [select, row]
})
}
const { EmbedBuilder, ActionRowBuilder, UserSelectMenuBuilder, PermissionFlagsBits, RoleSelectMenuComponent, UserSelectMenuComponent } = require("discord.js")
const { mClient } = require("../..")
require('dotenv').config()
module.exports = {
name: 'quotes_list_mentionable',
description: 'handles quotes list mentionables',
async execute(interaction) {
const embedData = await interaction.message.embeds[0].data
const embed = new EmbedBuilder()
if (!interaction.members) {
embed.setTitle(embedData.title)
.setThumbnail(embedData.thumbnail.url)
.setDescription(embedData.description);
} else {
const target = await interaction.guild.members.fetch(interaction.members.keys().next().value)
const db = mClient.db(process.env.M_DB)
const quotesColl = db.collection('quotes')
const quotes = await quotesColl.find({ by: target.id }).toArray()
const member = interaction.message.guild.members.cache.get(target.user.id)
const memberRoles = member.roles.cache
.filter((roles) => roles.id !== interaction.message.guild.id)
.map((role) => role.toString())
const description = String(`${target}\r\n\r\n${memberRoles}`).replaceAll(',', ' ')
embed.setTitle(`- User Stats -`)
.setDescription(description)
.setThumbnail(target.displayAvatarURL())
.addFields({
name: 'Number of Quotes:', value: `${quotes.length}`, inline: true
})
.setFooter({ text: (`${new Date().toLocaleDateString('en-US', { weekday: 'short' })} ${new Date().toLocaleDateString('en-US', { month: 'short' })} ${new Date().getDate()} ${new Date().getFullYear()} UserID <@${member.id}>`) })
}
const select = new ActionRowBuilder()
.addComponents(
new UserSelectMenuBuilder()
.setCustomId('quotes_list_mentionable')
.setPlaceholder('Filter By User')
)
const row = interaction.message.components[1]
await interaction.update({
embeds: [embed],
components: [select, row]
})
}
}