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

Commit 01636fc

Browse files
committed
removed cancer
1 parent c559dec commit 01636fc

File tree

1 file changed

+1
-122
lines changed

1 file changed

+1
-122
lines changed

src/commands/main/log.ts

Lines changed: 1 addition & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -13,128 +13,7 @@ class LogEventCommand implements SlashCommand {
1313
}
1414

1515
async execute(interaction: ChatInputCommandInteraction): Promise<void> {
16-
const allowedroleID = this.kogBot.environment.roles.mr_role;
17-
const logChannel = this.kogBot.environment.discord.logChannel;
18-
const userId = interaction.user.id; // Needed for DB
19-
20-
// Check for required role
21-
if (interaction.user.id !== '1344176447551574078' &&
22-
(!(interaction.member?.roles instanceof GuildMemberRoleManager) || !interaction.member.roles.cache.has(allowedroleID))) {
23-
const noperms = new EmbedBuilder()
24-
.setColor(Colors.Red)
25-
.setTitle('Error')
26-
.setDescription("You don't have the required role to use this command.")
27-
.setTimestamp()
28-
.setFooter({
29-
text: `Kleiner Oil Group`,
30-
iconURL: interaction.guild?.iconURL() as string
31-
})
32-
33-
await interaction.reply({ embeds: [noperms] });
34-
return;
35-
}
36-
37-
const logStart = new EmbedBuilder()
38-
.setColor(Colors.Yellow)
39-
.setTitle('Logging')
40-
.setDescription('To log an event, please follow the format:\n\n<@1138235120424325160>,<@573540579682811906>,<@1344176447551574078>,<@110877167897853952>,<@1125601338768756756>...\n\nNames must be separated by commas and must be mentions.')
41-
.setTimestamp();
42-
43-
await interaction.reply({ embeds: [logStart] });
44-
45-
if (!interaction.channel) {
46-
await interaction.reply('Channel not found.');
47-
return;
48-
}
49-
50-
const filter = (response: any) => response.user.id === interaction.user.id;
51-
const collected = await interaction.channel.awaitMessageComponent({ filter, time: 60_000 }).catch(() => console.log("hi"));
52-
const response = collected?.isMessageComponent() ? collected.message.content : null;
53-
54-
const mentionRegexthing = /^<@\d+>(?:,\s?<@\d+>)*$/;
55-
56-
if (!mentionRegexthing.test(response!)) {
57-
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.');
58-
return;
59-
}
60-
61-
if (response?.toLowerCase() === 'cancel') {
62-
await interaction.reply(`<@${interaction.user.id}> canceled the event log.`);
63-
return;
64-
}
65-
66-
if (response && typeof response === 'object' && 'message' in response && (response as any).message === 'time') {
67-
await interaction.reply(`<@${interaction.user.id}> you took too long to follow up, please try again.`);
68-
return;
69-
}
70-
71-
if (!response) {
72-
await interaction.followUp('No response received. Please try again.');
73-
return;
74-
}
75-
const mentions = response.split(',').map((id: string) => id.trim().replace('<@', '').replace('>', ''));
76-
const userIds: string[] = [];
77-
78-
for (const mention of mentions) {
79-
const userId = mention.replace('<@', '').replace('>', '');
80-
if (userId) userIds.push(userId);
81-
}
82-
83-
if (userIds.length === 0) {
84-
await interaction.reply('No users mentioned. Please try again.');
85-
return;
86-
}
87-
88-
const host = interaction.user.id;
89-
userIds.push(host);
90-
91-
const timestamp = Math.floor(Date.now() / 1000);
92-
const logEmbed = new EmbedBuilder()
93-
.setColor('#9033FF')
94-
.setTitle('Event log')
95-
.setDescription(`A new event was logged.\n\nHost: <@${host}>\n\nTime: <t:${timestamp}:F>\n\nAttendees: ${mentions.map((id: string) => `<@${id}>`).join(', ')}\n\nSquadron Rally: False`)
96-
.setTimestamp();
97-
98-
if (logChannel) {
99-
await logChannel.send({ embeds: [logEmbed] });
100-
}
101-
102-
for (const userId of userIds) {
103-
try {
104-
const results = await db('KOGDB').where({ userId });
105-
106-
if (results.length > 0) {
107-
if (userId === host) {
108-
await db('KOGDB').where({ userId }).update({
109-
eventsAttended: db.raw('eventsAttended + 1'),
110-
eventsHosted: db.raw('eventsHosted + 1')
111-
});
112-
} else {
113-
await db('KOGDB').where({ userId }).update({
114-
eventsAttended: db.raw('eventsAttended + 1')
115-
});
116-
}
117-
} else {
118-
if (userId === host) {
119-
await db('KOGDB').insert({ userId, eventsAttended: 1, eventsHosted: 1 });
120-
} else {
121-
await db('KOGDB').insert({ userId, eventsAttended: 1, eventsHosted: 0 });
122-
}
123-
}
124-
} catch (err) {
125-
console.error(err);
126-
}
127-
}
128-
129-
const dbEmbed = new EmbedBuilder()
130-
.setColor('#9033FF')
131-
.setTitle('Log Event')
132-
.setDescription('Database updated, event has been logged successfully.')
133-
.setTimestamp();
134-
135-
if (logChannel) {
136-
await logChannel.send({ embeds: [dbEmbed] });
137-
}
16+
return;
13817
}
13918
}
14019

0 commit comments

Comments
 (0)