fixed Birthday Event, Renamed DB Colls

This commit is contained in:
2026-04-06 15:47:54 +02:00
parent ea18387c75
commit 0769a482fb
33 changed files with 281 additions and 196 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ module.exports = {
let description = interaction.message.embeds[0].data.description
const target = await interaction.guild.members.fetch(description.split(' ')[0].slice(2, -1))
const db = mClient.db(process.env.M_DB)
const honorsColl = db.collection('honors')
const honorsColl = db.collection('items_honors')
const reason = `[-] Quick Menu Dishonor`
const theirHonorLevel = await honorsColl.findOne({ userID: target.id })
+1 -1
View File
@@ -9,7 +9,7 @@ module.exports = {
let description = interaction.message.embeds[0].data.description
const target = await interaction.guild.members.fetch(description.split(' ')[0].slice(2, -1))
const db = mClient.db(process.env.M_DB)
const reasonsColl = db.collection('honor-reasons')
const reasonsColl = db.collection('history_honors')
const history = await reasonsColl.findOne({ userID: target.user.id })
const embed = new EmbedBuilder()
+1 -1
View File
@@ -9,7 +9,7 @@ module.exports = {
let description = interaction.message.embeds[0].data.description
const target = await interaction.guild.members.fetch(description.split(' ')[0].slice(2, -1))
const db = mClient.db(process.env.M_DB)
const honorsColl = db.collection('honors')
const honorsColl = db.collection('items_honors')
const reason = `[+] Quick Menu Honor`
const theirHonorLevel = await honorsColl.findOne({ userID: target.id })
+2 -2
View File
@@ -20,8 +20,8 @@ module.exports = {
const reason = `${temp[1].slice(7, -1)}`
const db = mClient.db(process.env.M_DB)
const honorsColl = db.collection('honors')
const reasonsColl = db.collection('honor-reasons')
const honorsColl = db.collection('items_honors')
const reasonsColl = db.collection('history_honors')
const theirHonorLevel = await honorsColl.findOne({ userID: target.id })
await honorsColl.findOneAndUpdate({ userID: target.id }, { $inc: { honors: honor } }, { upsert: true })
+1 -1
View File
@@ -7,7 +7,7 @@ module.exports = {
description: 'navigate a page up',
async execute(interaction) {
const db = mClient.db(process.env.M_DB)
const honorsColl = db.collection('honors')
const honorsColl = db.collection('items_honors')
const min = 0
let skip = interaction.message.embeds[0].data.description.split('.')
skip = Number(skip[0]) - 6
+1 -1
View File
@@ -6,7 +6,7 @@ module.exports = {
description: 'navigate a page down',
async execute(interaction) {
const db = mClient.db(process.env.M_DB)
const honorsColl = db.collection('honors')
const honorsColl = db.collection('items_honors')
const max = await honorsColl.countDocuments()
let skip = interaction.message.embeds[0].data.description.split('.')
skip = Number(skip[0]) +4
+1 -1
View File
@@ -6,7 +6,7 @@ module.exports = {
description: 'navigate to your own placement',
async execute(interaction) {
const db = mClient.db(process.env.M_DB)
const honorsColl = db.collection('honors')
const honorsColl = db.collection('items_honors')
const self = await honorsColl.find({ userID: interaction.user.id }).toArray()
const all = await honorsColl.find().sort({ honors: -1 }).toArray()
+1 -1
View File
@@ -12,7 +12,7 @@ module.exports = {
const to = await interaction.message.guild.members.fetch(temp[6].slice(2,-1))
const db = mClient.db(process.env.M_DB)
const nutsColl = db.collection('nuts')
const nutsColl = db.collection('items_nuts')
await nutsColl.findOneAndUpdate({ userID: from.id }, { $inc: { nuts: -amount } }, { upsert: true })
await nutsColl.findOneAndUpdate({ userID: to.id }, { $inc: { nuts: +amount } }, { upsert: true })
+1 -1
View File
@@ -10,7 +10,7 @@ module.exports = {
const to = await interaction.message.guild.members.fetch(temp[6].slice(2,-1))
const db = mClient.db(process.env.M_DB)
const nutsColl = db.collection('nuts')
const nutsColl = db.collection('items_nuts')
const yourBalance = await nutsColl.findOne({ userID: from.id })
const theirBalance = await nutsColl.findOne({ userID: to.id })
+1 -1
View File
@@ -7,7 +7,7 @@ module.exports = {
description: 'navigate a page up',
async execute(interaction) {
const db = mClient.db(process.env.M_DB)
const nutsColl = db.collection('nuts')
const nutsColl = db.collection('items_nuts')
const min = 0
let skip = interaction.message.embeds[0].data.description.split('.')
skip = Number(skip[0]) - 6
+1 -1
View File
@@ -6,7 +6,7 @@ module.exports = {
description: 'navigate a page down',
async execute(interaction) {
const db = mClient.db(process.env.M_DB)
const nutsColl = db.collection('nuts')
const nutsColl = db.collection('items_nuts')
const max = await nutsColl.countDocuments({ nuts: { $gt: 0 } })
let skip = interaction.message.embeds[0].data.description.split('.')
skip = Number(skip[0]) +4
+1 -1
View File
@@ -6,7 +6,7 @@ module.exports = {
description: 'navigate to your own placement',
async execute(interaction) {
const db = mClient.db(process.env.M_DB)
const nutsColl = db.collection('nuts')
const nutsColl = db.collection('items_nuts')
const self = await nutsColl.find({ userID: interaction.user.id }).toArray()
const all = await nutsColl.find({ nuts: { $gt: 0 } }).sort({ nuts: -1 }).toArray()
+1 -1
View File
@@ -8,7 +8,7 @@ module.exports = {
async execute(interaction) {
await interaction.deferReply()
const db = mClient.db(process.env.M_DB)
const quotesColl = db.collection('quotes')
const quotesColl = db.collection('items_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('.')
+1 -1
View File
@@ -8,7 +8,7 @@ module.exports = {
async execute(interaction) {
await interaction.deferReply()
const db = mClient.db(process.env.M_DB)
const quotesColl = db.collection('quotes')
const quotesColl = db.collection('items_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('.')
+1 -1
View File
@@ -14,7 +14,7 @@ module.exports = {
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 quotesColl = db.collection('items_quotes')
const quotes = await quotesColl.find({ by: target.id }).toArray()
var index = Number((await interaction.message.embeds[0].data.title).split(' ')[2].slice(1))
+1 -1
View File
@@ -14,7 +14,7 @@ module.exports = {
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 quotesColl = db.collection('items_quotes')
const quotes = await quotesColl.find({ by: target.id }).toArray()
var index = Number((await interaction.message.embeds[0].data.title).split(' ')[2].slice(1))
-106
View File
@@ -1,106 +0,0 @@
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;
}
}
}
+169
View File
@@ -0,0 +1,169 @@
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.M_DB)
const channelColl = db.collection('config_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 })
}
async function roleSet(interaction) {
const guild = interaction.guild
const purpose = interaction.options.getString('purpose')
const role = interaction.options.getRole('role')
const db = mClient.db(process.env.M_DB)
const roleColl = db.collection('config_roles')
switch (purpose) {
case 'birthday':
await roleColl.findOneAndUpdate({
$and: [{ guildID: guild.id }, { purpose: purpose }]
}, {
$set: {
guildID: guild.id,
purpose: purpose,
roleID: role.id
}
}, {
upsert: true
})
break;
default:
break;
}
return await interaction.editReply({
content: `Set ${role} as default role for ${purpose} in ${guild} `
})
}
module.exports = {
data: new SlashCommandBuilder()
.setName('config')
.setDescription('configurations for admins')
.addSubcommandGroup(sg =>
sg
.setName('channels')
.setDescription('configure channels for certain events')
.addSubcommand(s =>
s.setName('set')
.setDescription('sets channel')
.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'
}))
)
)
.addSubcommandGroup(sg =>
sg.setName('roles')
.setDescription('configure roles for certain events')
.addSubcommand(s =>
s.setName('set')
.setDescription('sets roles')
.addStringOption(o =>
o.setName('purpose').setDescription('set the purpose').setRequired(true).addChoices({
name: 'birthday',
value: 'birthday'
}))
.addRoleOption(c =>
c.setName('role').setDescription('choose a role').setRequired(true)
)
)
),
async execute(interaction) {
switch (interaction.options._group) {
case 'channels':
switch (interaction.options._subcommand) {
case 'set':
await interaction.deferReply()
channelSet(interaction)
break;
case 'simulate':
channelSimulate(interaction)
break;
default:
break;
}
case 'roles':
switch (interaction.options._subcommand) {
case 'set':
await interaction.deferReply()
roleSet(interaction)
break;
default:
break;
}
default:
break;
}
}
}
+5 -5
View File
@@ -5,7 +5,7 @@ function delay(ms) { return new Promise(resolve => setTimeout(resolve, ms)); }
async function honorHoner(interaction) {
const db = mClient.db(process.env.M_DB)
const honorsColl = db.collection('honors')
const honorsColl = db.collection('items_honors')
const target = await interaction.options.getUser('target')
const reason = `[+] ${await interaction.options.getString('reason') ?? 'No reason provided'}`
@@ -40,7 +40,7 @@ async function honorHoner(interaction) {
}
async function honerDishonor(interaction) {
const db = mClient.db(process.env.M_DB)
const honorsColl = db.collection('honors')
const honorsColl = db.collection('items_honors')
const target = await interaction.options.getUser('target')
const reason = `[-] ${await interaction.options.getString('reason') ?? 'No reason provided'}`
@@ -93,7 +93,7 @@ async function honorLeaderboard(interaction) {
.setCustomId('honors_leaderboard_right')
)
const db = mClient.db(process.env.M_DB)
const honorsColl = db.collection('honors')
const honorsColl = db.collection('items_honors')
let skip = 0
const honorsData = await honorsColl.find({}).sort({ honors: -1 }).skip(skip).limit(5).toArray()
let fields
@@ -116,7 +116,7 @@ async function honorHistory(interaction) {
var target = interaction.options.getUser('target')
if (!target) { target = interaction.user }
const db = mClient.db(process.env.M_DB)
const reasonsColl = db.collection('honor-reasons')
const reasonsColl = db.collection('history_honors')
var history = await reasonsColl.findOne({ userID: target.id })
const embed = new EmbedBuilder()
@@ -136,7 +136,7 @@ async function honorCheck(interaction) {
var target = interaction.options.getUser('target')
if (!target) { target = interaction.user }
const db = mClient.db(process.env.M_DB)
const honorsColl = db.collection('honors')
const honorsColl = db.collection('items_honors')
var honors = await honorsColl.findOne({ userID: target.id })
honors = honors?.honors ?? 0
+7 -7
View File
@@ -39,7 +39,7 @@ async function nutsGive(interaction) {
var amount = await interaction.options.getNumber('amount')
const db = mClient.db(process.env.M_DB)
const nutsColl = db.collection('nuts')
const nutsColl = db.collection('items_nuts')
const yourBalance = await nutsColl.findOne({ userID: from.id })
const theirBalance = await nutsColl.findOne({ userID: to.id })
if (amount <= 0) {
@@ -69,7 +69,7 @@ async function nutsCheck(interaction) {
}
const db = mClient.db(process.env.M_DB)
const nutsColl = db.collection('nuts')
const nutsColl = db.collection('items_nuts')
const nutsData = await nutsColl.findOne({ userID: target.id })
let content
@@ -118,7 +118,7 @@ async function nutsLeaderboard(interaction) {
.setCustomId('nuts_leaderboard_right')
)
const db = mClient.db(process.env.M_DB)
const nutsColl = db.collection('nuts')
const nutsColl = db.collection('items_nuts')
let skip = 0
const nutsData = await nutsColl.find({ nuts: { $gt: 0 } }).sort({ nuts: -1 }).skip(skip).limit(5).toArray()
let fields
@@ -139,7 +139,7 @@ async function nutsLeaderboard(interaction) {
}
async function nutsStats(interaction) {
const db = mClient.db(process.env.M_DB)
const nStatsColl = db.collection('nut-stats')
const nStatsColl = db.collection('stats_nuts')
const stats = await nStatsColl.find({}).sort({ amount: 1 }).toArray()
let nutMin = {
count: 0,
@@ -188,7 +188,7 @@ async function nutsStats(interaction) {
}
async function nutsCooldown(interaction) {
const db = mClient.db(process.env.M_DB)
const nutsColl = db.collection('cooldown')
const nutsColl = db.collection('items_cooldowns')
const cooldown = await nutsColl.findOne({ userID: interaction.user.id })
let content = `Du kannst wieder nussen! :)`
@@ -213,8 +213,8 @@ async function nutsCooldown(interaction) {
}
async function nutsNut(interaction) {
const db = mClient.db(process.env.M_DB)
const nutsColl = db.collection('nuts')
const cdColl = db.collection('cooldown')
const nutsColl = db.collection('items_nuts')
const cdColl = db.collection('items_cooldowns')
const cdData = await cdColl.findOne({ userID: interaction.user.id })
const embed = new EmbedBuilder()
+5 -5
View File
@@ -48,7 +48,7 @@ async function quotesAdd(interaction) {
}
const db = mClient.db(process.env.M_DB)
const quotesColl = db.collection('quotes')
const quotesColl = db.collection('items_quotes')
const found = await quotesColl.findOne({ messageID: messageID })
if (found) { return await interaction.editReply({ content: 'Quote Already in Database', ephemeral: true }) }
await quotesColl.findOneAndUpdate({ messageID: messageID }, {
@@ -87,7 +87,7 @@ async function quotesRemove(interaction) {
const id = await interaction.options.getString('id')
const db = mClient.db(process.env.M_DB)
const quotesColl = db.collection('quotes')
const quotesColl = db.collection('items_quotes')
const found = await quotesColl.findOne({ messageID: id })
if (!found) { return await interaction.reply({ content: 'ID not found!', ephemeral: true }) }
@@ -98,7 +98,7 @@ async function quotesRemove(interaction) {
async function quotesSearch(interaction) {
const id = interaction.options.getString("id")
const db = mClient.db(process.env.M_DB)
const quotesColl = db.collection('quotes')
const quotesColl = db.collection('items_quotes')
const found = await quotesColl.findOne({ messageID: id })
if (!found) { return await interaction.reply({ content: 'ID not found!', ephemeral: true }) }
@@ -158,7 +158,7 @@ async function quotesSearch(interaction) {
async function quotesRandom(interaction) {
var user = interaction.options.getUser("by")
const db = mClient.db(process.env.M_DB)
const quotesColl = db.collection('quotes')
const quotesColl = db.collection('items_quotes')
var rdm
if (user) {
rdm = await quotesColl.aggregate([
@@ -269,7 +269,7 @@ async function quotesList(interaction) {
}
async function quotesLeaderboard(interaction) {
const db = mClient.db(process.env.M_DB)
const quotesColl = db.collection('quotes')
const quotesColl = db.collection('items_quotes')
let skip = 0
const minValue = 0
const maxValue = await quotesColl.countDocuments({ $and: [{ guildID: interaction.guild.id }, { count: { $gt: 0 } }] })
+4 -4
View File
@@ -44,7 +44,7 @@ async function birthdayAdd(interaction) {
}
const db = mClient.db(process.env.M_DB)
const bdayColl = db.collection('birthdays')
const bdayColl = db.collection('items_birthdays')
const found = await bdayColl.findOne({ userID: target.id })
if (found) {
@@ -77,7 +77,7 @@ async function birthdayDelete(interaction) {
}
const db = mClient.db(process.env.M_DB)
const bdayColl = db.collection('birthdays')
const bdayColl = db.collection('items_birthdays')
const found = await bdayColl.findOne({ userID: target.id })
if (!found) {
@@ -102,7 +102,7 @@ async function birthdayEdit(interaction) {
}
const db = mClient.db(process.env.M_DB)
const bdayColl = db.collection('birthdays')
const bdayColl = db.collection('items_birthdays')
const found = await bdayColl.findOne({ userID: target.id })
if (!found) {
@@ -143,7 +143,7 @@ function isToday(day, month) {
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 bdayColl = db.collection('items_birthdays')
const found = await bdayColl.findOne({ userID: target.id })
if (!found) {
+12 -10
View File
@@ -8,11 +8,11 @@ module.exports = {
once: false,
async execute(member, client) {
console.log(`${member.user.username} hat Geburtstag!`)
let found = null
const db = mClient.db(process.env.DB)
const channelsColl = db.collection('channels')
const found = await channelsColl.find(
const db = mClient.db(process.env.M_DB)
const channelsColl = db.collection('config_channels')
found = await channelsColl.find(
{
$and: [
{ guildID: member.guild.id },
@@ -25,12 +25,13 @@ module.exports = {
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)
const roleColl = db.collection('config_roles')
// Bot Role MUST BE above birthday Role, Birthday Role MUST BE above user roles
found = await roleColl.findOne({guildID: member.guild.id})
const role = guild.roles.cache.get(found.roleID)
try {
await member.roles.add(role)
@@ -79,8 +80,9 @@ module.exports = {
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} 🎉`;
// requires apt-get install ttf-ancient-fonts
ctx.font = '30px "Noto Emoji", "Segoe UI Emoji", "Apple Color Emoji", 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
+51 -31
View File
@@ -5,7 +5,9 @@ module.exports = {
name: Events.ClientReady,
once: true,
async execute(client) {
console.log(`Ready! Logged in as ${client.user.tag}`)
console.log(`Ready! Logged in as ${client.user.tag}`);
// Set presence
client.user.setPresence({
activities: [{
name: 'Red Dead Depression',
@@ -13,40 +15,58 @@ module.exports = {
url: 'https://twitch.tv/desq_blocki'
}],
status: 'online'
})
});
// if today is birthday
function isToday(day, month) {
const currentYear = new Date().getFullYear();
const inputDate = new Date(currentYear, month - 1, day);
// Check if a date matches today
const isToday = (day, month) => {
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)
return today.getDate() === day && today.getMonth() === month - 1;
};
// Handle birthdays
const handleBirthdays = async () => {
const guild = await client.guilds.fetch(process.env.D_GuildID);
const db = mClient.db(process.env.M_DB);
const bdayColl = db.collection('items_birthdays');
const allBirthdays = await bdayColl.find().toArray();
const bdayMap = new Map(allBirthdays.map(b => [b.userID, b]));
// Fetch birthday role
const bdayRoleColl = db.collection('config_roles');
const bdayRoleEntry = await bdayRoleColl.findOne({ guildID: guild.id });
const birthdayRoleID = bdayRoleEntry.roleID;
if (!birthdayRoleID) {
console.warn("No birthday role configured in DB");
return;
}
// Fetch all guild members
const members = await guild.members.fetch();
for (const member of members.values()) {
const dbEntry = bdayMap.get(member.id);
if (dbEntry && isToday(dbEntry.day, dbEntry.month)) {
// Today is their birthday
await member.roles.add(birthdayRoleID).catch(err =>
console.error(`Failed to add birthday role to ${member.user.tag}:`, err)
);
console.log(`Added birthday role to ${member.user.tag}`);
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)
// Default fallback: remove birthday role if present
if (member.roles.cache.has(birthdayRoleID)) {
await member.roles.remove(birthdayRoleID).catch(err =>
console.error(`Failed to remove birthday role from ${member.user.tag}:`, err)
);
console.log(`Removed birthday role from ${member.user.tag} (not today or not in DB)`);
}
}
}
}
isBirthday()
};
await handleBirthdays();
}
}
};
+2 -2
View File
@@ -9,8 +9,8 @@ module.exports = {
once: false,
async execute(member, client) {
console.log(`${member.user.username} joined the Server`);
const db = mClient.db(process.env.DB)
const channelsColl = db.collection('channels')
const db = mClient.db(process.env.M_DB)
const channelsColl = db.collection('config_channels')
const found = await channelsColl.find(
{
$and: [
+1 -1
View File
@@ -32,7 +32,7 @@ module.exports = {
}
}
const db = mClient.db(process.env.M_DB)
const nutsColl = db.collection('nuts')
const nutsColl = db.collection('items_nuts')
var nutsData = await nutsColl.findOne({ userID: target.id })
let content
+1 -1
View File
@@ -7,7 +7,7 @@ module.exports = {
aliases: ['ncd'],
async execute(message, args) {
const db = mClient.db(process.env.M_DB)
const nutsColl = db.collection('cooldown')
const nutsColl = db.collection('items_cooldowns')
const cooldown = await nutsColl.findOne({ userID: message.author.id })
let content = `Du kannst wieder nussen! :)`
+2 -2
View File
@@ -6,8 +6,8 @@ module.exports = {
aliases: ['n', 'nget', 'nutsget'],
async execute(message, args) {
const db = mClient.db(process.env.M_DB)
const nutsColl = db.collection('nuts')
const cdColl = db.collection('cooldown')
const nutsColl = db.collection('items_nuts')
const cdColl = db.collection('items_cooldowns')
const cdData = await cdColl.findOne({ userID: message.author.id })
+1 -1
View File
@@ -48,7 +48,7 @@ module.exports = {
}
const db = mClient.db(process.env.M_DB)
const nutsColl = db.collection('nuts')
const nutsColl = db.collection('items_nuts')
const yourBalance = await nutsColl.findOne({ userID: from.id })
if (amount <= 0) {
return await message.reply({
+1 -1
View File
@@ -27,7 +27,7 @@ module.exports = {
.setCustomId('nuts_leaderboard_right')
)
const db = mClient.db(process.env.M_DB)
const nutsColl = db.collection('nuts')
const nutsColl = db.collection('items_nuts')
let skip = 0
const nutsData = await nutsColl.find({ nuts: { $gt: 0 } }).sort({ nuts: -1 }).skip(skip).limit(5).toArray()
let fields
+1 -1
View File
@@ -8,7 +8,7 @@ module.exports = {
aliases: ['nstat', 'ns'],
async execute(message, args) {
const db = mClient.db(process.env.M_DB)
const nStatsColl = db.collection('nut-stats')
const nStatsColl = db.collection('stats_nuts')
const stats = await nStatsColl.find({}).sort({ amount: 1 }).toArray()
let nutMin = {
count: 0,
+1 -1
View File
@@ -15,7 +15,7 @@ module.exports = {
} else {
var target = await interaction.guild.members.fetch(interaction.members.keys().next().value)
var db = mClient.db(process.env.M_DB)
var honorsColl = db.collection('honors')
var honorsColl = db.collection('items_honors')
var theirHonorLevel = await honorsColl.findOne({ userID: target.id })
const member = interaction.message.guild.members.cache.get(target.user.id)
@@ -15,7 +15,7 @@ module.exports = {
} 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 quotesColl = db.collection('items_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