Compare commits

...

2 Commits

Author SHA1 Message Date
admin_rb 11102fc3a5 WGE Implementation Basics 2026-06-08 20:57:52 +02:00
admin_rb 7bd44bd653 clean slate, birthday fix 2026-06-08 20:57:40 +02:00
15 changed files with 237 additions and 36 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ module.exports = {
})
const embed = new EmbedBuilder()
.setTitle('Honors Leaderboard')
.setThumbnail(guild.iconURL({ dynamic: true}))
.setThumbnail(interaction.guild.iconURL({ dynamic: true}))
.setDescription(fields.toString())
.setColor('#5865F2') // Discord's blurple color
.setFooter({ text: 'Use ◄ ► to navigate' });
+1 -1
View File
@@ -21,7 +21,7 @@ module.exports = {
})
const embed = new EmbedBuilder()
.setTitle('Honors Leaderboard')
.setThumbnail(guild.iconURL({ dynamic: true}))
.setThumbnail(interaction.guild.iconURL({ dynamic: true}))
.setDescription(fields.toString())
.setColor('#5865F2') // Discord's blurple color
.setFooter({ text: 'Use ◄ ► to navigate' });
+1 -1
View File
@@ -31,7 +31,7 @@ module.exports = {
})
const embed = new EmbedBuilder()
.setTitle('Honors Leaderboard')
.setThumbnail(guild.iconURL({ dynamic: true}))
.setThumbnail(interaction.guild.iconURL({ dynamic: true}))
.setDescription(fields.toString())
.setColor('#5865F2') // Discord's blurple color
.setFooter({ text: 'Use ◄ ► to navigate' });
+1 -1
View File
@@ -23,7 +23,7 @@ module.exports = {
})
const embed = new EmbedBuilder()
.setTitle('Nuts Leaderboard')
.setThumbnail(guild.iconURL({ dynamic: true}))
.setThumbnail(interaction.guild.iconURL({ dynamic: true}))
.setDescription(fields.toString())
.setColor('#5865F2') // Discord's blurple color
.setFooter({ text: 'Use ◄ ► to navigate' });
+1 -1
View File
@@ -21,7 +21,7 @@ module.exports = {
})
const embed = new EmbedBuilder()
.setTitle('Nuts Leaderboard')
.setThumbnail(guild.iconURL({ dynamic: true}))
.setThumbnail(interaction.guild.iconURL({ dynamic: true}))
.setDescription(fields.toString())
.setColor('#5865F2') // Discord's blurple color
.setFooter({ text: 'Use ◄ ► to navigate' });
+1 -1
View File
@@ -31,7 +31,7 @@ module.exports = {
})
const embed = new EmbedBuilder()
.setTitle('Nuts Leaderboard')
.setThumbnail(guild.iconURL({ dynamic: true}))
.setThumbnail(interaction.guild.iconURL({ dynamic: true}))
.setDescription(fields.toString())
.setColor('#5865F2') // Discord's blurple color
.setFooter({ text: 'Use ◄ ► to navigate' });
+7 -4
View File
@@ -50,12 +50,15 @@ module.exports = {
{ $inc: { [`stat.${amount}`]: 1 } },
{ upsert: true }
)
let content = `Du hast ${amount} Nüsse bekommen! :chestnut:`
if (!amount) {
content = `Du hast leider keine Nüsse bekommen :(`
// Helper for singular/plural
const formatNut = (amount) => `${amount === 1 ? 'eine' : amount} ${amount === 1 ? 'Nuss' : 'Nüsse'}`
let nutText = `Du hast ${formatNut(amount)} bekommen! :chestnut:`
if (amount <= 0) {
nutText = `Du hast keine Nuss bekommen! :yoink_help:`
}
return await message.reply({
content: content
content: nutText
})
}
}
+1 -1
View File
@@ -37,7 +37,7 @@ module.exports = {
})
const embed = new EmbedBuilder()
.setTitle('Nuts Leaderboard')
.setThumbnail(guild.iconURL({ dynamic: true}))
.setThumbnail(message.guild.iconURL({ dynamic: true}))
.setDescription(fields.toString())
.setColor('#5865F2') // Discord's blurple color
.setFooter({ text: 'Use ◄ ► to navigate' });
+2 -13
View File
@@ -1,4 +1,4 @@
const { SlashCommandBuilder, EmbedBuilder, MessageFlags } = require('discord.js')
const { SlashCommandBuilder, EmbedBuilder, MessageFlags, PermissionFlagsBits } = require('discord.js')
const { mClient } = require('../../../index')
const { configDotenv } = require('dotenv')
configDotenv()
@@ -144,6 +144,7 @@ module.exports = {
data: new SlashCommandBuilder()
.setName('birthday')
.setDescription('manage birthdays')
.setDefaultMemberPermissions(PermissionFlagsBits.ManageRoles)
.addSubcommand(s =>
s
.setName('set')
@@ -185,21 +186,9 @@ module.exports = {
async execute(interaction) {
switch (interaction.options._subcommand) {
case 'set':
if (!interaction.member.permissions.has("ADMINISTRATOR")) {
return await interaction.reply({
content: "Unprivileged Access!",
flags: MessageFlags.Ephemeral
})
}
birthdaySet(interaction)
break;
case 'delete':
if (!interaction.member.permissions.has("ADMINISTRATOR")) {
return await interaction.reply({
content: "Unprivileged Access!",
flags: MessageFlags.Ephemeral
})
}
birthdayDelete(interaction)
break;
case 'get':
+2 -1
View File
@@ -1,4 +1,4 @@
const { SlashCommandBuilder, Events, MessageFlags } = require('discord.js')
const { SlashCommandBuilder, Events, MessageFlags, PermissionFlagsBits } = require('discord.js')
const { mClient } = require('../../../index')
require('dotenv').config()
@@ -80,6 +80,7 @@ module.exports = {
data: new SlashCommandBuilder()
.setName('config')
.setDescription('configurations for admins')
.setDefaultMemberPermissions(PermissionFlagsBits.ManageChannels)
.addSubcommandGroup(sg =>
sg
.setName('channels')
+1 -1
View File
@@ -103,7 +103,7 @@ async function honorLeaderboard(interaction) {
})
const embed = new EmbedBuilder()
.setTitle('- Honors Leaderboard -')
.setThumbnail(guild.iconURL({ dynamic: true}))
.setThumbnail(interaction.guild.iconURL({ dynamic: true}))
.setDescription(fields.toString())
.setColor('#5865F2') // Discord's blurple color
.setFooter({ text: 'Use ◄ ► to navigate' });
+9 -6
View File
@@ -150,15 +150,14 @@ async function nutsLeaderboard(interaction) {
const embed = new EmbedBuilder()
.setTitle('Nuts Leaderboard')
.setThumbnail('attachment://nuts_main.png')
.setThumbnail(interaction.guild.iconURL({ dynamic: true}))
.setDescription(fields.toString())
.setColor('#5865F2')
.setFooter({ text: 'Use ◄ ► to navigate' })
await interaction.editReply({
embeds: [embed],
components: [row],
files: [`${asset_path}nuts_main.png`]
components: [row]
})
}
@@ -281,7 +280,7 @@ async function nutsNut(interaction, quickMode) {
}
// Helper for singular/plural
const formatNut = (amount) => `${amount} ${amount === 1 ? 'Nuss' : 'Nüsse'}`
const formatNut = (amount) => `${amount === 1 ? 'eine' : amount} ${amount === 1 ? 'Nuss' : 'Nüsse'}`
// check cooldown
if (cdData?.cooldown > Date.now() / 1000) {
@@ -330,9 +329,13 @@ async function nutsNut(interaction, quickMode) {
{ upsert: true }
)
let nutText = `Du hast ${formatNut(amount)} bekommen! :chestnut:`
if (amount <= 0) {
nutText = `Du hast keine Nuss bekommen! :yoink_help:`
}
if (quickMode) {
return interaction.editReply({ content: `Du hast ${formatNut(amount)} bekommen! :chestnut:` })
return interaction.editReply({ content: nutText })
}
// pseudo animation
@@ -355,7 +358,7 @@ async function nutsNut(interaction, quickMode) {
else if (amount > 4) assetFile = assets.normal
else assetFile = assets.low
embed.setTitle(`Du hast ${formatNut(amount)} bekommen!`)
embed.setTitle(nutText)
embed.setThumbnail(assetFile)
embed.setImage(null)
+178
View File
@@ -0,0 +1,178 @@
const { ModalBuilder, UserSelectMenuBuilder, TextInputBuilder, EmbedBuilder, TimestampStyles, time } = require("@discordjs/builders");
const { SlashCommandBuilder, LabelBuilder, TextInputStyle, MessageFlags } = require("discord.js");
const { mClient } = require("../../..");
function ordinal(n) {
const s = ["th", "st", "nd", "rd"];
const v = n % 100;
return n + (s[(v - 20) % 10] || s[v] || s[0]);
}
async function wgeStatus(interaction) {
const db = mClient.db('neo-db')
const wgeColl = db.collection('timer_wge')
const historyColl = db.collection('history_wge');
const results = await wgeColl.findOne({
"debug": false
})
if (!results) {
return interaction.editReply({
content: 'No WGE Session currently running!',
flags: MessageFlags.Ephemeral
})
}
const historyCount = await historyColl.countDocuments();
const iteration = historyCount + 1;
const createdAt = new Date(results.createdAt)
const expiresAt = new Date(createdAt.getTime() + Number(results.timeRemaining))
const embed = new EmbedBuilder()
.setTitle(`✨ [${ordinal(iteration)}] World's Greatest Expert ✨`)
.setDescription(
`<@${results.assignedUser}> is currently the **World's Greatest Expert** in **${results.topic}**.\n\n` +
`They must submit their entry <t:${Math.floor(expiresAt.getTime() / 1000)}:R>.\n\n` +
`Thank you, <@${results.assigningUser}>, for the nomination!`
)
return interaction.editReply({
embeds: [embed]
})
}
async function wgeStart(interaction) {
const wgeBaseModal = new ModalBuilder()
.setCustomId('wgeBaseModal')
.setTitle("World's Greatest Expert")
const wgeUserInput = new UserSelectMenuBuilder()
.setCustomId('wgeUserInput')
.setMaxValues(1)
.setRequired(true)
const wgeTopicInput = new TextInputBuilder()
.setCustomId('wgeTopicInput')
.setStyle(TextInputStyle.Short)
.setRequired(true)
const wgeUserLabel = new LabelBuilder()
.setLabel("Who is YOUR World's Greatest Expert?")
.setDescription('Select them!')
.setUserSelectMenuComponent(wgeUserInput)
const wgeTopicLabel = new LabelBuilder()
.setLabel("And WHAT are they an expert in?")
.setDescription('Tell me!')
.setTextInputComponent(wgeTopicInput)
wgeBaseModal
.addLabelComponents(wgeUserLabel, wgeTopicLabel)
await interaction.showModal(wgeBaseModal)
}
async function wgeStop(interaction) {
}
async function wgePause(interaction) {
}
async function wgeResume(interaction) {
}
async function wgeForfeit(interaction) {
}
async function wgeHistory(interaction) {
}
module.exports = {
data: new SlashCommandBuilder()
.setName('wge')
.setDescription('welcome to worlds greatest experts')
// Show Status of Current Running WGE Session
.addSubcommand(s =>
s
.setName('status')
.setDescription('display current wge session')
)
// Assign Someone to be the next Expert
.addSubcommand(s =>
s
.setName('start')
.setDescription('start a new wge session')
)
// Stop the current Session, No Reassignment
.addSubcommand(s =>
s
.setName('stop')
.setDescription('stop the current wge session')
)
// Halt the current Session Timer
.addSubcommand(s =>
s
.setName('pause')
.setDescription('pause the current wge session timer')
)
// Resume the current Session Timer
.addSubcommand(s =>
s
.setName('resume')
.setDescription('resume the current wge session timer')
)
// Forfeit your current expert topic and assign someone else
.addSubcommand(s =>
s
.setName('forfeit')
.setDescription('forfeit your current topic')
)
// List the previous WGE Sessions
.addSubcommand(s =>
s
.setName('history')
.setDescription('display the previous wge sessions')
)
,
async execute(interaction) {
switch (interaction.options._subcommand) {
case 'status':
await interaction.deferReply()
wgeStatus(interaction)
break;
case 'start':
wgeStart(interaction)
break;
case 'stop':
wgeStop(interaction)
break;
case 'pause':
wgePause(interaction)
break;
case 'resume':
wgeResume(interaction)
break;
case 'forfeit':
wgeForfeit(interaction)
break;
case 'history':
wgeHistory(interaction)
break;
default:
break;
}
}
}
+1 -1
View File
@@ -54,7 +54,7 @@ module.exports = {
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);
client.emit('Birthday', member);
} else {
// Default fallback: remove birthday role if present
if (member.roles.cache.has(birthdayRoleID)) {
+29 -2
View File
@@ -1,13 +1,14 @@
const { Events, MessageFlags } = require('discord.js')
const { mClient } = require('../index')
module.exports = {
name: Events.InteractionCreate,
once: false,
async execute(interaction) {
if (interaction.isChatInputCommand()) { commandHandler(interaction) };
if (interaction.isChatInputCommand()) { commandHandler(interaction) }
if (interaction.isButton()) { buttonHandler(interaction) }
if (interaction.isMentionableSelectMenu()) { selectMenuHandler(interaction) }
if (interaction.isUserSelectMenu()) { selectMenuHandler(interaction) }
if (interaction.isModalSubmit()) { modalSubmitHandler(interaction) }
}
}
async function commandHandler(interaction) {
@@ -56,3 +57,29 @@ async function selectMenuHandler(interaction) {
}
}
}
async function modalSubmitHandler(interaction) {
if (interaction.customId === 'wgeBaseModal') {
await interaction.reply({
content: 'Your submission was received successfully!'
});
// Get the data entered by the user
const wgeAssignedUser = interaction.components[0].component.users.first();
const wgeAssigningUser = interaction.user
const wgeAssignedTopic = interaction.fields.getTextInputValue('wgeTopicInput');
const wgeDefaultAssignedTime = 7 * 24 * 60 * 60 * 1000; // 7 days in ms
const db = mClient.db('neo-db')
const wgeColl = db.collection('timer_wge')
wgeColl.insertOne({
"assignedUser": wgeAssignedUser.id,
"assigningUser": wgeAssigningUser.id,
"timeRemaining": wgeDefaultAssignedTime,
"createdAt": new Date(),
"topic": wgeAssignedTopic,
"debug" :false
})
}
}