mirror of
https://github.com/zkldi/Tachi.git
synced 2026-09-29 10:28:04 +03:00
change how namegen worked to be sync
This commit is contained in:
@@ -1,38 +1,9 @@
|
||||
import db from "../../../../db/db";
|
||||
import { KtLogger } from "../../../../types";
|
||||
import { GetRandomAdjective, GetRandomNoun } from "../../../../data/words";
|
||||
|
||||
export async function GenerateRandomSessionName(logger: KtLogger) {
|
||||
let adjectives = await db.adjectives.aggregate([
|
||||
{
|
||||
$sample: {
|
||||
size: 2,
|
||||
},
|
||||
},
|
||||
]);
|
||||
export function GenerateRandomSessionName() {
|
||||
let adj1 = GetRandomAdjective();
|
||||
let adj2 = GetRandomAdjective();
|
||||
let noun = GetRandomNoun();
|
||||
|
||||
let nouns = await db.nouns.aggregate([
|
||||
{
|
||||
$sample: {
|
||||
size: 1,
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
if (adjectives.length < 2) {
|
||||
logger.severe(
|
||||
`Could not source 2 adjectives from the adjectives DB. Filling in with defaults, but this should be investigated.`
|
||||
);
|
||||
|
||||
adjectives = ["Ambient", "Scary"];
|
||||
}
|
||||
|
||||
if (nouns.length < 1) {
|
||||
logger.severe(
|
||||
`Could not source a noun from the noun DB. Filling in with defaults, but this should be investigated.`
|
||||
);
|
||||
|
||||
nouns = ["Noise"];
|
||||
}
|
||||
|
||||
return `${adjectives[0].text} ${adjectives[1].text} ${nouns[0].text}`;
|
||||
return `${adj1} ${adj2} ${noun}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user