forked from cadence/out-of-your-element
Finish moving from SQL to New Funny ORM
This commit is contained in:
parent
4e1e590c3a
commit
79bd0254f0
19 changed files with 87 additions and 87 deletions
|
@ -3,7 +3,7 @@
|
|||
const assert = require("assert")
|
||||
|
||||
const passthrough = require("../../passthrough")
|
||||
const { sync, db } = passthrough
|
||||
const {select} = passthrough
|
||||
|
||||
/**
|
||||
* Downcased and stripped username. Can only include a basic set of characters.
|
||||
|
@ -53,7 +53,7 @@ function userToSimName(user) {
|
|||
assert.notEqual(user.discriminator, "0000", "cannot create user for a webhook")
|
||||
|
||||
// 1. Is sim user already registered?
|
||||
const existing = db.prepare("SELECT sim_name FROM sim WHERE discord_id = ?").pluck().get(user.id)
|
||||
const existing = select("sim", "sim_name", "WHERE discord_id = ?").pluck().get(user.id)
|
||||
if (existing) return existing
|
||||
|
||||
// 2. Register based on username (could be new or old format)
|
||||
|
@ -64,8 +64,7 @@ function userToSimName(user) {
|
|||
}
|
||||
|
||||
// Check for conflicts with already registered sims
|
||||
/** @type {string[]} */
|
||||
const matches = db.prepare("SELECT sim_name FROM sim WHERE sim_name LIKE ? ESCAPE '@'").pluck().all(downcased + "%")
|
||||
const matches = select("sim", "sim_name", "WHERE sim_name LIKE ? ESCAPE '@'").pluck().all(downcased + "%")
|
||||
// Keep generating until we get a suggestion that doesn't conflict
|
||||
for (const suggestion of generateLocalpartAlternatives(preferences)) {
|
||||
if (!matches.includes(suggestion)) return suggestion
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue