Skip to content

Commit

Permalink
fix(databses): Edit databse starter comment
Browse files Browse the repository at this point in the history
Signed-off-by: cobalt <61329810+RedGuy12@users.noreply.github.com>
  • Loading branch information
cobaltt7 committed Jul 17, 2024
1 parent 3650d54 commit 592bff1
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions common/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,30 @@ for (const message of allDatabaseMessages) {
}
}

const contructed: string[] = [];
const contructed = new Set<string>();

export default class Database<Data extends Record<string, boolean | number | string | null>> {
message: Message<true> | undefined;
#data: readonly Data[] = [];

constructor(public name: string) {
if (contructed.includes(name)) {
this.name = name.replaceAll(" ", "_");
if (contructed.has(this.name)) {
throw new RangeError(
`Cannot create a second database for ${name}, they may have conflicting data`,
`Cannot create a second database for ${this.name}, they may have conflicting data`,
);
}
contructed.push(name);
contructed.add(this.name);
}

async init(): Promise<void> {
if (this.message) return;
this.message = databases[this.name] ||= await databaseThread.send(
`__**SCRADD ${this.name.toUpperCase()} DATABASE**__\n\n*Please don’t delete this message. If you do, all ${this.name.replaceAll(
"_",
" ",
)} information may be reset.*`,
);

const content =
`__**${client.user.displayName.replaceAll(" ", "-").toUpperCase()} ${this.name.toUpperCase()} DATABASE**__\n\n` +
`*Please don’t delete this message. If you do, all ${this.name.replaceAll("_", " ")} information may be reset.*`;
if (databases[this.name]) await databases[this.name]?.edit(content);
this.message = databases[this.name] ||= await databaseThread.send(content);

const attachment = this.message.attachments.first();
if (!attachment) {
Expand Down

0 comments on commit 592bff1

Please sign in to comment.