From daf85e06dbcf42ece02a958e517ff6e93cc86013 Mon Sep 17 00:00:00 2001 From: Phil Date: Sun, 7 Jan 2024 03:06:19 +0100 Subject: [PATCH] update; remove prepare for minimal deplyoment --- commands/checkin.js | 3 +- config.json | 15 ++--- .../ENGINE/checkin/COMPONENT/button/allow.js | 2 +- functions/ENGINE/checkin/initReaction.js | 15 +++-- functions/ENGINE/checkin/postReaction.js | 60 +------------------ functions/ENGINE/checkin/transcriptChannel.js | 14 ++--- functions/EVENT/interaction/isModalSubmit.js | 9 --- functions/EVENT/interactionCreate.js | 6 -- functions/EVENT/messageCreate.js | 12 ---- functions/EVENT/messageReactionAdd.js | 13 ---- functions/EVENT/messageReactionRemove.js | 10 ---- functions/SETUP/status.js | 2 +- index.js | 4 -- 13 files changed, 24 insertions(+), 141 deletions(-) delete mode 100644 functions/EVENT/interaction/isModalSubmit.js delete mode 100644 functions/EVENT/messageReactionAdd.js delete mode 100644 functions/EVENT/messageReactionRemove.js diff --git a/commands/checkin.js b/commands/checkin.js index 957f735..340fb4a 100644 --- a/commands/checkin.js +++ b/commands/checkin.js @@ -11,4 +11,5 @@ module.exports.run = async (interaction) => { module.exports.data = new CmdBuilder() .setName('checkin') - .setDescription('Shows the checkin menu without pinging team.'); + .setDescription('Shows the checkin menu without pinging team.') + .setDMPermission(false); diff --git a/config.json b/config.json index a45f5a0..9c9a8f2 100644 --- a/config.json +++ b/config.json @@ -1,16 +1,11 @@ { "name": "Aseivadae", + "teamRole": "932062876250804294", + "guildId": "928873675250364447", "prefix": "a?", "setup": { - "moduleFolders": { - "functionsFolder": "functions", - "commandsFolder": "commands" - }, - "startupFunctions": [ - "STARTUP_initCommands", - "STARTUP_initFunctions" - ], - "setupFunctions": [ "SETUP_status" ] + "logStatusChannel": "934144110451892224", + "setupFunctions": [ "SETUP_status", "SETUP_initCommands" ] }, "checkin": { "reaction": { @@ -23,7 +18,5 @@ "archiveChannel": "934144110451892224", "checkinRole": "932062131359207487" }, - "aboutText": "./config/about.txt", - "teamRole": "932062876250804294", "logChannel": "933524154479689778" } \ No newline at end of file diff --git a/functions/ENGINE/checkin/COMPONENT/button/allow.js b/functions/ENGINE/checkin/COMPONENT/button/allow.js index fbbb6e2..d8ccef8 100644 --- a/functions/ENGINE/checkin/COMPONENT/button/allow.js +++ b/functions/ENGINE/checkin/COMPONENT/button/allow.js @@ -9,7 +9,7 @@ module.exports.run = async (interaction) => { // post welcome message const welcomeChannel = member.guild.channels.cache.get(config.checkin.welcomeChannel); - welcomeChannel.send(`${member}, you are checked-in now!\nYou can check out some roles in <#669278640667623434>!\nHave a great time on the server! :3`); + welcomeChannel.send(`${member}, you are checked-in now!\nYou can check out some roles in <#932122537763143700>!\nHave a great time on the server!`); await client.functions.get('ENGINE_checkin_transcriptChannel').run(checkinChannel); // delete channel await checkinChannel.delete(); diff --git a/functions/ENGINE/checkin/initReaction.js b/functions/ENGINE/checkin/initReaction.js index aa6b890..c7d8bab 100644 --- a/functions/ENGINE/checkin/initReaction.js +++ b/functions/ENGINE/checkin/initReaction.js @@ -1,14 +1,13 @@ const welcomeMessage = (userID) => ` -Hey there <@!${userID}>! Welcome to TDM. -Before we let you in im going to ask you some questions, before a staff member is going to let you in. +Hey there <@!${userID}>! Welcome to The Commune of Dragons. +Before we can continue im going to ask you some questions and a staff member is going to review them and let you in. -:one: - How did you find our server? -:two: - Are you on any other vore servers? -:three: - Do you like vore and what is your favorite? -:four: - What is your DoB date of birth? (Preferable in YYYY-MM-DD format) -:five: - Please provide your ID as in <#496948681656893440> described. +:one: - Please state your age. +:two: - How do you act in a displeasing situation? +:three: - How long have you been kin and have you switched kin? +:four: - Have you read the rules and agree? -When you are done please ping/mention \`@Team\`, so we know that you are done and ready to be reviewd. +When you are done please ping/mention \`@Staff\`, so we know that you are done and ready to be reviewed. `; // calculate user creation diff --git a/functions/ENGINE/checkin/postReaction.js b/functions/ENGINE/checkin/postReaction.js index 4d4e7ca..9ece62c 100644 --- a/functions/ENGINE/checkin/postReaction.js +++ b/functions/ENGINE/checkin/postReaction.js @@ -4,58 +4,20 @@ const { const moment = require('moment'); -const userDoB = require('../../../database/models/UserDoB'); - -const buttonsSetup = ({ checked, DoB }) => new ActionRowBuilder() +const buttonsAdd = new ActionRowBuilder() .addComponents([ new ButtonBuilder() .setCustomId('checkin_COMPONENT_button_allow') .setEmoji('👌') - .setLabel(!(checked && DoB) ? 'Verfiy first' : 'Allow') - .setDisabled(!(checked && DoB)) + .setLabel('Allow') .setStyle(ButtonStyle.Primary), new ButtonBuilder() .setCustomId('checkin_COMPONENT_button_deny') .setEmoji('✋') .setLabel('Deny') .setStyle(ButtonStyle.Danger), - new ButtonBuilder() - .setCustomId('checkin_COMPONENT_button_dob_checked') - .setEmoji('🔞') - .setLabel(checked && DoB ? 'Already checked ID' : 'ID checked') - .setDisabled(checked) - .setStyle(ButtonStyle.Secondary), - new ButtonBuilder() - .setCustomId('checkin_COMPONENT_button_dob_add') - .setEmoji('➕') - .setLabel(DoB || 'Add DoB') - .setDisabled(!!DoB) - .setStyle(ButtonStyle.Secondary), ]); -async function getDate(channel) { - // get all messages - const messages = await channel.messages.fetch(); - // match date - const dateRegEx = /\d{4}[-]\d{2}[-]\d{2}/gm; - const found = await messages.filter((msg) => msg.content.match(dateRegEx) && msg.author.id === channel.name); - if (!found.size) return; - const coreMessage = found.entries().next().value[1].content; - const rawDate = coreMessage.match(dateRegEx)[0]; - return moment(rawDate, config.DoBchecking.dateFormats, true); -} - -async function searchUser(ID) { - const result = await userDoB.findOne({ where: { ID } }).catch(ERR); - return result; -} - -async function addUser(ID, DoB, allow, teammemberID) { - if (await userDoB.findOne({ where: { ID } }).catch(ERR)) return false; - await userDoB.findOrCreate({ where: { ID }, defaults: { DoB, allow, teammemberID } }).catch(ERR); - return true; -} - module.exports.run = async (message) => { // check if team fore was pinged and if channel is a checkin channel const embed = new EmbedBuilder() @@ -63,24 +25,6 @@ module.exports.run = async (message) => { .setDescription('Please wait for a teammember to review your answers.') .setFooter({ text: 'You can ignore the buttons below.' }); - const userID = message.channel.name; - const userDoB = await searchUser(userID); - - let DoB = false; - if (!userDoB) { - const date = await getDate(message.channel); - if (date && date.isValid()) { - DoB = date.format(config.DoBchecking.dateFormats[0]); - // add entry - await addUser(userID, DoB, false, client.user.id); - } - } else { - DoB = moment(userDoB.DoB).format(config.DoBchecking.dateFormats[0]); - } - const checked = userDoB ? userDoB.allow : false; - - // dont activate 'checked' button, if DoB has not been checked - const buttonsAdd = buttonsSetup({ checked: DoB ? checked : true, DoB }); message.channel.send({ embeds: [embed], components: [buttonsAdd] }); }; diff --git a/functions/ENGINE/checkin/transcriptChannel.js b/functions/ENGINE/checkin/transcriptChannel.js index e6a1c15..0894425 100644 --- a/functions/ENGINE/checkin/transcriptChannel.js +++ b/functions/ENGINE/checkin/transcriptChannel.js @@ -12,22 +12,22 @@ const document = dom.window.document; module.exports.run = async (channel) => { let messageCollection = new Collection(); - let channelMessages = await channel.messages.fetch({ limit: 100 }).catch((err) => console.log(err)); + let channelMessages = await channel.messages.fetch({ limit: 100 }).catch(ERR); messageCollection = messageCollection.concat(channelMessages); while (channelMessages.size === 100) { const lastMessageId = channelMessages.lastKey(); // eslint-disable-next-line no-await-in-loop - channelMessages = await channel.messages.fetch({ limit: 100, before: lastMessageId }).catch((err) => console.log(err)); + channelMessages = await channel.messages.fetch({ limit: 100, before: lastMessageId }).catch(ERR); if (channelMessages) messageCollection = messageCollection.concat(channelMessages); } const allMessages = Array.from(messageCollection.values()).reverse(); - const data = await fs.readFile('./assets/transcript/template.html', 'utf8').catch((err) => console.log(err)); + const data = await fs.readFile('./assets/transcript/template.html', 'utf8').catch(ERR); if (!data) return console.error('Template file could not be loaded!'); // create file - await fs.writeFile('./cache/index.html', data).catch((err) => console.log(err)); + await fs.writeFile('./cache/index.html', data).catch(ERR); // add guild title const guildElement = document.createElement('div'); const guildText = document.createTextNode(channel.name); @@ -36,7 +36,7 @@ module.exports.run = async (channel) => { guildImg.setAttribute('width', '150'); guildElement.appendChild(guildImg); guildElement.appendChild(guildText); - await fs.appendFile('./cache/index.html', guildElement.outerHTML).catch((err) => console.log(err)); + await fs.appendFile('./cache/index.html', guildElement.outerHTML).catch(ERR); // forEach all messages allMessages.forEach(async (msg) => { @@ -73,7 +73,7 @@ module.exports.run = async (channel) => { messageContainer.appendChild(msgNode); } parentContainer.appendChild(messageContainer); - await fs.appendFile('./cache/index.html', parentContainer.outerHTML).catch((err) => console.log(err)); + await fs.appendFile('./cache/index.html', parentContainer.outerHTML).catch(ERR); }); const archive = channel.guild.channels.cache.get(config.checkin.archiveChannel); archive.send({ @@ -82,7 +82,7 @@ module.exports.run = async (channel) => { attachment: './cache/index.html', name: `${channel.name}.html`, }], - }).catch((err) => console.log(err)); + }).catch(ERR); }; module.exports.data = { diff --git a/functions/EVENT/interaction/isModalSubmit.js b/functions/EVENT/interaction/isModalSubmit.js deleted file mode 100644 index 0a6fa14..0000000 --- a/functions/EVENT/interaction/isModalSubmit.js +++ /dev/null @@ -1,9 +0,0 @@ -module.exports.run = async (interaction) => { - interaction.deferUpdate(); - // if (!interaction.member.roles.cache.has(config.teamRole)) return; - return client.functions.get(`ENGINE_${interaction.customId}`).run(interaction).catch(ERR); -}; - -module.exports.data = { - name: 'isModalSubmit', -}; diff --git a/functions/EVENT/interactionCreate.js b/functions/EVENT/interactionCreate.js index 0bdc038..0a79b3d 100644 --- a/functions/EVENT/interactionCreate.js +++ b/functions/EVENT/interactionCreate.js @@ -1,13 +1,7 @@ module.exports.run = async (interaction) => { - // only guild command - // TODO: check if neseccary, because this seems to be a useless intent 'DIRECT_MESSAGES' - // TODO: maybe check if command deployment to DM can be supressed - if (!await interaction.inGuild()) return messageFail(interaction, 'The bot is for server-use only.'); - // command handler if (interaction.isCommand()) return client.functions.get('EVENT_interaction_isCommand').run(interaction).catch(ERR); if (interaction.isButton()) return client.functions.get('EVENT_interaction_isButton').run(interaction).catch(ERR); - if (interaction.isModalSubmit()) return client.functions.get('EVENT_interaction_isModalSubmit').run(interaction).catch(ERR); }; module.exports.data = { diff --git a/functions/EVENT/messageCreate.js b/functions/EVENT/messageCreate.js index 7c97e95..c55f7f3 100644 --- a/functions/EVENT/messageCreate.js +++ b/functions/EVENT/messageCreate.js @@ -3,18 +3,6 @@ module.exports.run = async (message) => { if (message.author.bot) return; if (message.channel.type === 'dm') return; - // checking if staffmember - // TODO: foreach, with more roles - // const staff = message.member.roles.cache.has(config.teamRole); - - if (config.contentWarning.checkChannels.includes(message.channel.id)) return client.functions.get('ENGINE_contentWarning_check').run(message); - - if (config.linkReplace.checkChannels.includes(message.channel.id)) return client.functions.get('ENGINE_linkReplace_check').run(message); - - // check if channel channel is a limited RP zone - if (!DEBUG && config.reducedRP.channels.includes(message.channel.id)) return client.functions.get('ENGINE_limitedRp').run(message); - // if (config.reducedRP.channels.includes(message.channel.id)) return client.functions.get('ENGINE_limitedRp').run(message); - // non command function: checkin complete questioning Reaction adding if (message.mentions.roles.has(config.teamRole) && message.channel.parentId === config.checkin.categoryID) return client.functions.get('ENGINE_checkin_postReaction').run(message); diff --git a/functions/EVENT/messageReactionAdd.js b/functions/EVENT/messageReactionAdd.js deleted file mode 100644 index a433ac6..0000000 --- a/functions/EVENT/messageReactionAdd.js +++ /dev/null @@ -1,13 +0,0 @@ -module.exports.run = async (reaction, user) => { - if (user.bot) return; - - // reaction logging - client.functions.get('ENGINE_logger_reaction').run('added', reaction, user); - - // rolerequest - if (reaction.message.channel.id === config.setup.roleRequest.channelID) return client.functions.get('ENGINE_roleRequest_manager').run(reaction, user); -}; - -module.exports.data = { - name: 'messageReactionAdd', -}; diff --git a/functions/EVENT/messageReactionRemove.js b/functions/EVENT/messageReactionRemove.js deleted file mode 100644 index f19c9aa..0000000 --- a/functions/EVENT/messageReactionRemove.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports.run = async (reaction, user) => { - if (user.bot) return; - - // reaction logging - client.functions.get('ENGINE_logger_reaction').run('removed', reaction, user); -}; - -module.exports.data = { - name: 'messageReactionRemove', -}; diff --git a/functions/SETUP/status.js b/functions/SETUP/status.js index 0e375d0..027a048 100644 --- a/functions/SETUP/status.js +++ b/functions/SETUP/status.js @@ -3,7 +3,7 @@ module.exports.run = async () => { console.log(`[${module.exports.data.name}] Setting status...`); await client.user.setStatus('online'); const membercount = await client.guilds.cache.reduce((previousCount, currentGuild) => previousCount + currentGuild.memberCount, 0); - await client.user.setActivity(`${membercount} members in TDM`, { type: 'WATCHING' }); + await client.user.setActivity(`${membercount} members in the Commune`, { type: 'WATCHING' }); console.log(`[${module.exports.data.name}] Status set!`); }; diff --git a/index.js b/index.js index a6a4896..8f94155 100644 --- a/index.js +++ b/index.js @@ -80,10 +80,6 @@ client.on('messageReactionAdd', (reaction, user) => { client.functions.get('EVENT_messageReactionAdd').run(reaction, user).catch(ERR); }); -client.on('messageReactionRemove', (reaction, user) => { - client.functions.get('EVENT_messageReactionRemove').run(client, reaction, user, config); -}); - // trigger on reaction with raw package client.on('raw', async (packet) => { if (packet.t === 'MESSAGE_REACTION_ADD' && packet.d.guild_id) {