V1.4.0 Completed
This update adds a handful of new features and readies the API for public use. Detailed changes below:
config.example.ts - Bumped version, added local testing options, added prefill data, changed default logging to false, moved long strings for help and rollhelp to longStrings.ts
db/initialize.ts (previously initDB.ts) - Relocated file for organization, added local options, added new command count and allowed guilds table, created stored procedure for counting commands
db/populateDefaults.ts - Fills in db with default values, adding admin's api key and populating the command count table
flags.ts - Centralized flags for dev/local modes
longStrings.ts - Moved all long string commands to here, contains help, rollhelp, apihelp, info, and privacy commands
mod.ts - Moved flags out into flags.ts, implemented local mode for development, implemented command counting for basic statistics, added info and privacy commands for user help, added more stats to the stats command, added api command, allowing users to allow or block api rolls from happening in their server, reformatted API code, using proper HTTP methods, makes sure api is allowed to roll into chosen guild, added delete endpoint to remove user's data from the database, added endpoint to allow the general public to generate their own api keys
PRIVACY.md - I got bored and wrote a privacy policy, detailing how little data is collected and how the user can have their data removed
README.md - Added new commands to README, updated API documentation, added delete endpoint, updated self hosting details
src/utils.ts - Bumped discordeno version
www/api - Built API website
www/home (previously located in www) - Moved for better organization, minor fixes, updated API details,
2021-02-12 20:26:33 -08:00
|
|
|
// This file will populate the tables with default values
|
|
|
|
|
2021-02-19 17:44:38 -08:00
|
|
|
import {
|
|
|
|
// MySQL deps
|
|
|
|
Client
|
|
|
|
} from "../deps.ts";
|
V1.4.0 Completed
This update adds a handful of new features and readies the API for public use. Detailed changes below:
config.example.ts - Bumped version, added local testing options, added prefill data, changed default logging to false, moved long strings for help and rollhelp to longStrings.ts
db/initialize.ts (previously initDB.ts) - Relocated file for organization, added local options, added new command count and allowed guilds table, created stored procedure for counting commands
db/populateDefaults.ts - Fills in db with default values, adding admin's api key and populating the command count table
flags.ts - Centralized flags for dev/local modes
longStrings.ts - Moved all long string commands to here, contains help, rollhelp, apihelp, info, and privacy commands
mod.ts - Moved flags out into flags.ts, implemented local mode for development, implemented command counting for basic statistics, added info and privacy commands for user help, added more stats to the stats command, added api command, allowing users to allow or block api rolls from happening in their server, reformatted API code, using proper HTTP methods, makes sure api is allowed to roll into chosen guild, added delete endpoint to remove user's data from the database, added endpoint to allow the general public to generate their own api keys
PRIVACY.md - I got bored and wrote a privacy policy, detailing how little data is collected and how the user can have their data removed
README.md - Added new commands to README, updated API documentation, added delete endpoint, updated self hosting details
src/utils.ts - Bumped discordeno version
www/api - Built API website
www/home (previously located in www) - Moved for better organization, minor fixes, updated API details,
2021-02-12 20:26:33 -08:00
|
|
|
|
|
|
|
import { LOCALMODE } from "../flags.ts";
|
|
|
|
import config from "../config.ts";
|
|
|
|
|
|
|
|
// Log into the MySQL DB
|
|
|
|
const dbClient = await new Client().connect({
|
|
|
|
hostname: LOCALMODE ? config.db.localhost : config.db.host,
|
|
|
|
port: config.db.port,
|
|
|
|
db: config.db.name,
|
|
|
|
username: config.db.username,
|
|
|
|
password: config.db.password,
|
|
|
|
});
|
|
|
|
|
|
|
|
console.log("Attempting to populate DB Admin API key");
|
|
|
|
await dbClient.execute("INSERT INTO all_keys(userid,apiKey) values(?,?)", [config.api.admin, config.api.adminKey]).catch(e => {
|
|
|
|
console.log("Failed to insert into database", e);
|
|
|
|
});
|
|
|
|
console.log("Inesrtion done");
|
|
|
|
|
|
|
|
console.log("Attempting to insert default commands into command_cnt");
|
|
|
|
const commands = ["ping", "rip", "rollhelp", "help", "info", "version", "report", "stats", "roll", "emojis", "api", "privacy"];
|
|
|
|
for (let i = 0; i < commands.length; i++) {
|
|
|
|
await dbClient.execute("INSERT INTO command_cnt(command) values(?)", [commands[i]]).catch(e => {
|
|
|
|
console.log(`Failed to insert into database`, e);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
console.log("Insertion done");
|
|
|
|
|
|
|
|
await dbClient.close();
|
|
|
|
console.log("Done!");
|