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 let description = interaction.message.embeds[0].data.description
const target = await interaction.guild.members.fetch(description.split(' ')[0].slice(2, -1)) const target = await interaction.guild.members.fetch(description.split(' ')[0].slice(2, -1))
const db = mClient.db(process.env.M_DB) 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 reason = `[-] Quick Menu Dishonor`
const theirHonorLevel = await honorsColl.findOne({ userID: target.id }) 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 let description = interaction.message.embeds[0].data.description
const target = await interaction.guild.members.fetch(description.split(' ')[0].slice(2, -1)) const target = await interaction.guild.members.fetch(description.split(' ')[0].slice(2, -1))
const db = mClient.db(process.env.M_DB) 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 history = await reasonsColl.findOne({ userID: target.user.id })
const embed = new EmbedBuilder() const embed = new EmbedBuilder()
+1 -1
View File
@@ -9,7 +9,7 @@ module.exports = {
let description = interaction.message.embeds[0].data.description let description = interaction.message.embeds[0].data.description
const target = await interaction.guild.members.fetch(description.split(' ')[0].slice(2, -1)) const target = await interaction.guild.members.fetch(description.split(' ')[0].slice(2, -1))
const db = mClient.db(process.env.M_DB) 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 reason = `[+] Quick Menu Honor`
const theirHonorLevel = await honorsColl.findOne({ userID: target.id }) 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 reason = `${temp[1].slice(7, -1)}`
const db = mClient.db(process.env.M_DB) const db = mClient.db(process.env.M_DB)
const honorsColl = db.collection('honors') const honorsColl = db.collection('items_honors')
const reasonsColl = db.collection('honor-reasons') const reasonsColl = db.collection('history_honors')
const theirHonorLevel = await honorsColl.findOne({ userID: target.id }) const theirHonorLevel = await honorsColl.findOne({ userID: target.id })
await honorsColl.findOneAndUpdate({ userID: target.id }, { $inc: { honors: honor } }, { upsert: true }) 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', description: 'navigate a page up',
async execute(interaction) { async execute(interaction) {
const db = mClient.db(process.env.M_DB) const db = mClient.db(process.env.M_DB)
const honorsColl = db.collection('honors') const honorsColl = db.collection('items_honors')
const min = 0 const min = 0
let skip = interaction.message.embeds[0].data.description.split('.') let skip = interaction.message.embeds[0].data.description.split('.')
skip = Number(skip[0]) - 6 skip = Number(skip[0]) - 6
+1 -1
View File
@@ -6,7 +6,7 @@ module.exports = {
description: 'navigate a page down', description: 'navigate a page down',
async execute(interaction) { async execute(interaction) {
const db = mClient.db(process.env.M_DB) const db = mClient.db(process.env.M_DB)
const honorsColl = db.collection('honors') const honorsColl = db.collection('items_honors')
const max = await honorsColl.countDocuments() const max = await honorsColl.countDocuments()
let skip = interaction.message.embeds[0].data.description.split('.') let skip = interaction.message.embeds[0].data.description.split('.')
skip = Number(skip[0]) +4 skip = Number(skip[0]) +4
+1 -1
View File
@@ -6,7 +6,7 @@ module.exports = {
description: 'navigate to your own placement', description: 'navigate to your own placement',
async execute(interaction) { async execute(interaction) {
const db = mClient.db(process.env.M_DB) 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 self = await honorsColl.find({ userID: interaction.user.id }).toArray()
const all = await honorsColl.find().sort({ honors: -1 }).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 to = await interaction.message.guild.members.fetch(temp[6].slice(2,-1))
const db = mClient.db(process.env.M_DB) 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: from.id }, { $inc: { nuts: -amount } }, { upsert: true })
await nutsColl.findOneAndUpdate({ userID: to.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 to = await interaction.message.guild.members.fetch(temp[6].slice(2,-1))
const db = mClient.db(process.env.M_DB) 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 yourBalance = await nutsColl.findOne({ userID: from.id })
const theirBalance = await nutsColl.findOne({ userID: to.id }) const theirBalance = await nutsColl.findOne({ userID: to.id })
+1 -1
View File
@@ -7,7 +7,7 @@ module.exports = {
description: 'navigate a page up', description: 'navigate a page up',
async execute(interaction) { async execute(interaction) {
const db = mClient.db(process.env.M_DB) const db = mClient.db(process.env.M_DB)
const nutsColl = db.collection('nuts') const nutsColl = db.collection('items_nuts')
const min = 0 const min = 0
let skip = interaction.message.embeds[0].data.description.split('.') let skip = interaction.message.embeds[0].data.description.split('.')
skip = Number(skip[0]) - 6 skip = Number(skip[0]) - 6
+1 -1
View File
@@ -6,7 +6,7 @@ module.exports = {
description: 'navigate a page down', description: 'navigate a page down',
async execute(interaction) { async execute(interaction) {
const db = mClient.db(process.env.M_DB) 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 } }) const max = await nutsColl.countDocuments({ nuts: { $gt: 0 } })
let skip = interaction.message.embeds[0].data.description.split('.') let skip = interaction.message.embeds[0].data.description.split('.')
skip = Number(skip[0]) +4 skip = Number(skip[0]) +4
+1 -1
View File
@@ -6,7 +6,7 @@ module.exports = {
description: 'navigate to your own placement', description: 'navigate to your own placement',
async execute(interaction) { async execute(interaction) {
const db = mClient.db(process.env.M_DB) 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 self = await nutsColl.find({ userID: interaction.user.id }).toArray()
const all = await nutsColl.find({ nuts: { $gt: 0 } }).sort({ nuts: -1 }).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) { async execute(interaction) {
await interaction.deferReply() await interaction.deferReply()
const db = mClient.db(process.env.M_DB) 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 } }] }) const maxValue = await quotesColl.countDocuments({ $and: [{ guildID: interaction.guild.id }, { count: { $gt: 0 } }] })
let skip = interaction.message.embeds[0].data.fields[0].value.split('.') let skip = interaction.message.embeds[0].data.fields[0].value.split('.')
+1 -1
View File
@@ -8,7 +8,7 @@ module.exports = {
async execute(interaction) { async execute(interaction) {
await interaction.deferReply() await interaction.deferReply()
const db = mClient.db(process.env.M_DB) 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 } }] }) const maxValue = await quotesColl.countDocuments({ $and: [{ guildID: interaction.guild.id }, { count: { $gt: 0 } }] })
let skip = interaction.message.embeds[0].data.fields[0].value.split('.') 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 }) } if (!target) { return interaction.reply({ content: 'Please use a Filter', ephemeral: true }) }
const db = mClient.db(process.env.M_DB) 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 quotes = await quotesColl.find({ by: target.id }).toArray()
var index = Number((await interaction.message.embeds[0].data.title).split(' ')[2].slice(1)) 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 }) } if (!target) { return interaction.reply({ content: 'Please use a Filter', ephemeral: true }) }
const db = mClient.db(process.env.M_DB) 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 quotes = await quotesColl.find({ by: target.id }).toArray()
var index = Number((await interaction.message.embeds[0].data.title).split(' ')[2].slice(1)) 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) { async function honorHoner(interaction) {
const db = mClient.db(process.env.M_DB) 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 target = await interaction.options.getUser('target')
const reason = `[+] ${await interaction.options.getString('reason') ?? 'No reason provided'}` const reason = `[+] ${await interaction.options.getString('reason') ?? 'No reason provided'}`
@@ -40,7 +40,7 @@ async function honorHoner(interaction) {
} }
async function honerDishonor(interaction) { async function honerDishonor(interaction) {
const db = mClient.db(process.env.M_DB) 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 target = await interaction.options.getUser('target')
const reason = `[-] ${await interaction.options.getString('reason') ?? 'No reason provided'}` const reason = `[-] ${await interaction.options.getString('reason') ?? 'No reason provided'}`
@@ -93,7 +93,7 @@ async function honorLeaderboard(interaction) {
.setCustomId('honors_leaderboard_right') .setCustomId('honors_leaderboard_right')
) )
const db = mClient.db(process.env.M_DB) const db = mClient.db(process.env.M_DB)
const honorsColl = db.collection('honors') const honorsColl = db.collection('items_honors')
let skip = 0 let skip = 0
const honorsData = await honorsColl.find({}).sort({ honors: -1 }).skip(skip).limit(5).toArray() const honorsData = await honorsColl.find({}).sort({ honors: -1 }).skip(skip).limit(5).toArray()
let fields let fields
@@ -116,7 +116,7 @@ async function honorHistory(interaction) {
var target = interaction.options.getUser('target') var target = interaction.options.getUser('target')
if (!target) { target = interaction.user } if (!target) { target = interaction.user }
const db = mClient.db(process.env.M_DB) 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 }) var history = await reasonsColl.findOne({ userID: target.id })
const embed = new EmbedBuilder() const embed = new EmbedBuilder()
@@ -136,7 +136,7 @@ async function honorCheck(interaction) {
var target = interaction.options.getUser('target') var target = interaction.options.getUser('target')
if (!target) { target = interaction.user } if (!target) { target = interaction.user }
const db = mClient.db(process.env.M_DB) 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 }) var honors = await honorsColl.findOne({ userID: target.id })
honors = honors?.honors ?? 0 honors = honors?.honors ?? 0
+7 -7
View File
@@ -39,7 +39,7 @@ async function nutsGive(interaction) {
var amount = await interaction.options.getNumber('amount') var amount = await interaction.options.getNumber('amount')
const db = mClient.db(process.env.M_DB) 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 yourBalance = await nutsColl.findOne({ userID: from.id })
const theirBalance = await nutsColl.findOne({ userID: to.id }) const theirBalance = await nutsColl.findOne({ userID: to.id })
if (amount <= 0) { if (amount <= 0) {
@@ -69,7 +69,7 @@ async function nutsCheck(interaction) {
} }
const db = mClient.db(process.env.M_DB) 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 }) const nutsData = await nutsColl.findOne({ userID: target.id })
let content let content
@@ -118,7 +118,7 @@ async function nutsLeaderboard(interaction) {
.setCustomId('nuts_leaderboard_right') .setCustomId('nuts_leaderboard_right')
) )
const db = mClient.db(process.env.M_DB) const db = mClient.db(process.env.M_DB)
const nutsColl = db.collection('nuts') const nutsColl = db.collection('items_nuts')
let skip = 0 let skip = 0
const nutsData = await nutsColl.find({ nuts: { $gt: 0 } }).sort({ nuts: -1 }).skip(skip).limit(5).toArray() const nutsData = await nutsColl.find({ nuts: { $gt: 0 } }).sort({ nuts: -1 }).skip(skip).limit(5).toArray()
let fields let fields
@@ -139,7 +139,7 @@ async function nutsLeaderboard(interaction) {
} }
async function nutsStats(interaction) { async function nutsStats(interaction) {
const db = mClient.db(process.env.M_DB) 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() const stats = await nStatsColl.find({}).sort({ amount: 1 }).toArray()
let nutMin = { let nutMin = {
count: 0, count: 0,
@@ -188,7 +188,7 @@ async function nutsStats(interaction) {
} }
async function nutsCooldown(interaction) { async function nutsCooldown(interaction) {
const db = mClient.db(process.env.M_DB) 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 }) const cooldown = await nutsColl.findOne({ userID: interaction.user.id })
let content = `Du kannst wieder nussen! :)` let content = `Du kannst wieder nussen! :)`
@@ -213,8 +213,8 @@ async function nutsCooldown(interaction) {
} }
async function nutsNut(interaction) { async function nutsNut(interaction) {
const db = mClient.db(process.env.M_DB) const db = mClient.db(process.env.M_DB)
const nutsColl = db.collection('nuts') const nutsColl = db.collection('items_nuts')
const cdColl = db.collection('cooldown') const cdColl = db.collection('items_cooldowns')
const cdData = await cdColl.findOne({ userID: interaction.user.id }) const cdData = await cdColl.findOne({ userID: interaction.user.id })
const embed = new EmbedBuilder() 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 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 }) const found = await quotesColl.findOne({ messageID: messageID })
if (found) { return await interaction.editReply({ content: 'Quote Already in Database', ephemeral: true }) } if (found) { return await interaction.editReply({ content: 'Quote Already in Database', ephemeral: true }) }
await quotesColl.findOneAndUpdate({ messageID: messageID }, { await quotesColl.findOneAndUpdate({ messageID: messageID }, {
@@ -87,7 +87,7 @@ async function quotesRemove(interaction) {
const id = await interaction.options.getString('id') const id = await interaction.options.getString('id')
const db = mClient.db(process.env.M_DB) 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 }) const found = await quotesColl.findOne({ messageID: id })
if (!found) { return await interaction.reply({ content: 'ID not found!', ephemeral: true }) } if (!found) { return await interaction.reply({ content: 'ID not found!', ephemeral: true }) }
@@ -98,7 +98,7 @@ async function quotesRemove(interaction) {
async function quotesSearch(interaction) { async function quotesSearch(interaction) {
const id = interaction.options.getString("id") const id = interaction.options.getString("id")
const db = mClient.db(process.env.M_DB) 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 }) const found = await quotesColl.findOne({ messageID: id })
if (!found) { return await interaction.reply({ content: 'ID not found!', ephemeral: true }) } if (!found) { return await interaction.reply({ content: 'ID not found!', ephemeral: true }) }
@@ -158,7 +158,7 @@ async function quotesSearch(interaction) {
async function quotesRandom(interaction) { async function quotesRandom(interaction) {
var user = interaction.options.getUser("by") var user = interaction.options.getUser("by")
const db = mClient.db(process.env.M_DB) const db = mClient.db(process.env.M_DB)
const quotesColl = db.collection('quotes') const quotesColl = db.collection('items_quotes')
var rdm var rdm
if (user) { if (user) {
rdm = await quotesColl.aggregate([ rdm = await quotesColl.aggregate([
@@ -269,7 +269,7 @@ async function quotesList(interaction) {
} }
async function quotesLeaderboard(interaction) { async function quotesLeaderboard(interaction) {
const db = mClient.db(process.env.M_DB) const db = mClient.db(process.env.M_DB)
const quotesColl = db.collection('quotes') const quotesColl = db.collection('items_quotes')
let skip = 0 let skip = 0
const minValue = 0 const minValue = 0
const maxValue = await quotesColl.countDocuments({ $and: [{ guildID: interaction.guild.id }, { count: { $gt: 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 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 }) const found = await bdayColl.findOne({ userID: target.id })
if (found) { if (found) {
@@ -77,7 +77,7 @@ async function birthdayDelete(interaction) {
} }
const db = mClient.db(process.env.M_DB) 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 }) const found = await bdayColl.findOne({ userID: target.id })
if (!found) { if (!found) {
@@ -102,7 +102,7 @@ async function birthdayEdit(interaction) {
} }
const db = mClient.db(process.env.M_DB) 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 }) const found = await bdayColl.findOne({ userID: target.id })
if (!found) { if (!found) {
@@ -143,7 +143,7 @@ function isToday(day, month) {
async function birthdayGet(interaction) { async function birthdayGet(interaction) {
let target = await interaction.options.getUser('user') let target = await interaction.options.getUser('user')
const db = mClient.db(process.env.M_DB) 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 }) const found = await bdayColl.findOne({ userID: target.id })
if (!found) { if (!found) {
+12 -10
View File
@@ -8,11 +8,11 @@ module.exports = {
once: false, once: false,
async execute(member, client) { async execute(member, client) {
console.log(`${member.user.username} hat Geburtstag!`) console.log(`${member.user.username} hat Geburtstag!`)
let found = null
const db = mClient.db(process.env.M_DB)
const db = mClient.db(process.env.DB) const channelsColl = db.collection('config_channels')
const channelsColl = db.collection('channels') found = await channelsColl.find(
const found = await channelsColl.find(
{ {
$and: [ $and: [
{ guildID: member.guild.id }, { guildID: member.guild.id },
@@ -25,12 +25,13 @@ module.exports = {
return console.log('Channel not yet set for birthday!') return console.log('Channel not yet set for birthday!')
} }
const guild = client.guilds.cache.get(found[0].guildID); const guild = client.guilds.cache.get(found[0].guildID);
const channel = guild.channels.cache.get(found[0].channelID); const channel = guild.channels.cache.get(found[0].channelID);
const roleColl = db.collection('config_roles')
const roleID = '702877228857557002'
const role = guild.roles.cache.get(roleID) // 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 { try {
await member.roles.add(role) await member.roles.add(role)
@@ -79,8 +80,9 @@ module.exports = {
ctx.strokeText(text, textX, 60 + pfp.height); ctx.strokeText(text, textX, 60 + pfp.height);
ctx.fillText(text, textX, 60 + pfp.height); ctx.fillText(text, textX, 60 + pfp.height);
ctx.font = '30px sans-serif'; // requires apt-get install ttf-ancient-fonts
text = `🥳 ${member.user.globalName ? member.user.globalName : member.user.username} 🎉`; 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; textWidth = ctx.measureText(text).width;
textX = canvas.width / 2 - textWidth / 2; textX = canvas.width / 2 - textWidth / 2;
textHeight = 30; // Approximate height of the text textHeight = 30; // Approximate height of the text
+51 -31
View File
@@ -5,7 +5,9 @@ module.exports = {
name: Events.ClientReady, name: Events.ClientReady,
once: true, once: true,
async execute(client) { 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({ client.user.setPresence({
activities: [{ activities: [{
name: 'Red Dead Depression', name: 'Red Dead Depression',
@@ -13,40 +15,58 @@ module.exports = {
url: 'https://twitch.tv/desq_blocki' url: 'https://twitch.tv/desq_blocki'
}], }],
status: 'online' status: 'online'
}) });
// if today is birthday // Check if a date matches today
function isToday(day, month) { const isToday = (day, month) => {
const currentYear = new Date().getFullYear();
const inputDate = new Date(currentYear, month - 1, day);
const today = new Date(); const today = new Date();
return ( return today.getDate() === day && today.getMonth() === month - 1;
inputDate.getDate() === today.getDate() && };
inputDate.getMonth() === today.getMonth() &&
inputDate.getFullYear() === today.getFullYear() // Handle birthdays
); const handleBirthdays = async () => {
} const guild = await client.guilds.fetch(process.env.D_GuildID);
async function isBirthday() { const db = mClient.db(process.env.M_DB);
const db = mClient.db(process.env.M_DB)
const bdayColl = db.collection('birthdays') const bdayColl = db.collection('items_birthdays');
const allBirthdays = await bdayColl.find().toArray() const allBirthdays = await bdayColl.find().toArray();
for (let index = 0; index < allBirthdays.length; index++) { const bdayMap = new Map(allBirthdays.map(b => [b.userID, b]));
if (isToday(allBirthdays[index].day, allBirthdays[index].month)) {
let guild = client.guilds.cache.get(process.env.D_GuildID) // Fetch birthday role
let member = guild.members.cache.get(allBirthdays[index].userID) const bdayRoleColl = db.collection('config_roles');
client.emit('Birthday', member) 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 { } else {
// remove any residual birthday roles // Default fallback: remove birthday role if present
try { if (member.roles.cache.has(birthdayRoleID)) {
let guild = client.guilds.cache.get(process.env.D_GuildID) await member.roles.remove(birthdayRoleID).catch(err =>
let member = guild.members.cache.get(allBirthdays[index].userID) console.error(`Failed to remove birthday role from ${member.user.tag}:`, err)
await member.roles.remove('702877228857557002') );
} catch (error) { console.log(`Removed birthday role from ${member.user.tag} (not today or not in DB)`);
console.error('Could not remove role', error)
} }
} }
} }
} };
isBirthday()
await handleBirthdays();
} }
} };
+2 -2
View File
@@ -9,8 +9,8 @@ module.exports = {
once: false, once: false,
async execute(member, client) { async execute(member, client) {
console.log(`${member.user.username} joined the Server`); console.log(`${member.user.username} joined the Server`);
const db = mClient.db(process.env.DB) const db = mClient.db(process.env.M_DB)
const channelsColl = db.collection('channels') const channelsColl = db.collection('config_channels')
const found = await channelsColl.find( const found = await channelsColl.find(
{ {
$and: [ $and: [
+1 -1
View File
@@ -32,7 +32,7 @@ module.exports = {
} }
} }
const db = mClient.db(process.env.M_DB) 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 }) var nutsData = await nutsColl.findOne({ userID: target.id })
let content let content
+1 -1
View File
@@ -7,7 +7,7 @@ module.exports = {
aliases: ['ncd'], aliases: ['ncd'],
async execute(message, args) { async execute(message, args) {
const db = mClient.db(process.env.M_DB) 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 }) const cooldown = await nutsColl.findOne({ userID: message.author.id })
let content = `Du kannst wieder nussen! :)` let content = `Du kannst wieder nussen! :)`
+2 -2
View File
@@ -6,8 +6,8 @@ module.exports = {
aliases: ['n', 'nget', 'nutsget'], aliases: ['n', 'nget', 'nutsget'],
async execute(message, args) { async execute(message, args) {
const db = mClient.db(process.env.M_DB) const db = mClient.db(process.env.M_DB)
const nutsColl = db.collection('nuts') const nutsColl = db.collection('items_nuts')
const cdColl = db.collection('cooldown') const cdColl = db.collection('items_cooldowns')
const cdData = await cdColl.findOne({ userID: message.author.id }) 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 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 yourBalance = await nutsColl.findOne({ userID: from.id })
if (amount <= 0) { if (amount <= 0) {
return await message.reply({ return await message.reply({
+1 -1
View File
@@ -27,7 +27,7 @@ module.exports = {
.setCustomId('nuts_leaderboard_right') .setCustomId('nuts_leaderboard_right')
) )
const db = mClient.db(process.env.M_DB) const db = mClient.db(process.env.M_DB)
const nutsColl = db.collection('nuts') const nutsColl = db.collection('items_nuts')
let skip = 0 let skip = 0
const nutsData = await nutsColl.find({ nuts: { $gt: 0 } }).sort({ nuts: -1 }).skip(skip).limit(5).toArray() const nutsData = await nutsColl.find({ nuts: { $gt: 0 } }).sort({ nuts: -1 }).skip(skip).limit(5).toArray()
let fields let fields
+1 -1
View File
@@ -8,7 +8,7 @@ module.exports = {
aliases: ['nstat', 'ns'], aliases: ['nstat', 'ns'],
async execute(message, args) { async execute(message, args) {
const db = mClient.db(process.env.M_DB) 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() const stats = await nStatsColl.find({}).sort({ amount: 1 }).toArray()
let nutMin = { let nutMin = {
count: 0, count: 0,
+1 -1
View File
@@ -15,7 +15,7 @@ module.exports = {
} else { } else {
var target = await interaction.guild.members.fetch(interaction.members.keys().next().value) var target = await interaction.guild.members.fetch(interaction.members.keys().next().value)
var db = mClient.db(process.env.M_DB) 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 }) var theirHonorLevel = await honorsColl.findOne({ userID: target.id })
const member = interaction.message.guild.members.cache.get(target.user.id) const member = interaction.message.guild.members.cache.get(target.user.id)
@@ -15,7 +15,7 @@ module.exports = {
} else { } else {
const target = await interaction.guild.members.fetch(interaction.members.keys().next().value) const target = await interaction.guild.members.fetch(interaction.members.keys().next().value)
const db = mClient.db(process.env.M_DB) 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 quotes = await quotesColl.find({ by: target.id }).toArray()
const member = interaction.message.guild.members.cache.get(target.user.id) const member = interaction.message.guild.members.cache.get(target.user.id)
const memberRoles = member.roles.cache const memberRoles = member.roles.cache