Skip to content

Commit 46dd18c

Browse files
committed
fix: startup & testing errors
1 parent 5d5fc71 commit 46dd18c

13 files changed

Lines changed: 51 additions & 47 deletions

File tree

bot/events/discord/interactionCreate.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ class InteractionCreateEvent extends Event {
1515
*/
1616
async run(interaction) {
1717

18-
if (!interaction.user.bot) return;
18+
if (interaction.user.bot) return;
1919

2020
const command = this.MentorQ.slashCommands.get(interaction.commandName) ?? this.MentorQ.components.get(interaction.customId);
2121
if (!command) return;
22+
2223
if (command.config.guildRequired && !interaction.guild)
2324
return interaction.reply({ embeds: [this.MentorQ.util.errorEmbed("This command must be used in a server.")] });
2425

@@ -41,7 +42,7 @@ class InteractionCreateEvent extends Event {
4142
if (this.MentorQ.util.handleCooldown(command, interaction)) return;
4243

4344
command.run(interaction).catch(err => {
44-
console.error(`INTERACTION (${command.config.name}) ERROR | EXECUTOR: ${interaction.user.username} | GUILD: ${interaction.guild?.name || "N/A"} |\n INTERACTION DATA: ${interaction.options?.data ? JSON.stringify(interaction.options.data) : "N/A"} |\n` + err.stack);
45+
console.error(`-----\nINTERACTION (${command.config.name}) ERROR | EXECUTOR: ${interaction.user.username} | GUILD: ${interaction.guild?.name || "N/A"} |\n INTERACTION DATA: ${interaction.options?.data ? JSON.stringify(interaction.options.data) : "N/A"} |\n` + err.stack + "\n-----");
4546

4647
const errorEmbed = new EmbedBuilder()
4748
.setAuthor({ name: `Interaction Error: ${command.config.name}`, iconURL: this.MentorQ.user.displayAvatarURL() })

bot/events/discord/messageCreate.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ class MessageCreateEvent extends Event {
1717

1818
if (!message.guild || message.author.bot) return;
1919

20-
const prefixRegex = new RegExp(`^(<@!?${this.StormBeatz.user.id}> |${message.guild.settings.prefix})\\s*`);
20+
const escapeRegex = str => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
21+
const prefixRegex = new RegExp(`^(<@!?${this.MentorQ.user.id}> |${escapeRegex(this.MentorQ.config.prefix)})\\s*`);
2122
const prefix = message.content.match(prefixRegex)?.shift();
2223

2324
if (!prefix || !message.content.startsWith(prefix)) return;
@@ -45,7 +46,7 @@ class MessageCreateEvent extends Event {
4546
if (this.MentorQ.util.handleCooldown(command, message)) return;
4647

4748
command.run(message, args).catch(err => {
48-
console.error(`COMMAND (${command.config.name}) ERROR | EXECUTOR: ${message.author.username} | GUILD: ${message.guild.name} |\n` + err.stack);
49+
console.error(`-----\nCOMMAND (${command.config.name}) ERROR | EXECUTOR: ${message.author.username} | GUILD: ${message.guild.name} |\n` + err.stack + "\n-----");
4950

5051
const errorEmbed = new EmbedBuilder()
5152
.setAuthor({ name: `Command Error: ${command.config.name}`, iconURL: this.MentorQ.user.displayAvatarURL() })

bot/events/discord/ready.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const Event = require("../../../structures/base/BaseEvent");
2-
const { EmbedBuilder } = require("discord.js");
2+
const { EmbedBuilder, ActivityType } = require("discord.js");
33

44
class ReadyEvent extends Event {
55
/**
@@ -12,6 +12,8 @@ class ReadyEvent extends Event {
1212

1313
async run() {
1414

15+
console.log(`MentorQ (${this.MentorQ.user.tag}) is Online`);
16+
1517
const onlineEmbed = new EmbedBuilder()
1618
.setTitle("MentorQ is Online")
1719
.addFields([
@@ -23,6 +25,8 @@ class ReadyEvent extends Event {
2325

2426
this.MentorQ.logs.send({ embeds: [onlineEmbed] });
2527

28+
this.MentorQ.user.setPresence({ activities: [{ type: ActivityType.Watching, name: "HackRU" }] });
29+
2630
return;
2731

2832
}

bot/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ class MentorQClient extends Client {
4848
/**
4949
* @type {import("../managers/TicketsManager")}
5050
*/
51-
this.tickets = (require("../managers/TicketsManager"))(this);
51+
this.tickets = new (require("../managers/TicketsManager"))(this);
5252
/**
5353
* @type {import("../managers/UtilManager")}
5454
*/
55-
this.util = (require("../managers/UtilManager"))(this);
55+
this.util = new (require("../managers/UtilManager"))(this);
5656

5757
}
5858

bot/interactions/components/buttons/close.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ class CloseButton extends Component {
1717
if (!this.MentorQ.tickets.isActive(interaction.guild))
1818
return interaction.reply({ embeds: [this.MentorQ.util.errorEmbed("The MentorQ system is not active. Contact a server admin to complete setup process.")], ephemeral: true });
1919

20-
await this.MentorQ.tickets.close(interaction.member, interaction.message.channel);
21-
2220
interaction.reply({ embeds: [this.MentorQ.util.successEmbed(`Ticket ${interaction.message.channel.toString()} has been closed.`)] });
2321

22+
await this.MentorQ.tickets.close(interaction.member, interaction.message.channel);
23+
2424
return;
2525

2626
}

bot/interactions/components/modals/mentor-request.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class MentorRequestModal extends Component {
1919
team: interaction.fields.getTextInputValue("team-input"),
2020
title: interaction.fields.getTextInputValue("title-input"),
2121
language: interaction.fields.getTextInputValue("lang-input"),
22-
techStack: interaction.fields.getTextInputValue("tech-stack-input"),
2322
description: interaction.fields.getTextInputValue("desc-input"),
2423
});
2524

bot/interactions/slashcommands/close.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ class CloseSlashCommand extends SlashCommand {
2222
return interaction.reply({ embeds: [this.MentorQ.util.errorEmbed("The MentorQ system is not active. Contact a server admin to complete setup process.")], ephemeral: true });
2323

2424
const ticket = interaction.channel;
25-
if (!ticket.isThread() || ticket.ownerId !== this.MentorQ.user.id || ticket.parentId !== this.MentorQ.tickets.getRequestsChannel()?.id)
25+
if (!ticket.isThread() || ticket.ownerId !== this.MentorQ.user.id || ticket.parentId !== this.MentorQ.tickets.getRequestsChannel(interaction.guild)?.id)
2626
return interaction.reply({ embeds: [this.MentorQ.util.errorEmbed("This is not a valid MentorQ ticket!")], ephemeral: true });
2727

28-
await this.MentorQ.tickets.close(interaction.member, ticket);
29-
3028
interaction.reply({ embeds: [this.MentorQ.util.successEmbed(`Ticket ${ticket.toString()} has been closed.`)] });
3129

30+
await this.MentorQ.tickets.close(interaction.member, ticket);
31+
3232
return;
3333

3434
}

bot/interactions/slashcommands/ping.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const { EmbedBuilder } = require("discord.js");
12
const SlashCommand = require("../../../structures/base/BaseSlashCommand");
23

34
class PingCommand extends SlashCommand {
@@ -22,7 +23,11 @@ class PingCommand extends SlashCommand {
2223
async run(interaction) {
2324
const msg = await interaction.reply({ content: "🏓 Pinging...", fetchReply: true });
2425

25-
interaction.editReply({ embeds: [this.MentorQ.util.successEmbed(`💗 WS Heartbeat: ${Math.round(this.MentorQ.ws.ping)}ms\n🏓 API Latency: ${msg.createdTimestamp - interaction.createdTimestamp}ms`)] });
26+
const pingEmbed = new EmbedBuilder()
27+
.setDescription(`💗 WS Heartbeat: ${Math.round(this.MentorQ.ws.ping)}ms\n🏓 API Latency: ${msg.createdTimestamp - interaction.createdTimestamp}ms`)
28+
.setColor("Blurple");
29+
30+
interaction.editReply({ content: "", embeds: [pingEmbed] });
2631

2732
return;
2833
}

bot/interactions/textcommands/ping.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const { EmbedBuilder } = require("discord.js");
12
const TextCommand = require("../../../structures/base/BaseTextCommand");
23

34
class PingCommand extends TextCommand {
@@ -20,7 +21,11 @@ class PingCommand extends TextCommand {
2021
async run(message) {
2122
const msg = await message.reply("🏓 Pinging...");
2223

23-
msg.edit({ embeds: [this.MentorQ.util.successEmbed(`💗 WS Heartbeat: ${Math.round(this.MentorQ.ws.ping)}ms\n🏓 API Latency: ${msg.createdTimestamp - message.createdTimestamp}ms`)] });
24+
const pingEmbed = new EmbedBuilder()
25+
.setDescription(`💗 WS Heartbeat: ${Math.round(this.MentorQ.ws.ping)}ms\n🏓 API Latency: ${msg.createdTimestamp - message.createdTimestamp}ms`)
26+
.setColor("Blurple");
27+
28+
msg.edit({ content: "", embeds: [pingEmbed] });
2429

2530
return;
2631
}

managers/TicketsManager.js

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class TicketsManager {
1515
* @prop {string} team
1616
* @prop {string} title
1717
* @prop {string} language
18-
* @prop {string} techStack
1918
* @prop {string} description
2019
*/
2120

@@ -34,7 +33,6 @@ class TicketsManager {
3433
{ name: "Name:", value: requestData.name, inline: true },
3534
{ name: "Team Members:", value: requestData.team, inline: true },
3635
{ name: "Programming Language:", value: requestData.language },
37-
{ name: "Tech Stack:", value: requestData.techStack },
3836
])
3937
.setFooter({ text: `User ID: ${member.id}` })
4038
.setColor("Yellow")
@@ -65,12 +63,12 @@ class TicketsManager {
6563
*/
6664
async claim(mentor, qMessage) {
6765
const request = this.parseQueueEmbed(qMessage.embeds[0]);
68-
const newEmbed = new EmbedBuilder(qMessage.embeds[0].toJSON()).setColor("Green");
66+
const newEmbed = new EmbedBuilder(qMessage.embeds[0].toJSON());
6967

7068
const member = await this.MentorQ.util.fetchMember(mentor.guild, request.userID);
7169
if (!member) return;
7270

73-
const ticket = await this.getRequestsChannel().threads.create({
71+
const ticket = await this.getRequestsChannel(mentor.guild).threads.create({
7472
name: request.requestData.title + "-" + request.userID,
7573
type: ChannelType.PrivateThread,
7674
invitable: true,
@@ -90,9 +88,9 @@ class TicketsManager {
9088

9189
ticket.send({ content: `**Mentor:** ${mentor.toString()}\n**Hacker:** ${member.toString()}`, embeds: [newEmbed.setColor("Blurple")], components: [closeButton] });
9290

93-
member.send({ embeds: [this.MentorQ.util.infoEmbed(`Your mentor request ticket has been opened. Contact your mentor here: ${ticket.toString()}`)] }).catch(() => { });
91+
member.send({ embeds: [this.MentorQ.util.infoEmbed(`Your mentor request ticket has been opened.\nContact your mentor here: ${ticket.toString()}`)] }).catch(() => { });
9492

95-
qMessage.edit({ content: `❕ **CLAIMED** by <@${mentor.user.id}>`, embeds: [newEmbed], components: [] });
93+
qMessage.edit({ content: `❕ **CLAIMED** by <@${mentor.user.id}>`, embeds: [newEmbed.setColor("Green")], components: [] });
9694

9795
return ticket.toString();
9896
}
@@ -105,8 +103,8 @@ class TicketsManager {
105103
async close(mentor, ticketChannel) {
106104
if (ticketChannel.archived && ticketChannel.locked) return true;
107105

108-
await ticketChannel.setArchived(true, `Closed by: ${mentor.user.tag}`);
109106
await ticketChannel.setLocked(true, `Closed by: ${mentor.user.tag}`);
107+
await ticketChannel.setArchived(true, `Closed by: ${mentor.user.tag}`);
110108

111109
const member = await this.MentorQ.util.fetchMember(mentor.guild, ticketChannel.name.split("-")[1]);
112110
if (member) member.send({ embeds: [this.MentorQ.util.infoEmbed(`Your mentor ticket ${ticketChannel.toString()} has been **CLOSED** by ${mentor.user.tag}.`)] }).catch(() => { });
@@ -193,13 +191,13 @@ class TicketsManager {
193191
],
194192
});
195193

196-
const requestsChannel = this.getRequestsChannel() || await guild.channels.create({
194+
const requestsChannel = this.getRequestsChannel(guild) || await guild.channels.create({
197195
type: ChannelType.GuildText,
198196
name: "mentorq",
199197
parent: category,
200198
});
201199

202-
if (!this.getQueueChannel()) {
200+
if (!this.getQueueChannel(guild)) {
203201
await guild.channels.create({
204202
type: ChannelType.GuildText,
205203
name: "mentorq-queue",
@@ -267,27 +265,19 @@ class TicketsManager {
267265
.setLabel("What programming language(s) are you using?")
268266
.setRequired(true);
269267

270-
const techStackInput = new TextInputBuilder()
271-
.setCustomId("tech-stack-input")
272-
.setStyle(TextInputStyle.Short)
273-
.setLabel("What tools are you using for development (tech stack)?")
274-
.setPlaceholder("It's fine if you don't know yet!")
275-
.setRequired(true);
276-
277268
const descInput = new TextInputBuilder()
278269
.setCustomId("desc-input")
279270
.setStyle(TextInputStyle.Paragraph)
280271
.setLabel("Project Description:")
281-
.setPlaceholder("Give us any details about your project idea.")
272+
.setPlaceholder("Give us any details about your project idea and your tech stack (dev tools).")
282273
.setRequired(true);
283274

284275
mentorRequestModal.addComponents(
285-
new ActionRowBuilder(nameInput),
286-
new ActionRowBuilder(teamInput),
287-
new ActionRowBuilder(titleInput),
288-
new ActionRowBuilder(langInput),
289-
new ActionRowBuilder(techStackInput),
290-
new ActionRowBuilder(descInput),
276+
new ActionRowBuilder().addComponents(nameInput),
277+
new ActionRowBuilder().addComponents(teamInput),
278+
new ActionRowBuilder().addComponents(titleInput),
279+
new ActionRowBuilder().addComponents(langInput),
280+
new ActionRowBuilder().addComponents(descInput),
291281
);
292282

293283
return mentorRequestModal;
@@ -311,7 +301,6 @@ class TicketsManager {
311301
team: queueEmbed.fields[1].value,
312302
title: queueEmbed.title.substring(9),
313303
language: queueEmbed.fields[2].value,
314-
techStack: queueEmbed.fields[3].value,
315304
description: queueEmbed.description,
316305
};
317306
return { userID, requestData };

0 commit comments

Comments
 (0)