Added Leaderboard to Quotes
This commit is contained in:
@@ -0,0 +1,9 @@
|
|||||||
|
- quotes leaderboard (count)
|
||||||
|
- quotes filter by channel
|
||||||
|
- event creation + reminder 1h before
|
||||||
|
- birthday role
|
||||||
|
- 8ball (neue Antworten)
|
||||||
|
- avatar
|
||||||
|
- mittwoch
|
||||||
|
- wetter
|
||||||
|
- WGE (help)
|
||||||
@@ -24,7 +24,9 @@ module.exports = {
|
|||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setTitle('Honors Leaderboard')
|
.setTitle('Honors Leaderboard')
|
||||||
.setThumbnail('https://cdn.discordapp.com/attachments/1152723542836772914/1152940755539722240/pngwing.com.png')
|
.setThumbnail('https://cdn.discordapp.com/attachments/1152723542836772914/1152940755539722240/pngwing.com.png')
|
||||||
.setDescription(fields.toString());
|
.setDescription(fields.toString())
|
||||||
|
.setColor('#5865F2') // Discord's blurple color
|
||||||
|
.setFooter({ text: 'Use ◄ ► to navigate' });
|
||||||
await interaction.update({
|
await interaction.update({
|
||||||
embeds: [embed],
|
embeds: [embed],
|
||||||
components: [interaction.message.components[0]]
|
components: [interaction.message.components[0]]
|
||||||
|
|||||||
@@ -22,7 +22,9 @@ module.exports = {
|
|||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setTitle('Honors Leaderboard')
|
.setTitle('Honors Leaderboard')
|
||||||
.setThumbnail('https://cdn.discordapp.com/attachments/1152723542836772914/1152940755539722240/pngwing.com.png')
|
.setThumbnail('https://cdn.discordapp.com/attachments/1152723542836772914/1152940755539722240/pngwing.com.png')
|
||||||
.setDescription(fields.toString());
|
.setDescription(fields.toString())
|
||||||
|
.setColor('#5865F2') // Discord's blurple color
|
||||||
|
.setFooter({ text: 'Use ◄ ► to navigate' });
|
||||||
await interaction.update({
|
await interaction.update({
|
||||||
embeds: [embed],
|
embeds: [embed],
|
||||||
components: [interaction.message.components[0]]
|
components: [interaction.message.components[0]]
|
||||||
|
|||||||
@@ -32,7 +32,10 @@ module.exports = {
|
|||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setTitle('Honors Leaderboard')
|
.setTitle('Honors Leaderboard')
|
||||||
.setThumbnail('https://cdn.discordapp.com/attachments/1152723542836772914/1152940755539722240/pngwing.com.png')
|
.setThumbnail('https://cdn.discordapp.com/attachments/1152723542836772914/1152940755539722240/pngwing.com.png')
|
||||||
.setDescription(fields.toString());
|
.setDescription(fields.toString())
|
||||||
|
.setColor('#5865F2') // Discord's blurple color
|
||||||
|
.setFooter({ text: 'Use ◄ ► to navigate' });
|
||||||
|
|
||||||
await interaction.update({
|
await interaction.update({
|
||||||
embeds: [embed],
|
embeds: [embed],
|
||||||
components: [interaction.message.components[0]]
|
components: [interaction.message.components[0]]
|
||||||
|
|||||||
@@ -24,7 +24,9 @@ module.exports = {
|
|||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setTitle('Nuts Leaderboard')
|
.setTitle('Nuts Leaderboard')
|
||||||
.setThumbnail('https://cdn.discordapp.com/attachments/1152723542836772914/1152940755539722240/pngwing.com.png')
|
.setThumbnail('https://cdn.discordapp.com/attachments/1152723542836772914/1152940755539722240/pngwing.com.png')
|
||||||
.setDescription(fields.toString());
|
.setDescription(fields.toString())
|
||||||
|
.setColor('#5865F2') // Discord's blurple color
|
||||||
|
.setFooter({ text: 'Use ◄ ► to navigate' });
|
||||||
await interaction.update({
|
await interaction.update({
|
||||||
embeds: [embed],
|
embeds: [embed],
|
||||||
components: [interaction.message.components[0]]
|
components: [interaction.message.components[0]]
|
||||||
|
|||||||
@@ -22,7 +22,9 @@ module.exports = {
|
|||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setTitle('Nuts Leaderboard')
|
.setTitle('Nuts Leaderboard')
|
||||||
.setThumbnail('https://cdn.discordapp.com/attachments/1152723542836772914/1152940755539722240/pngwing.com.png')
|
.setThumbnail('https://cdn.discordapp.com/attachments/1152723542836772914/1152940755539722240/pngwing.com.png')
|
||||||
.setDescription(fields.toString());
|
.setDescription(fields.toString())
|
||||||
|
.setColor('#5865F2') // Discord's blurple color
|
||||||
|
.setFooter({ text: 'Use ◄ ► to navigate' });
|
||||||
await interaction.update({
|
await interaction.update({
|
||||||
embeds: [embed],
|
embeds: [embed],
|
||||||
components: [interaction.message.components[0]]
|
components: [interaction.message.components[0]]
|
||||||
|
|||||||
@@ -32,7 +32,9 @@ module.exports = {
|
|||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setTitle('Nuts Leaderboard')
|
.setTitle('Nuts Leaderboard')
|
||||||
.setThumbnail('https://cdn.discordapp.com/attachments/1152723542836772914/1152940755539722240/pngwing.com.png')
|
.setThumbnail('https://cdn.discordapp.com/attachments/1152723542836772914/1152940755539722240/pngwing.com.png')
|
||||||
.setDescription(fields.toString());
|
.setDescription(fields.toString())
|
||||||
|
.setColor('#5865F2') // Discord's blurple color
|
||||||
|
.setFooter({ text: 'Use ◄ ► to navigate' });
|
||||||
await interaction.update({
|
await interaction.update({
|
||||||
embeds: [embed],
|
embeds: [embed],
|
||||||
components: [interaction.message.components[0]]
|
components: [interaction.message.components[0]]
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
const { EmbedBuilder, ButtonBuilder, ButtonStyle, ActionRowBuilder } = require('discord.js');
|
||||||
|
const { mClient } = require('../..'); // Adjust the path as needed
|
||||||
|
function delay(ms) { return new Promise(resolve => setTimeout(resolve, ms)); }
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'quotes_leaderboard_right',
|
||||||
|
description: 'Navigate right through the quotes leaderboard',
|
||||||
|
async execute(interaction) {
|
||||||
|
await interaction.deferReply()
|
||||||
|
const db = mClient.db(process.env.M_DB)
|
||||||
|
const quotesColl = db.collection('quotes')
|
||||||
|
const maxValue = await quotesColl.countDocuments({ $and: [{ guildID: interaction.guild.id }, { count: { $gt: 0 } }] })
|
||||||
|
|
||||||
|
let skip = interaction.message.embeds[0].data.fields[0].value.split('.')
|
||||||
|
skip = Number(skip[0]) - 6
|
||||||
|
if (skip >= (maxValue - (maxValue % 5))) {
|
||||||
|
skip = maxValue - (maxValue % 5)
|
||||||
|
}
|
||||||
|
|
||||||
|
const quotesData = await quotesColl.find({ count: { $gt: 0 } }).sort({ count: -1, messageID: -1 }).skip(skip).limit(5).toArray()
|
||||||
|
const fields = []
|
||||||
|
|
||||||
|
const guild = await interaction.client.guilds.fetch(interaction.guild.id)
|
||||||
|
quotesData.forEach(async (data, index) => {
|
||||||
|
|
||||||
|
let channel = await guild.channels.fetch(data.channelID)
|
||||||
|
let message = await channel.messages.fetch(data.messageID)
|
||||||
|
await delay(500)
|
||||||
|
fields.push({
|
||||||
|
name: `\u200b`,
|
||||||
|
value: `${skip + index + 1}. [#${data.messageID}](https://discord.com/channels/${data.guildID}/${data.channelID}/${data.messageID})\r\n**by** <@${data.by}> • ⭐ ${data.count}\r\n${message.content}`
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
await delay(5000)
|
||||||
|
console.log(fields)
|
||||||
|
const embed = new EmbedBuilder()
|
||||||
|
.setTitle('- Quotes Leaderboard -')
|
||||||
|
.setThumbnail('https://cdn.discordapp.com/attachments/1152723542836772914/1152940755539722240/pngwing.com.png')
|
||||||
|
.setFields(fields)
|
||||||
|
.setColor('#5865F2') // Discord's blurple color
|
||||||
|
.setFooter({ text: 'Use ◄ ► to navigate' });
|
||||||
|
|
||||||
|
const row = new ActionRowBuilder()
|
||||||
|
.addComponents(
|
||||||
|
new ButtonBuilder()
|
||||||
|
.setLabel('◄')
|
||||||
|
.setStyle(ButtonStyle.Primary)
|
||||||
|
.setCustomId('quotes_leaderboard_left')
|
||||||
|
.setDisabled(skip - 6 < 0)
|
||||||
|
)
|
||||||
|
.addComponents(
|
||||||
|
new ButtonBuilder()
|
||||||
|
.setLabel('X')
|
||||||
|
.setStyle(ButtonStyle.Danger)
|
||||||
|
.setCustomId('abort')
|
||||||
|
)
|
||||||
|
.addComponents(
|
||||||
|
new ButtonBuilder()
|
||||||
|
.setLabel('►')
|
||||||
|
.setStyle(ButtonStyle.Primary)
|
||||||
|
.setCustomId('quotes_leaderboard_right')
|
||||||
|
.setDisabled(skip + 4 > maxValue)
|
||||||
|
)
|
||||||
|
await interaction.editReply({
|
||||||
|
embeds: [embed],
|
||||||
|
components: [row]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
const { EmbedBuilder, ButtonBuilder, ButtonStyle, ActionRowBuilder } = require('discord.js');
|
||||||
|
const { mClient } = require('../..'); // Adjust the path as needed
|
||||||
|
function delay(ms) { return new Promise(resolve => setTimeout(resolve, ms)); }
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'quotes_leaderboard_right',
|
||||||
|
description: 'Navigate right through the quotes leaderboard',
|
||||||
|
async execute(interaction) {
|
||||||
|
await interaction.deferReply()
|
||||||
|
const db = mClient.db(process.env.M_DB)
|
||||||
|
const quotesColl = db.collection('quotes')
|
||||||
|
const maxValue = await quotesColl.countDocuments({ $and: [{ guildID: interaction.guild.id }, { count: { $gt: 0 } }] })
|
||||||
|
|
||||||
|
let skip = interaction.message.embeds[0].data.fields[0].value.split('.')
|
||||||
|
skip = Number(skip[0]) +4
|
||||||
|
if (skip >= (maxValue - (maxValue % 5))) {
|
||||||
|
skip = maxValue - (maxValue % 5)
|
||||||
|
}
|
||||||
|
|
||||||
|
const quotesData = await quotesColl.find({ count: { $gt: 0 } }).sort({ count: -1, messageID: -1 }).skip(skip).limit(5).toArray()
|
||||||
|
const fields = []
|
||||||
|
|
||||||
|
const guild = await interaction.client.guilds.fetch(interaction.guild.id)
|
||||||
|
quotesData.forEach(async (data, index) => {
|
||||||
|
|
||||||
|
let channel = await guild.channels.fetch(data.channelID)
|
||||||
|
let message = await channel.messages.fetch(data.messageID)
|
||||||
|
await delay(500)
|
||||||
|
fields.push({
|
||||||
|
name: `\u200b`,
|
||||||
|
value: `${skip + index + 1}. [#${data.messageID}](https://discord.com/channels/${data.guildID}/${data.channelID}/${data.messageID})\r\n**by** <@${data.by}> • ⭐ ${data.count}\r\n${message.content}`
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
await delay(5000)
|
||||||
|
console.log(fields)
|
||||||
|
const embed = new EmbedBuilder()
|
||||||
|
.setTitle('- Quotes Leaderboard -')
|
||||||
|
.setThumbnail('https://cdn.discordapp.com/attachments/1152723542836772914/1152940755539722240/pngwing.com.png')
|
||||||
|
.setFields(fields)
|
||||||
|
.setColor('#5865F2') // Discord's blurple color
|
||||||
|
.setFooter({ text: 'Use ◄ ► to navigate' });
|
||||||
|
|
||||||
|
const row = new ActionRowBuilder()
|
||||||
|
.addComponents(
|
||||||
|
new ButtonBuilder()
|
||||||
|
.setLabel('◄')
|
||||||
|
.setStyle(ButtonStyle.Primary)
|
||||||
|
.setCustomId('quotes_leaderboard_left')
|
||||||
|
.setDisabled(skip - 6 < 0)
|
||||||
|
)
|
||||||
|
.addComponents(
|
||||||
|
new ButtonBuilder()
|
||||||
|
.setLabel('X')
|
||||||
|
.setStyle(ButtonStyle.Danger)
|
||||||
|
.setCustomId('abort')
|
||||||
|
)
|
||||||
|
.addComponents(
|
||||||
|
new ButtonBuilder()
|
||||||
|
.setLabel('►')
|
||||||
|
.setStyle(ButtonStyle.Primary)
|
||||||
|
.setCustomId('quotes_leaderboard_right')
|
||||||
|
.setDisabled(skip + 4 > maxValue)
|
||||||
|
)
|
||||||
|
await interaction.editReply({
|
||||||
|
embeds: [embed],
|
||||||
|
components: [row]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
const { SlashCommandBuilder, Events } = require('discord.js')
|
||||||
|
const { mClient } = require('../..')
|
||||||
|
require('dotenv').config()
|
||||||
|
|
||||||
|
async function channelSet(interaction) {
|
||||||
|
const channel = interaction.options.getChannel('channel')
|
||||||
|
const purpose = interaction.options.getString('purpose')
|
||||||
|
const db = mClient.db(process.env.DB)
|
||||||
|
const channelColl = db.collection('channels')
|
||||||
|
|
||||||
|
await channelColl.findOneAndUpdate({
|
||||||
|
$and: [{ guildID: channel.guild.id }, { purpose: purpose }]
|
||||||
|
}, {
|
||||||
|
$set: {
|
||||||
|
guildID: channel.guild.id,
|
||||||
|
purpose: purpose,
|
||||||
|
channelID: channel.id
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
upsert: true
|
||||||
|
})
|
||||||
|
|
||||||
|
return await interaction.editReply({
|
||||||
|
content: `Set <#${channel.id}> as ${purpose} channel!`, ephemeral: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
async function channelSimulate(interaction) {
|
||||||
|
const purpose = interaction.options.getString('purpose')
|
||||||
|
switch (purpose) {
|
||||||
|
case 'birthday':
|
||||||
|
await interaction.client.emit('Birthday', interaction.member)
|
||||||
|
break;
|
||||||
|
case 'wge':
|
||||||
|
// For Future WGE Use
|
||||||
|
break;
|
||||||
|
case 'welcome':
|
||||||
|
await interaction.client.emit(Events.GuildMemberAdd, interaction.member)
|
||||||
|
break;
|
||||||
|
case 'logs':
|
||||||
|
// For Future Log Use
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return interaction.reply({ content: 'Done.', ephemeral: true })
|
||||||
|
}
|
||||||
|
module.exports = {
|
||||||
|
data: new SlashCommandBuilder()
|
||||||
|
.setName('channels')
|
||||||
|
.setDescription('rund um den honor')
|
||||||
|
.addSubcommand(s =>
|
||||||
|
s
|
||||||
|
.setName('set')
|
||||||
|
.setDescription('set a channel for a specific purpose')
|
||||||
|
.addStringOption(o =>
|
||||||
|
o.setName('purpose').setDescription('set the purpose').setRequired(true).addChoices({
|
||||||
|
name: 'birthday',
|
||||||
|
value: 'birthday'
|
||||||
|
}, {
|
||||||
|
name: 'welcome',
|
||||||
|
value: 'welcome'
|
||||||
|
}, {
|
||||||
|
name: 'logs',
|
||||||
|
value: 'logs'
|
||||||
|
}, {
|
||||||
|
name: 'wge',
|
||||||
|
value: 'wge'
|
||||||
|
}))
|
||||||
|
.addChannelOption(c =>
|
||||||
|
c.setName('channel').setDescription('choose a channel').setRequired(true)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.addSubcommand(s =>
|
||||||
|
s
|
||||||
|
.setName('simulate')
|
||||||
|
.setDescription('simulate a specific channel event')
|
||||||
|
.addStringOption(o =>
|
||||||
|
o.setName('purpose').setDescription('set the purpose').setRequired(true).addChoices({
|
||||||
|
name: 'birthday',
|
||||||
|
value: 'birthday'
|
||||||
|
}, {
|
||||||
|
name: 'welcome',
|
||||||
|
value: 'welcome'
|
||||||
|
}, {
|
||||||
|
name: 'logs',
|
||||||
|
value: 'logs'
|
||||||
|
}, {
|
||||||
|
name: 'wge',
|
||||||
|
value: 'wge'
|
||||||
|
}))
|
||||||
|
)
|
||||||
|
,
|
||||||
|
async execute(interaction) {
|
||||||
|
switch (interaction.options._subcommand) {
|
||||||
|
case 'set':
|
||||||
|
await interaction.deferReply()
|
||||||
|
channelSet(interaction)
|
||||||
|
break;
|
||||||
|
case 'simulate':
|
||||||
|
channelSimulate(interaction)
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -104,7 +104,9 @@ async function honorLeaderboard(interaction) {
|
|||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setTitle('- Honors Leaderboard -')
|
.setTitle('- Honors Leaderboard -')
|
||||||
.setThumbnail('https://cdn.discordapp.com/attachments/1152723542836772914/1152940755539722240/pngwing.com.png')
|
.setThumbnail('https://cdn.discordapp.com/attachments/1152723542836772914/1152940755539722240/pngwing.com.png')
|
||||||
.setDescription(fields.toString());
|
.setDescription(fields.toString())
|
||||||
|
.setColor('#5865F2') // Discord's blurple color
|
||||||
|
.setFooter({ text: 'Use ◄ ► to navigate' });
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [embed],
|
embeds: [embed],
|
||||||
components: [row]
|
components: [row]
|
||||||
|
|||||||
+14
-5
@@ -129,7 +129,9 @@ async function nutsLeaderboard(interaction) {
|
|||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setTitle('Nuts Leaderboard')
|
.setTitle('Nuts Leaderboard')
|
||||||
.setThumbnail('https://cdn.discordapp.com/attachments/1152723542836772914/1152940755539722240/pngwing.com.png')
|
.setThumbnail('https://cdn.discordapp.com/attachments/1152723542836772914/1152940755539722240/pngwing.com.png')
|
||||||
.setDescription(fields.toString());
|
.setDescription(fields.toString())
|
||||||
|
.setColor('#5865F2') // Discord's blurple color
|
||||||
|
.setFooter({ text: 'Use ◄ ► to navigate' });
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [embed],
|
embeds: [embed],
|
||||||
components: [row]
|
components: [row]
|
||||||
@@ -192,7 +194,9 @@ async function nutsCooldown(interaction) {
|
|||||||
let content = `Du kannst wieder nussen! :)`
|
let content = `Du kannst wieder nussen! :)`
|
||||||
let thumbnail = 'https://cdn-icons-png.flaticon.com/512/7451/7451659.png'
|
let thumbnail = 'https://cdn-icons-png.flaticon.com/512/7451/7451659.png'
|
||||||
let title = 'Go Nuts!'
|
let title = 'Go Nuts!'
|
||||||
if (cooldown) {
|
|
||||||
|
let date = (Date.now() / 1000)
|
||||||
|
if (cooldown.cooldown > date) {
|
||||||
content = `<t:${cooldown.cooldown}:R> kannst du wieder nussen! ;)`
|
content = `<t:${cooldown.cooldown}:R> kannst du wieder nussen! ;)`
|
||||||
thumbnail = 'https://cdn.discordapp.com/attachments/1152723542836772914/1152987472788193361/No-nuts-PhotoRoom.png-PhotoRoom.png'
|
thumbnail = 'https://cdn.discordapp.com/attachments/1152723542836772914/1152987472788193361/No-nuts-PhotoRoom.png-PhotoRoom.png'
|
||||||
title = 'To Nut or Not to Nut...'
|
title = 'To Nut or Not to Nut...'
|
||||||
@@ -213,6 +217,8 @@ async function nutsNut(interaction) {
|
|||||||
const cdColl = db.collection('cooldown')
|
const cdColl = db.collection('cooldown')
|
||||||
|
|
||||||
const cdData = await cdColl.findOne({ userID: interaction.user.id })
|
const cdData = await cdColl.findOne({ userID: interaction.user.id })
|
||||||
|
const embed = new EmbedBuilder()
|
||||||
|
.setThumbnail('https://cdn.discordapp.com/attachments/1152723542836772914/1152991361113538621/png-transparent-subscription-box-label-bag-mysterious-miscellaneous-purple-blue-thumbnail-PhotoRoom.png-PhotoRoom.png')
|
||||||
|
|
||||||
let content
|
let content
|
||||||
const images = {
|
const images = {
|
||||||
@@ -259,11 +265,14 @@ async function nutsNut(interaction) {
|
|||||||
} else {
|
} else {
|
||||||
content = `Du kannst erst <t:${Math.floor(cdData?.cooldown)}:R> wieder nussen :(`
|
content = `Du kannst erst <t:${Math.floor(cdData?.cooldown)}:R> wieder nussen :(`
|
||||||
image = images["onCD"]
|
image = images["onCD"]
|
||||||
|
await delay(1000)
|
||||||
|
embed.setDescription(content)
|
||||||
|
embed.setThumbnail(image)
|
||||||
|
return await interaction.editReply({
|
||||||
|
embeds: [embed]
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
|
||||||
.setThumbnail('https://cdn.discordapp.com/attachments/1152723542836772914/1152991361113538621/png-transparent-subscription-box-label-bag-mysterious-miscellaneous-purple-blue-thumbnail-PhotoRoom.png-PhotoRoom.png')
|
|
||||||
|
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [embed]
|
embeds: [embed]
|
||||||
})
|
})
|
||||||
|
|||||||
+68
-11
@@ -1,17 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
Add
|
|
||||||
Delete
|
|
||||||
Random
|
|
||||||
Random By Person
|
|
||||||
Direct Search by ID
|
|
||||||
|
|
||||||
Random By Year?
|
Random By Year?
|
||||||
List?
|
Counter (Leaderboard)
|
||||||
Counter (Leaderboard?)
|
|
||||||
*/
|
*/
|
||||||
const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, UserSelectMenuBuilder } = require('discord.js')
|
const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, UserSelectMenuBuilder } = require('discord.js')
|
||||||
const { mClient } = require('../..')
|
const { mClient } = require('../..')
|
||||||
require('dotenv').config()
|
require('dotenv').config()
|
||||||
|
function delay(ms) { return new Promise(resolve => setTimeout(resolve, ms)); }
|
||||||
|
|
||||||
async function quotesAdd(interaction) {
|
async function quotesAdd(interaction) {
|
||||||
const messageLink = await interaction.options.getString('link')
|
const messageLink = await interaction.options.getString('link')
|
||||||
@@ -272,12 +266,74 @@ async function quotesList(interaction) {
|
|||||||
ephemeral: true
|
ephemeral: true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
async function quotesLeaderboard(interaction) {
|
async function quotesLeaderboard(interaction) {
|
||||||
// need to add count to quotes
|
const db = mClient.db(process.env.M_DB)
|
||||||
|
const quotesColl = db.collection('quotes')
|
||||||
|
let skip = 0
|
||||||
|
const minValue = 0
|
||||||
|
const maxValue = await quotesColl.countDocuments({ $and: [{ guildID: interaction.guild.id }, { count: { $gt: 0 } }] })
|
||||||
|
|
||||||
|
const quotesData = await quotesColl.find({}).sort({ count: -1, messageID: -1 }).skip(skip).limit(5).toArray()
|
||||||
|
const fields = []
|
||||||
|
|
||||||
|
const guild = await interaction.client.guilds.fetch(interaction.guild.id)
|
||||||
|
quotesData.forEach(async (data, index) => {
|
||||||
|
|
||||||
|
let channel = await guild.channels.fetch(data.channelID)
|
||||||
|
let message = await channel.messages.fetch(data.messageID)
|
||||||
|
|
||||||
|
await delay(500)
|
||||||
|
let timestamp = new Date(message.createdTimestamp)
|
||||||
|
fields.push({
|
||||||
|
name: `${index + 1}.`,//`\u200b` ,
|
||||||
|
value: `[#${data.messageID}](https://discord.com/channels/${data.guildID}/${data.channelID}/${data.messageID})\r\n**by** <@${data.by}> • ⭐ ${data.count}\r\n_Posted on **${timestamp}**_\r\n${message.content}`
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
await delay(5000)
|
||||||
|
console.log(fields)
|
||||||
|
quotesData.sort((a,b) => {
|
||||||
|
const numA = parseInt(a.name);
|
||||||
|
const numB = parseInt(b.name);
|
||||||
|
return numA - numB;
|
||||||
|
})
|
||||||
|
console.log(fields)
|
||||||
|
|
||||||
|
const embed = new EmbedBuilder()
|
||||||
|
.setTitle('- Quotes Leaderboard -')
|
||||||
|
.setThumbnail('https://cdn.discordapp.com/attachments/1152723542836772914/1152940755539722240/pngwing.com.png')
|
||||||
|
.setFields(fields)
|
||||||
|
.setColor('#5865F2') // Discord's blurple color
|
||||||
|
.setFooter({ text: `Use ◄ ► to navigate\r\n${skip}` });
|
||||||
|
|
||||||
|
const row = new ActionRowBuilder()
|
||||||
|
.addComponents(
|
||||||
|
new ButtonBuilder()
|
||||||
|
.setLabel('◄')
|
||||||
|
.setStyle(ButtonStyle.Primary)
|
||||||
|
.setCustomId('quotes_leaderboard_left')
|
||||||
|
)
|
||||||
|
.addComponents(
|
||||||
|
new ButtonBuilder()
|
||||||
|
.setLabel('X')
|
||||||
|
.setStyle(ButtonStyle.Danger)
|
||||||
|
.setCustomId('abort')
|
||||||
|
)
|
||||||
|
.addComponents(
|
||||||
|
new ButtonBuilder()
|
||||||
|
.setLabel('►')
|
||||||
|
.setStyle(ButtonStyle.Primary)
|
||||||
|
.setCustomId('quotes_leaderboard_right')
|
||||||
|
)
|
||||||
|
await interaction.editReply({
|
||||||
|
embeds: [embed],
|
||||||
|
components: [row]
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName('quotes')
|
.setName('quotes')
|
||||||
@@ -326,6 +382,7 @@ module.exports = {
|
|||||||
quotesRandom(interaction)
|
quotesRandom(interaction)
|
||||||
break;
|
break;
|
||||||
case 'leaderboard':
|
case 'leaderboard':
|
||||||
|
await interaction.deferReply()
|
||||||
quotesLeaderboard(interaction)
|
quotesLeaderboard(interaction)
|
||||||
break;
|
break;
|
||||||
case 'list':
|
case 'list':
|
||||||
|
|||||||
@@ -0,0 +1,259 @@
|
|||||||
|
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js')
|
||||||
|
const { mClient } = require('../..')
|
||||||
|
const { configDotenv } = require('dotenv')
|
||||||
|
configDotenv()
|
||||||
|
|
||||||
|
function isValidDate(day, month) {
|
||||||
|
// Define the number of days in each month
|
||||||
|
const daysInMonth = {
|
||||||
|
1: 31, // January
|
||||||
|
2: 28, // February (ignore leap years)
|
||||||
|
3: 31, // March
|
||||||
|
4: 30, // April
|
||||||
|
5: 31, // May
|
||||||
|
6: 30, // June
|
||||||
|
7: 31, // July
|
||||||
|
8: 31, // August
|
||||||
|
9: 30, // September
|
||||||
|
10: 31, // October
|
||||||
|
11: 30, // November
|
||||||
|
12: 31 // December
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check if month is valid
|
||||||
|
if (month < 1 || month > 12) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if day is valid for the given month
|
||||||
|
if (day < 1 || day > daysInMonth[month]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function birthdayAdd(interaction) {
|
||||||
|
let target = await interaction.options.getUser('user')
|
||||||
|
let day = await interaction.options.getNumber('day')
|
||||||
|
let month = await interaction.options.getNumber('month')
|
||||||
|
|
||||||
|
|
||||||
|
if (!isValidDate(day, month)) {
|
||||||
|
return interaction.reply({ content: "Invalid Date", ephemeral: true })
|
||||||
|
}
|
||||||
|
|
||||||
|
const db = mClient.db(process.env.M_DB)
|
||||||
|
const bdayColl = db.collection('birthdays')
|
||||||
|
|
||||||
|
const found = await bdayColl.findOne({ userID: target.id })
|
||||||
|
if (found) {
|
||||||
|
return interaction.reply({ content: "Already in Database", ephemeral: true })
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
guildID: interaction.guild.id,
|
||||||
|
userID: target.id,
|
||||||
|
day: day,
|
||||||
|
month: month
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await bdayColl.insertOne(data)
|
||||||
|
if (res.acknowledged) {
|
||||||
|
return interaction.reply({ content: "Birthday added successfully!" })
|
||||||
|
} else {
|
||||||
|
return interaction.reply({ content: "There was an issue!" })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function birthdayDelete(interaction) {
|
||||||
|
var target = await interaction.options.getUser('user')
|
||||||
|
const guild = await interaction.client.guilds.cache.get(interaction.guild.id)
|
||||||
|
if (!target) {
|
||||||
|
target = await guild.members.cache.get(await interaction.options.getString('id'))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!target) {
|
||||||
|
return interaction.reply({ content: "Invalid or No User specified!" })
|
||||||
|
}
|
||||||
|
|
||||||
|
const db = mClient.db(process.env.M_DB)
|
||||||
|
const bdayColl = db.collection('birthdays')
|
||||||
|
|
||||||
|
const found = await bdayColl.findOne({ userID: target.id })
|
||||||
|
if (!found) {
|
||||||
|
return interaction.reply({ content: "Not yet in Database", ephemeral: true })
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await bdayColl.deleteOne({ userID: target.id })
|
||||||
|
if (res.acknowledged) {
|
||||||
|
return interaction.reply({ content: "Birthday removed successfully!" })
|
||||||
|
} else {
|
||||||
|
return interaction.reply({ content: "There was an issue!" })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function birthdayEdit(interaction) {
|
||||||
|
let target = await interaction.options.getUser('user')
|
||||||
|
let day = await interaction.options.getNumber('day')
|
||||||
|
let month = await interaction.options.getNumber('month')
|
||||||
|
|
||||||
|
|
||||||
|
if (!isValidDate(day, month)) {
|
||||||
|
return interaction.reply({ content: "Invalid Date", ephemeral: true })
|
||||||
|
}
|
||||||
|
|
||||||
|
const db = mClient.db(process.env.M_DB)
|
||||||
|
const bdayColl = db.collection('birthdays')
|
||||||
|
|
||||||
|
const found = await bdayColl.findOne({ userID: target.id })
|
||||||
|
if (!found) {
|
||||||
|
return interaction.reply({ content: "Not yet in Database", ephemeral: true })
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
guildID: interaction.guild.id,
|
||||||
|
userID: target.id,
|
||||||
|
day: day,
|
||||||
|
month: month
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await bdayColl.findOneAndUpdate({ userID: target.id }, { $set: data }, { upsert: true })
|
||||||
|
return interaction.reply({ content: "Birthday edited successfully!" })
|
||||||
|
}
|
||||||
|
async function isDateInPast(day, month) {
|
||||||
|
const currentYear = new Date().getFullYear();
|
||||||
|
const inputDate = new Date(currentYear, month - 1, day);
|
||||||
|
const now = new Date();
|
||||||
|
return inputDate < now;
|
||||||
|
}
|
||||||
|
async function makeTimestamp(day, month, year) {
|
||||||
|
const date = new Date(year, month - 1, day);
|
||||||
|
const unixTimestamp = Math.floor(date.getTime() / 1000);
|
||||||
|
return unixTimestamp
|
||||||
|
}
|
||||||
|
function isToday(day, month) {
|
||||||
|
const currentYear = new Date().getFullYear();
|
||||||
|
const inputDate = new Date(currentYear, month - 1, day);
|
||||||
|
const today = new Date();
|
||||||
|
return (
|
||||||
|
inputDate.getDate() === today.getDate() &&
|
||||||
|
inputDate.getMonth() === today.getMonth() &&
|
||||||
|
inputDate.getFullYear() === today.getFullYear()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
async function birthdayGet(interaction) {
|
||||||
|
let target = await interaction.options.getUser('user')
|
||||||
|
const db = mClient.db(process.env.M_DB)
|
||||||
|
const bdayColl = db.collection('birthdays')
|
||||||
|
|
||||||
|
const found = await bdayColl.findOne({ userID: target.id })
|
||||||
|
if (!found) {
|
||||||
|
return interaction.reply({ content: "Not in Database!", ephemeral: true })
|
||||||
|
}
|
||||||
|
let unix
|
||||||
|
if(isDateInPast(found.day,found.month)){
|
||||||
|
let nextYear = new Date().getFullYear() + 1
|
||||||
|
unix = await makeTimestamp(found.day,found.month, nextYear)
|
||||||
|
} else {
|
||||||
|
let thisYear = new Date().getFullYear()
|
||||||
|
unix = await makeTimestamp(found.day,found.month, thisYear)
|
||||||
|
}
|
||||||
|
let description = `is on the <t:${unix}:d>\r\n<t:${unix}:R>`
|
||||||
|
if(isToday(found.day, found.month)){
|
||||||
|
description = `IS TODAY!🥳🎉`
|
||||||
|
}
|
||||||
|
const embed = new EmbedBuilder()
|
||||||
|
.setThumbnail(target.displayAvatarURL())
|
||||||
|
.setTitle(`${target.globalName ? target.globalName: target.username}'s Birthday!`)
|
||||||
|
.setDescription(description)
|
||||||
|
await interaction.reply({ embeds: [embed] })
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
data: new SlashCommandBuilder()
|
||||||
|
.setName('birthday')
|
||||||
|
.setDescription('manage birthdays')
|
||||||
|
.addSubcommand(s =>
|
||||||
|
s
|
||||||
|
.setName('add')
|
||||||
|
.setDescription('adds a birthday')
|
||||||
|
.addUserOption((option) =>
|
||||||
|
option
|
||||||
|
.setName('user')
|
||||||
|
.setDescription('user')
|
||||||
|
.setRequired(true))
|
||||||
|
.addNumberOption((option) =>
|
||||||
|
option
|
||||||
|
.setName('day')
|
||||||
|
.setDescription('day')
|
||||||
|
.setMinValue(1)
|
||||||
|
.setMaxValue(31)
|
||||||
|
.setRequired(true))
|
||||||
|
.addNumberOption((option) =>
|
||||||
|
option
|
||||||
|
.setName('month')
|
||||||
|
.setDescription('month')
|
||||||
|
.setMinValue(1)
|
||||||
|
.setMaxValue(12)
|
||||||
|
.setRequired(true))
|
||||||
|
)
|
||||||
|
.addSubcommand(s =>
|
||||||
|
s
|
||||||
|
.setName('delete')
|
||||||
|
.setDescription('deletes a birthday')
|
||||||
|
.addUserOption((option) =>
|
||||||
|
option.setName('user').setDescription('user'))
|
||||||
|
.addStringOption((option) =>
|
||||||
|
option.setName('id').setDescription('ID')))
|
||||||
|
.addSubcommand(s =>
|
||||||
|
s
|
||||||
|
.setName('edit')
|
||||||
|
.setDescription('edits a birthday')
|
||||||
|
.addUserOption((option) =>
|
||||||
|
option.setName('user').setDescription('user').setRequired(true))
|
||||||
|
.addNumberOption((option) =>
|
||||||
|
option.setName('day').setDescription('day').setRequired(true))
|
||||||
|
.addNumberOption((option) =>
|
||||||
|
option.setName('month').setDescription('month').setRequired(true)))
|
||||||
|
.addSubcommand(s =>
|
||||||
|
s
|
||||||
|
.setName('get')
|
||||||
|
.setDescription('gets a birthday')
|
||||||
|
.addUserOption((option) =>
|
||||||
|
option.setName('user').setDescription('user').setRequired(true))),
|
||||||
|
async execute(interaction) {
|
||||||
|
switch (interaction.options._subcommand) {
|
||||||
|
case 'add':
|
||||||
|
if (!interaction.member.permissions.has("ADMINISTRATOR")) {
|
||||||
|
return await interaction.reply({
|
||||||
|
content: "Unprivileged Access!",
|
||||||
|
ephemeral: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
birthdayAdd(interaction)
|
||||||
|
break;
|
||||||
|
case 'delete':
|
||||||
|
if (!interaction.member.permissions.has("ADMINISTRATOR")) {
|
||||||
|
return await interaction.reply({
|
||||||
|
content: "Unprivileged Access!",
|
||||||
|
ephemeral: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
birthdayDelete(interaction)
|
||||||
|
break;
|
||||||
|
case 'edit':
|
||||||
|
if (!interaction.member.permissions.has("ADMINISTRATOR")) {
|
||||||
|
return await interaction.reply({
|
||||||
|
content: "Unprivileged Access!",
|
||||||
|
ephemeral: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
birthdayEdit(interaction)
|
||||||
|
break;
|
||||||
|
case 'get':
|
||||||
|
birthdayGet(interaction)
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
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
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
const { createCanvas, loadImage } = require('canvas');
|
||||||
|
const path = require('node:path');
|
||||||
|
const { mClient } = require('..');
|
||||||
|
require('dotenv').configDotenv();
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "Birthday",
|
||||||
|
once: false,
|
||||||
|
async execute(member, client) {
|
||||||
|
console.log(`${member.user.username} hat Geburtstag!`)
|
||||||
|
|
||||||
|
|
||||||
|
const db = mClient.db(process.env.DB)
|
||||||
|
const channelsColl = db.collection('channels')
|
||||||
|
const found = await channelsColl.find(
|
||||||
|
{
|
||||||
|
$and: [
|
||||||
|
{ guildID: member.guild.id },
|
||||||
|
{ purpose: 'birthday' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
).toArray()
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
return console.log('Channel not yet set for birthday!')
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const guild = client.guilds.cache.get(found[0].guildID);
|
||||||
|
const channel = guild.channels.cache.get(found[0].channelID);
|
||||||
|
|
||||||
|
const roleID = '702877228857557002'
|
||||||
|
const role = guild.roles.cache.get(roleID)
|
||||||
|
|
||||||
|
try {
|
||||||
|
await member.roles.add(role)
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
}
|
||||||
|
// 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/bdbanner.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 = '#FFC0CB'; // Pink text
|
||||||
|
ctx.strokeStyle = '#000000'; // Black outline
|
||||||
|
ctx.lineWidth = 3; // Thickness of the outline
|
||||||
|
|
||||||
|
let text = `Alles Gute zum Geburtstag! `;
|
||||||
|
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 = `🥳 ${member.user.globalName ? member.user.globalName : member.user.username} 🎉`;
|
||||||
|
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: `@here`,
|
||||||
|
files: [{
|
||||||
|
attachment: banner,
|
||||||
|
name: 'banner.png',
|
||||||
|
description: 'a birthday banner'
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
+36
-1
@@ -1,4 +1,5 @@
|
|||||||
const { Events, ActivityType } = require('discord.js')
|
const { Events, ActivityType } = require('discord.js');
|
||||||
|
const { mClient } = require('..');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: Events.ClientReady,
|
name: Events.ClientReady,
|
||||||
@@ -13,5 +14,39 @@ module.exports = {
|
|||||||
}],
|
}],
|
||||||
status: 'online'
|
status: 'online'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// if today is birthday
|
||||||
|
function isToday(day, month) {
|
||||||
|
const currentYear = new Date().getFullYear();
|
||||||
|
const inputDate = new Date(currentYear, month - 1, day);
|
||||||
|
const today = new Date();
|
||||||
|
return (
|
||||||
|
inputDate.getDate() === today.getDate() &&
|
||||||
|
inputDate.getMonth() === today.getMonth() &&
|
||||||
|
inputDate.getFullYear() === today.getFullYear()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
async function isBirthday() {
|
||||||
|
const db = mClient.db(process.env.M_DB)
|
||||||
|
const bdayColl = db.collection('birthdays')
|
||||||
|
const allBirthdays = await bdayColl.find().toArray()
|
||||||
|
for (let index = 0; index < allBirthdays.length; index++) {
|
||||||
|
if (isToday(allBirthdays[index].day, allBirthdays[index].month)) {
|
||||||
|
let guild = client.guilds.cache.get(process.env.D_GuildID)
|
||||||
|
let member = guild.members.cache.get(allBirthdays[index].userID)
|
||||||
|
client.emit('Birthday', member)
|
||||||
|
} else {
|
||||||
|
// remove any residual birthday roles
|
||||||
|
try {
|
||||||
|
let guild = client.guilds.cache.get(process.env.D_GuildID)
|
||||||
|
let member = guild.members.cache.get(allBirthdays[index].userID)
|
||||||
|
await member.roles.remove('702877228857557002')
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Could not remove role', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
isBirthday()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,32 @@
|
|||||||
const { Events } = require('discord.js');
|
const { Events } = require('discord.js');
|
||||||
const { createCanvas, loadImage } = require('canvas');
|
const { createCanvas, loadImage } = require('canvas');
|
||||||
const path = require('node:path');
|
const path = require('node:path');
|
||||||
|
const { mClient } = require('..');
|
||||||
require('dotenv').configDotenv();
|
require('dotenv').configDotenv();
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: Events.GuildMemberAdd,
|
name: Events.GuildMemberAdd,
|
||||||
once: false,
|
once: false,
|
||||||
async execute(member, client) {
|
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`);
|
console.log(`${member.user.username} joined the Server`);
|
||||||
|
const db = mClient.db(process.env.DB)
|
||||||
|
const channelsColl = db.collection('channels')
|
||||||
|
const found = await channelsColl.find(
|
||||||
|
{
|
||||||
|
$and: [
|
||||||
|
{ guildID: member.guild.id },
|
||||||
|
{ purpose: 'welcome' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
).toArray()
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
return console.log('Channel not yet set for welcome!')
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const guild = client.guilds.cache.get(found[0].guildID);
|
||||||
|
const channel = guild.channels.cache.get(found[0].channelID);
|
||||||
|
|
||||||
// Create Canvas
|
// Create Canvas
|
||||||
let canvasWidth = 600;
|
let canvasWidth = 600;
|
||||||
@@ -44,7 +61,7 @@ module.exports = {
|
|||||||
ctx.strokeStyle = '#000000'; // Black outline
|
ctx.strokeStyle = '#000000'; // Black outline
|
||||||
ctx.lineWidth = 3; // Thickness of the outline
|
ctx.lineWidth = 3; // Thickness of the outline
|
||||||
|
|
||||||
let text = `Willkommen, ${member.user.username}!`;
|
let text = `Willkommen, ${member.user.globalName?member.user.globalName:member.user.username}!`;
|
||||||
let textWidth = ctx.measureText(text).width;
|
let textWidth = ctx.measureText(text).width;
|
||||||
let textX = canvas.width / 2 - textWidth / 2;
|
let textX = canvas.width / 2 - textWidth / 2;
|
||||||
let textHeight = 35; // Approximate height of the text
|
let textHeight = 35; // Approximate height of the text
|
||||||
@@ -63,10 +80,8 @@ module.exports = {
|
|||||||
ctx.strokeText(text, textX, 100 + pfp.height);
|
ctx.strokeText(text, textX, 100 + pfp.height);
|
||||||
ctx.fillText(text, textX, 100 + pfp.height);
|
ctx.fillText(text, textX, 100 + pfp.height);
|
||||||
|
|
||||||
const banner = canvas.toBuffer();
|
|
||||||
|
|
||||||
channel.send({
|
channel.send({
|
||||||
content: `Bitte guck einmal in die <#850491176540700703> ${member}`,
|
content: `Bitte guck einmal in die <#455023824791011338> ${member}`,
|
||||||
files: [{
|
files: [{
|
||||||
attachment: banner,
|
attachment: banner,
|
||||||
name: 'banner.png',
|
name: 'banner.png',
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const client = new Client({
|
|||||||
GatewayIntentBits.GuildMessageReactions,
|
GatewayIntentBits.GuildMessageReactions,
|
||||||
GatewayIntentBits.GuildVoiceStates,
|
GatewayIntentBits.GuildVoiceStates,
|
||||||
GatewayIntentBits.DirectMessages,
|
GatewayIntentBits.DirectMessages,
|
||||||
GatewayIntentBits.MessageContent
|
GatewayIntentBits.MessageContent,
|
||||||
],
|
],
|
||||||
partials: [Partials.Channel, Partials.Message, Partials.User, Partials.GuildMember, Partials.Reaction]
|
partials: [Partials.Channel, Partials.Message, Partials.User, Partials.GuildMember, Partials.Reaction]
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -38,7 +38,9 @@ module.exports = {
|
|||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setTitle('Nuts Leaderboard')
|
.setTitle('Nuts Leaderboard')
|
||||||
.setThumbnail('https://cdn.discordapp.com/attachments/1152723542836772914/1152940755539722240/pngwing.com.png')
|
.setThumbnail('https://cdn.discordapp.com/attachments/1152723542836772914/1152940755539722240/pngwing.com.png')
|
||||||
.setDescription(fields.toString());
|
.setDescription(fields.toString())
|
||||||
|
.setColor('#5865F2') // Discord's blurple color
|
||||||
|
.setFooter({ text: 'Use ◄ ► to navigate' });
|
||||||
await message.reply({
|
await message.reply({
|
||||||
embeds: [embed],
|
embeds: [embed],
|
||||||
components: [row]
|
components: [row]
|
||||||
|
|||||||
Reference in New Issue
Block a user