Skip to content

Commit 9f04a7c

Browse files
committed
Updated env, submit-simple reworked, 1.0 release
1 parent 21fb4ea commit 9f04a7c

File tree

13 files changed

+150
-106
lines changed

13 files changed

+150
-106
lines changed

.env.example

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
TOKEN=bot_token
22
OWNER_ID=user_id
33
MASTER_SERVER=server_id
4-
MASTER_LOG=channel_id
5-
MASTER_POSTING=channel_id
6-
LIBRARIANS=role_id
4+
MASTER_CHX_DEBUG_LOG=channel_id
5+
MASTER_CHX_POSTING=channel_id
6+
MASTER_CHX_POSTING_LOG=channel_id
7+
MASTER_CHX_POSTING_WANTED=channel_id
8+
MASTER_LIBRARIANS_ROLE=role_id
79
DB_URL=postgres://username:password@host/database
810
PGHOST=host
911
PGDATABASE=database

events/client/interactionCreate.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
const chalkMy = require(process.cwd() + "/src/chalk");
33

4+
const _local_debug = Boolean(0);
5+
46
module.exports = {
57
name: 'interactionCreate',
68

@@ -52,11 +54,14 @@ module.exports = {
5254
//console.log(interaction);
5355
let triggerFounded = false;
5456
const cmdsArr = [...client.slash.keys()];
57+
if (_local_debug) console.log('Button hit, interaction.customId:', interaction.customId);
5558
for (let i = 0; i < cmdsArr.length; i++) {
5659
const element = client.slash.get(cmdsArr[i]);
5760
//console.log(element);
5861
if (!element.triggers) continue;
62+
if (_local_debug) console.log(`element: ${element.name}, trigger: ${element.triggers}`);
5963
if (element.triggers.includes(interaction.customId)) {
64+
if (_local_debug) console.log(`hit`);
6065
triggerFounded = true;
6166
const command = element; //client.slash.get("one-time-button");
6267
try {

events/client/inviteCreate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@ module.exports = {
5757
)}`, true);
5858

5959

60-
return client.channels.cache.get(process.env.MASTER_LOG).send({ embeds: [eventEmbed] });
60+
return client.channels.cache.get(process.env.MASTER_CHX_DEBUG_LOG).send({ embeds: [eventEmbed] });
6161
}
6262
}

events/client/inviteDelete.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ module.exports = {
1515
*/
1616
async execute(interaction, client) {
1717
console.log(chalkMy.event, `Event fired: "inviteDelete" (${interaction})`);
18-
return client.channels.cache.get(process.env.MASTER_LOG).send({ content: `inviteDelete event fired`});
18+
return client.channels.cache.get(process.env.MASTER_CHX_DEBUG_LOG).send({ content: `inviteDelete event fired`});
1919
}
2020
}

events/client/modalSubmit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ module.exports = {
114114
if (!firstResponse) return modal.reply({ content: `Error: There is not enough variables, cancel command execution.` });
115115
const secondResponse = modal.getTextInputValue('textinput-customid-2');
116116
if (!secondResponse) return modal.reply({ content: `Error: There is not enough variables, cancel command execution.` });
117-
//client.channels.cache.get(process.env.MASTER_LOG).send({ content: `modalSubmit event fired`});
117+
//client.channels.cache.get(process.env.MASTER_CHX_DEBUG_LOG).send({ content: `modalSubmit event fired`});
118118
return modal.reply('Congrats! Powered by discord-modals.' + Formatters.codeBlock('markdown', firstResponse) + Formatters.codeBlock('markdown', secondResponse));
119119
} else if (modal.customId === 'submit-modal-form') {
120120
const inviteIn = modal.getTextInputValue('textinput-invite');

handler/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ const loadSlashCommands = async function (client) {
9898
}
9999
client.slash.set(command.name, command);
100100
slash.push(command);
101-
console.log(chalkMy.load, chalkMy.ok, `SlashCommand: "${file}"`); // SlashCommand is being loaded:
101+
console.log(chalkMy.load, chalkMy.ok, `SlashCommand: "${file}"${((command.triggers) ? ('; "' + JSON.stringify(command.triggers) + '"') : (''))}`); // SlashCommand is being loaded:
102102
} else {
103103
console.log(chalkMy.load, chalkMy.err, `SlashCommand missing a help.name or help.name is not in string: "${file}"`);
104104
continue;

slashCommands/Utility/create-invite.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const { SlashCommandBuilder } = require('@discordjs/builders'); // require('disc
33
const { MessageActionRow, MessageButton } = require('discord.js');
44

55

6-
let self = module.exports = {
6+
const self = module.exports = {
77
name: "create-invite",
88
category: "Utility",
99
description: "Creates an invite to this guild channel.",

slashCommands/Utility/get-info.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ module.exports = {
7272
}
7373
}
7474
if (fetchedInvite === null) {
75-
return interaction.reply({ content: `Error: ${e}; message:${e.message}` });
75+
console.log('Invite checked, it\'s not alive.');
76+
return interaction.reply({ content: `Error: Message: ${e.message}\n${e}` });
7677
}
7778

7879
const embedInvite = new client.discord.MessageEmbed()

slashCommands/Utility/one-time-button.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const { SlashCommandBuilder } = require('@discordjs/builders'); // require('disc
33
const { MessageActionRow, MessageButton } = require('discord.js');
44

55

6-
let self = module.exports = {
6+
const self = module.exports = {
77
name: "one-time-button",
88
category: "Utility",
99
description: "A button that will only work once and be destroyed.",

slashCommands/Utility/submit-project.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ const { Modal, TextInputComponent, showModal } = require('discord-modals');
33
const { MessageButton, Permissions } = require('discord.js');
44
const chalkMy = require(process.cwd() + "/src/chalk");
55

6-
self = module.exports = {
6+
const self = module.exports = {
77
name: "submit-project",
88
category: "Utility",
99
description: "Call form to input invite with server info to propose to publish.",
1010
ownerOnly: true,
1111
triggers: [
12-
'submit-modal-form-post', // submit-modal-form-echo
13-
'submit-modal-form-check',
12+
'submit-project-post', // submit-modal-form-echo
13+
'submit-project-check',
1414
],
1515
trigger: async (client, interaction) => {
16-
console.log(chalkMy.event, `Command triggered: "submit".`);
17-
const _channel = client.channels.cache.get(process.env.MASTER_POSTING);
16+
console.log(chalkMy.event, `Command triggered: "submit-project".`);
17+
const _channel = client.channels.cache.get(process.env.MASTER_CHX_POSTING);
1818
if (interaction.customId == self.triggers[0]) {
19-
if (!(interaction.member.permissions.has(Permissions.FLAGS.ADMINISTRATOR)) || !(interaction.member.roles.resolveId(process.env.LIBRARIANS))) {
19+
if (!(interaction.member.permissions.has(Permissions.FLAGS.ADMINISTRATOR)) || !(interaction.member.roles.resolveId(process.env.MASTER_LIBRARIANS_ROLE))) {
2020
return await interaction.reply({ ephemeral: true, content: `**Access denied**: Only librarian or admin allowed to do this.`});
2121
}
2222
let _MessageActionRow = interaction.message.components;
@@ -133,7 +133,7 @@ self = module.exports = {
133133
let _channel = await client.channels.fetch(interaction.channelId);
134134
await _channel.sendTyping();
135135
}
136-
if ((interaction.member.permissions.has(Permissions.FLAGS.ADMINISTRATOR)) || (interaction.member.roles.resolveId(process.env.LIBRARIANS))) {
136+
if ((interaction.member.permissions.has(Permissions.FLAGS.ADMINISTRATOR)) || (interaction.member.roles.resolveId(process.env.MASTER_LIBRARIANS_ROLE))) {
137137
const modal = new Modal() // We create a Modal
138138
.setCustomId('submit-modal-form')
139139
.setTitle('Submit your invite')

0 commit comments

Comments
 (0)