Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

Commit a98734f

Browse files
I hate you all
1 parent f29dc04 commit a98734f

File tree

4 files changed

+68
-51
lines changed

4 files changed

+68
-51
lines changed

src/commands/main/log.ts

Lines changed: 58 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import { SlashCommandBuilder, EmbedBuilder, ChatInputCommandInteraction } from "discord.js";
1+
/* import { SlashCommandBuilder, EmbedBuilder, ChatInputCommandInteraction } from "discord.js";
22
import mysql from "mysql";
33
import { KOGBot } from "index.ts";
4-
import { SlashCommand } from "main.d.ts"; //
4+
import { SlashCommand } from "main.d.ts";
55
66
const allowedroleID = ""; // Set this later when I have perms
77
const logchannel = ""; // log channel
88
const connection = mysql.createConnection({
9-
// goes here
9+
// database connection details
1010
});
1111
1212
class LogEventCommand implements SlashCommand {
1313
name = "log";
1414
description = "Logs official events for KOG.";
1515
subcommands = [];
1616
parameters = [];
17-
dev = true;
17+
dev = true;
1818
kogBot: KOGBot;
1919
2020
constructor(kogBot: KOGBot) {
@@ -35,11 +35,10 @@ class LogEventCommand implements SlashCommand {
3535
return;
3636
}
3737
38-
3938
const logStart = new EmbedBuilder()
4039
.setColor("#9033FF")
4140
.setTitle("Logging")
42-
.setDescription("To log an event, please follow the format:\n\n<@user1>,<@user2>,<@user3>...\n\nNames must be separated by commas and must be mentions.") // put peoples names here
41+
.setDescription("To log an event, please follow the format:\n\n<@user1>,<@user2>,<@user3>...\n\nNames must be separated by commas and must be mentions.")
4342
.setTimestamp();
4443
4544
await interaction.reply({ embeds: [logStart], ephemeral: true });
@@ -51,27 +50,31 @@ class LogEventCommand implements SlashCommand {
5150
const mentionRegexthing = /^<@\d+>(?:,\s?<@\d+>)*$/;
5251
5352
if (!mentionRegexthing.test(response!)) {
54-
return interaction.followUp("Invalid format. Please make sure the names are separated by commas and each name is a mention. Run the command again with the correct format.");
53+
await interaction.followUp("Invalid format. Please make sure the names are separated by commas and each name is a mention. Run the command again with the correct format.");
54+
return;
5555
}
5656
5757
if (response?.toLowerCase() === 'cancel') {
58-
return interaction.reply(`<@${interaction.user.id}> canceled the event log.`);
58+
await interaction.reply(`<@${interaction.user.id}> canceled the event log.`);
59+
return;
5960
}
6061
6162
if (response instanceof Error && response.message === 'time') {
62-
return interaction.reply(`<@${interaction.user.id}> you took too long to follow up, please try again.`);
63+
await interaction.reply(`<@${interaction.user.id}> you took too long to follow up, please try again.`);
64+
return;
6365
}
6466
6567
const mentions = response.split(',').map((id: string) => id.trim().replace('<@', '').replace('>', ''));
6668
const userIds: string[] = [];
6769
6870
for (const mention of mentions) {
69-
const userId = mention.slice(2, -1);
71+
const userId = mention.replace('<@', '').replace('>', '');
7072
if (userId) userIds.push(userId);
7173
}
7274
7375
if (userIds.length === 0) {
74-
return interaction.reply("No users mentioned. Please try again.");
76+
await interaction.reply("No users mentioned. Please try again.");
77+
return;
7578
}
7679
7780
// Log the event in the log channel
@@ -83,64 +86,69 @@ class LogEventCommand implements SlashCommand {
8386
.setTimestamp();
8487
8588
const logChannel = await interaction.client.channels.fetch(logchannel);
86-
if (logChannel) {
89+
if (logChannel?.isText()) {
8790
await logChannel.send({ embeds: [logEmbed] });
8891
}
8992
90-
9193
for (const userId of userIds) {
92-
connection.query(// 'SELECT COUNT(*) AS eventCount FROM events WHERE userId = ?' this is not final (async will do db)
93-
, [userId], async (err, results) => {
94-
if (err) {
95-
console.error(err);
96-
return interaction.followUp("There was an error querying the database.");
97-
}
98-
99-
const eventCount = results[0]?.eventCount || 0;
100-
101-
102-
103-
104-
if (eventCount === 5) {
105-
const promotionEmbed = new EmbedBuilder()
106-
.setColor("#FFBF00")
107-
.setTitle("Promotion Needed")
108-
.setDescription(`<@${userId}> has reached 5 events! This user needs promoting.`)
109-
.setTimestamp();
110-
} else if (eventCount >= 10) {
111-
const promotionEmbed = new EmbedBuilder()
112-
.setColor("#FFD700")
113-
.setTitle("Promotion Needed")
114-
.setDescription(`<@${userId}> has reached 10 events! Consider promoting them.`)
115-
.setTimestamp();
94+
connection.query(
95+
'SELECT COUNT(*) AS eventCount FROM events WHERE userId = ?',
96+
[userId],
97+
async (err, results) => {
98+
if (err) {
99+
console.error(err);
100+
await interaction.followUp("There was an error querying the database.");
101+
return;
102+
}
103+
104+
const eventCount = results[0]?.eventCount || 0;
105+
let promotionEmbed: any;
106+
107+
if (eventCount === 5) {
108+
promotionEmbed = new EmbedBuilder()
109+
.setColor("#FFBF00")
110+
.setTitle("Promotion Needed")
111+
.setDescription(`<@${userId}> has reached 5 events! This user needs promoting.`)
112+
.setTimestamp();
113+
} else if (eventCount >= 10) {
114+
promotionEmbed = new EmbedBuilder()
115+
.setColor("#FFD700")
116+
.setTitle("Promotion Needed")
117+
.setDescription(`<@${userId}> has reached 10 events! Consider promoting them.`)
118+
.setTimestamp();
119+
}
120+
121+
if (promotionEmbed && logChannel?.isText()) {
122+
await logChannel.send({ embeds: [promotionEmbed] });
123+
}
116124
}
117-
118-
/
119-
if (promotionEmbed) {
120-
await logChannel.send({ embeds: [promotionEmbed] });
121-
}
122-
});
125+
);
123126
}
124127
125128
// database updating goes here
126-
127129
128-
if () { // database logging
130+
const isDatabaseUpdated = true; // "oh its updated"
131+
132+
if (isDatabaseUpdated) {
129133
const dbEmbed = new EmbedBuilder()
130134
.setColor("#9033FF")
131135
.setTitle("Log Event")
132136
.setDescription("Database updated, event has been logged successfully.")
133137
.setTimestamp();
134138
135-
await logChannel.send({ embeds: [dbEmbed] });
139+
if (logChannel) {
140+
await logChannel.send({ embeds: [dbEmbed] });
141+
}
136142
} else {
137143
const errorEmbed = new EmbedBuilder()
138144
.setColor("#E73A3A")
139145
.setTitle("Error")
140146
.setDescription("An error occurred while updating the DB. The database has not been updated, and the log has failed.\nContact the admin for support.")
141147
.setTimestamp();
142148
143-
await logChannel.send({ embeds: [errorEmbed] });
149+
if (logChannel) {
150+
await logChannel.send({ embeds: [errorEmbed] });
151+
}
144152
}
145153
146154
} catch (error) {
@@ -157,3 +165,6 @@ class LogEventCommand implements SlashCommand {
157165
}
158166
159167
export default LogEventCommand;
168+
169+
*/
170+

src/commands/main/mydata.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { SlashCommandBuilder, EmbedBuilder, ChatInputCommandInteraction } from "discord.js";
1+
/* import { SlashCommandBuilder, EmbedBuilder, ChatInputCommandInteraction } from "discord.js";
22
import mysql from "mysql";
33
import { KOGBot } from "index.ts";
44
import { SlashCommand } from "main.d.ts";
@@ -71,3 +71,5 @@ class GetDataCommand implements SlashCommand {
7171
}
7272
7373
export default GetDataCommand;
74+
75+
*/

src/commands/misc/kill.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { SlashCommandBuilder, EmbedBuilder, ChatInputCommandInteraction, SlashCommand } from "discord.js";
1+
/* import { SlashCommandBuilder, EmbedBuilder, ChatInputCommandInteraction, SlashCommand } from "discord.js";
22
import { KOGBot } from "index.ts";
33
44
class KillCommand implements SlashCommand {
@@ -42,3 +42,5 @@ class KillCommand implements SlashCommand {
4242
}
4343
4444
export default KillCommand;
45+
46+
*/

src/commands/misc/ping.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { SlashCommandBuilder, EmbedBuilder, ChatInputCommandInteraction } from "discord.js";
1+
/* import { SlashCommandBuilder, EmbedBuilder, ChatInputCommandInteraction } from "discord.js";
22
import { KOGBot } from "index.ts";
3-
import { SlashCommand } from "main.d.ts"; =
3+
import { SlashCommand } from "main.d.ts";
44
55
class PingCommand implements SlashCommand {
66
name = 'ping';
@@ -41,3 +41,5 @@ class PingCommand implements SlashCommand {
4141
}
4242
4343
export default PingCommand;
44+
45+
*/

0 commit comments

Comments
 (0)