Skip to content

Commit

Permalink
update; remove prepare for minimal deplyoment
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-flip committed Jan 7, 2024
1 parent b993e0f commit daf85e0
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 141 deletions.
3 changes: 2 additions & 1 deletion commands/checkin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
15 changes: 4 additions & 11 deletions config.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -23,7 +18,5 @@
"archiveChannel": "934144110451892224",
"checkinRole": "932062131359207487"
},
"aboutText": "./config/about.txt",
"teamRole": "932062876250804294",
"logChannel": "933524154479689778"
}
2 changes: 1 addition & 1 deletion functions/ENGINE/checkin/COMPONENT/button/allow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
15 changes: 7 additions & 8 deletions functions/ENGINE/checkin/initReaction.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
60 changes: 2 additions & 58 deletions functions/ENGINE/checkin/postReaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,83 +4,27 @@ 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()
.setColor('Green')
.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] });
};

Expand Down
14 changes: 7 additions & 7 deletions functions/ENGINE/checkin/transcriptChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) => {
Expand Down Expand Up @@ -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({
Expand All @@ -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 = {
Expand Down
9 changes: 0 additions & 9 deletions functions/EVENT/interaction/isModalSubmit.js

This file was deleted.

6 changes: 0 additions & 6 deletions functions/EVENT/interactionCreate.js
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
12 changes: 0 additions & 12 deletions functions/EVENT/messageCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 0 additions & 13 deletions functions/EVENT/messageReactionAdd.js

This file was deleted.

10 changes: 0 additions & 10 deletions functions/EVENT/messageReactionRemove.js

This file was deleted.

2 changes: 1 addition & 1 deletion functions/SETUP/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -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!`);
};

Expand Down
4 changes: 0 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit daf85e0

Please sign in to comment.