Skip to content

Commit 3700dc0

Browse files
author
xyzjesper
committed
ticket(fix): Transcription channel from closing action not working correctly. tags(fix): Tag module and re-registration from tag commands. bot(fix): readyEvent. component(added): sone Components V2 Editor structure. general(added): automatic versioning via Github.
1 parent 46032d9 commit 3700dc0

30 files changed

+575
-434
lines changed

prisma/schema.prisma

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -615,13 +615,15 @@ model GuildLogs {
615615
}
616616

617617
model MessageTemplates {
618-
Id Int @id @default(autoincrement())
619-
Content String?
620-
EmbedJSON String?
621-
OtherEmbeds String[]
622-
Name String @unique
623-
GuildId String
624-
Guilds Guilds @relation(fields: [GuildId], references: [GuildId])
618+
Id Int @id @default(autoincrement())
619+
Content String?
620+
EmbedJSON String?
621+
ComponentJSON String?
622+
IsComponentsV2Message Boolean @default(false)
623+
OtherEmbeds String[]
624+
Name String @unique
625+
GuildId String
626+
Guilds Guilds @relation(fields: [GuildId], references: [GuildId])
625627
}
626628

627629
model GuildReactionRoles {
@@ -709,8 +711,8 @@ model Tags {
709711
TagId String @unique
710712
TriggerKeywords String[] // SOON && NEW
711713
MessageTemplateId String?
712-
IsShlashCommand Boolean
713-
ShlashCommandId String?
714+
IsSlashCommand Boolean
715+
SlashCommandId String?
714716
IsTextInputCommand Boolean
715717
IsEnabled Boolean
716718
PermissionRoleId String?

src/api/restAPI/api.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@ import multer from "multer";
55
import {Logger} from "../../main/logger.js";
66
import {LoggingAction} from "../../enums/loggingTypes.js";
77
import cors from "cors";
8-
import {botData} from "../../main/version.js";
8+
import {versionData} from "../../main/version.js";
99
import {Config} from "../../main/config.js";
1010
import {discoveryApi} from "./routes/get/discovery.js";
1111
import {banList} from "./routes/get/banlist.js";
1212

1313
export const APIServer = express();
1414

1515
export async function api(client: ExtendedClient) {
16-
const upload = multer();
17-
1816
// Default Values
1917
APIServer.set("client", client);
2018
APIServer.use(cors());
@@ -26,7 +24,8 @@ export async function api(client: ExtendedClient) {
2624
APIServer.get("/v2/bot/discovery", discoveryApi);
2725

2826
APIServer.get("/version", async (req, res): Promise<void> => {
29-
res.status(200).json({version: botData.version});
27+
const version = (await versionData()).version
28+
res.status(200).json({version: version});
3029
});
3130

3231
APIServer.get("/", async (req, res): Promise<void> => {

src/helper/CommandHelper.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,38 @@ export class CommandHelper {
211211
}
212212
}
213213

214+
const tagsData = await database.tags.findMany({
215+
where: {
216+
GuildId: guild.id
217+
}
218+
})
219+
220+
for (const tag of tagsData) {
221+
const clientGuild = await client.guilds.fetch(guild.id);
222+
223+
let guildCommand = null;
224+
try {
225+
guildCommand = await clientGuild.commands.fetch(tag.SlashCommandId);
226+
} catch {
227+
}
228+
229+
if (!guildCommand) {
230+
guildCommand = await clientGuild.commands.create({
231+
name: tag.TagId,
232+
description: tag.CommandDescription ?? "",
233+
});
234+
235+
await database.tags.update({
236+
where: {
237+
UUID: tag.UUID,
238+
},
239+
data: {
240+
IsSlashCommand: true,
241+
SlashCommandId: guildCommand.id,
242+
},
243+
});
244+
}
245+
}
214246
} catch (e) {
215247
Logger.error({
216248
timestamp: new Date().toISOString(),
@@ -454,7 +486,7 @@ export class CommandHelper {
454486

455487
}
456488

457-
public static async guildLoadCommands(client: ExtendedClient) {
489+
public static async adminGuildLoadCommands(client: ExtendedClient) {
458490
const cmdlist: any[] = [];
459491

460492
const commandFiles = fs

src/helper/databaseHelper.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {ExtendedClient} from "../types/client.js";
22
import {default as axios} from "axios";
33
import {database} from "../main/database.js";
4-
import {botData} from "../main/version.js";
4+
import {versionData} from "../main/version.js";
55
import {Logger} from "../main/logger.js";
66
import {LoggingAction} from "../enums/loggingTypes.js";
77
import colors from "colors"
@@ -40,24 +40,24 @@ export async function setupDisBotConfig(client: ExtendedClient): Promise<void> {
4040
GetConf: "config"
4141
}
4242
})
43+
const version = await versionData()
4344
if (!disbotConfig) {
4445
await database.disBot.create({
4546
data: {
4647
GetConf: "config",
47-
Version: botData.version,
48+
Version: version.version,
4849
Logs: [],
4950
SpotifyToken: authData.access_token,
5051
TwitchToken: twitchAccessToken
5152
}
5253
})
5354
}
54-
5555
await database.disBot.update({
5656
where: {
5757
GetConf: "config",
5858
},
5959
data: {
60-
Version: botData.version,
60+
Version: version.version,
6161
Logs: [],
6262
SpotifyToken: authData.access_token,
6363
TwitchToken: twitchAccessToken
@@ -319,5 +319,5 @@ export async function initUsersToDatabase(client: ExtendedClient, user: User) {
319319
}
320320

321321
export async function migrateDataBase(client?: ExtendedClient) {
322-
322+
323323
}

src/helper/readyHelper.ts

Lines changed: 0 additions & 116 deletions
This file was deleted.

src/helper/ticketHelper.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -971,22 +971,23 @@ export async function handleCloseAction(client: ExtendedClient, guild: Guild, ch
971971
})
972972

973973
const tChannel = await guild.channels.fetch(data.TranscriptChannelId) as TextChannel | PrivateThreadChannel
974+
if (tChannel) {
975+
const transcript = await ticketTranscriptBuilder(
976+
ticketId,
977+
client,
978+
guild,
979+
channel,
980+
null,
981+
interaction ?? null
982+
)
974983

975-
const transcript = await ticketTranscriptBuilder(
976-
ticketId,
977-
client,
978-
guild,
979-
channel,
980-
null,
981-
interaction ?? null
982-
)
983-
984-
const message = await tChannel.send(transcript as MessageCreateOptions)
984+
const message = await tChannel.send(transcript as MessageCreateOptions)
985985

986-
if (!isAuto)
987-
await interaction.editReply({
988-
content: `## ${await convertToEmojiPng("check", client.user.id)} Exported Ticket-Transcript ${message.url}`,
989-
})
986+
if (!isAuto)
987+
await interaction.editReply({
988+
content: `## ${await convertToEmojiPng("check", client.user.id)} Exported Ticket-Transcript ${message.url}`,
989+
})
990+
}
990991
}
991992
if (data.OldTicketCategoryId) {
992993
actionCounter += 1

src/internal/commands/reload.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ export default {
2121
await loadEvents(client);
2222

2323
await CommandHelper.loadCommands(client);
24-
await CommandHelper.guildLoadCommands(client);
24+
await CommandHelper.adminGuildLoadCommands(client);
25+
26+
const guilds = await client.guilds.fetch();
27+
for (const fakeGuild of guilds.values()) {
28+
const guild = await client.guilds.fetch(fakeGuild.id)
29+
await CommandHelper.loadCommandsForGuild(client, guild);
30+
}
2531

2632
await interaction.reply({
2733
content: "## Reload the Bot Modules",

src/main/bot.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ import {loadSelectMenus} from "../handler/files/selectmenus.js";
1818
import {ExtendedClient} from "../types/client.js";
1919
import {Logger} from "./logger.js";
2020
import {LoggingAction} from "../enums/loggingTypes.js";
21-
import {connectToDatabase, initDataToDatabase} from "./database.js";
22-
import {botData} from "./version.js";
21+
import {connectToDatabase} from "./database.js";
2322
import {CommandHelper} from "../helper/CommandHelper.js";
24-
import {clientReady} from "../helper/readyHelper.js";
23+
2524
import {Config, configStartup} from "./config.js";
2625

2726
colors.enable();
@@ -140,9 +139,6 @@ async function initializeClient() {
140139
await loadModals(client);
141140
await loadButtons(client);
142141
await loadEvents(client);
143-
144-
await CommandHelper.loadCommands(client);
145-
await CommandHelper.guildLoadCommands(client);
146142
}
147143

148144
initializeClient()
@@ -179,19 +175,13 @@ client
179175
botType: Config.BotType.toString() || "Unknown",
180176
action: LoggingAction.Other,
181177
});
182-
client.once(Events.ClientReady, async () => {
183-
clientReady(client);
184-
await initDataToDatabase(client)
185-
});
186-
187178
process.setMaxListeners(0);
188179
client.setMaxListeners(0);
189180
if (process.env.SENTRY_DSN) {
190181
Sentry.init({
191182
dsn: process.env.SENTRY_DSN,
192183
tracesSampleRate: 1.0,
193184
environment: process.env.NODE_ENV || "development",
194-
release: botData.version,
195185
});
196186
}
197187
})

0 commit comments

Comments
 (0)