better naming

This commit is contained in:
Hexugory 2023-03-29 14:33:44 -05:00
parent 7a979cda75
commit 0fb8358a86
7 changed files with 20 additions and 20 deletions

View File

@ -4,7 +4,7 @@ import strings from "./clientstrings.json";
import { Sequelize } from "sequelize"; import { Sequelize } from "sequelize";
import { CommandList } from "./commands/commandlist"; import { CommandList } from "./commands/commandlist";
import { Command } from "./commands/command"; import { Command } from "./commands/command";
import { BlacklistUsers } from "./models/blacklistusers"; import { BlacklistUser } from "./models/blacklistuser";
import { CommandBlacklist } from "./models/commandblacklist"; import { CommandBlacklist } from "./models/commandblacklist";
import { SlashCommand } from "./slash/slash"; import { SlashCommand } from "./slash/slash";
import { SlashCommandList } from "./slash/commandlist"; import { SlashCommandList } from "./slash/commandlist";
@ -30,7 +30,7 @@ export class CommandClient extends Client {
this.on('messageCreate', async (msg: Message) => { this.on('messageCreate', async (msg: Message) => {
if (!msg.content.startsWith(config.prefix) || msg.author.bot) return; if (!msg.content.startsWith(config.prefix) || msg.author.bot) return;
if (!config.owners.includes(msg.author.id) && (await BlacklistUsers.findOne({ where: { user_id: msg.author.id } }))) return; if (!config.owners.includes(msg.author.id) && (await BlacklistUser.findOne({ where: { user_id: msg.author.id } }))) return;
this.parseCommand(msg); this.parseCommand(msg);
}); });

View File

@ -1,7 +1,7 @@
import { Message, User } from "discord.js" import { Message, User } from "discord.js"
import { Command } from "./command" import { Command } from "./command"
import { UserArgument } from "../types/user" import { UserArgument } from "../types/user"
import { BlacklistUsers } from "../models/blacklistusers" import { BlacklistUser } from "../models/blacklistuser"
interface GlobalBlacklistArguments { interface GlobalBlacklistArguments {
users: User[] users: User[]
@ -29,14 +29,14 @@ export class GlobalBlacklistCommand implements Command {
let replystr = ''; let replystr = '';
for (const user of args.users){ for (const user of args.users){
const row = (await BlacklistUsers.findOne({ where: { user_id: user.id } })); const row = (await BlacklistUser.findOne({ where: { user_id: user.id } }));
if (row) { if (row) {
row.destroy() row.destroy()
replystr += `${user.tag}: removed\n` replystr += `${user.tag}: removed\n`
} }
else { else {
await BlacklistUsers.create({ user_id: user.id }); await BlacklistUser.create({ user_id: user.id });
replystr += `${user.tag}: added\n` replystr += `${user.tag}: added\n`
} }
} }

View File

@ -1,7 +1,7 @@
import { DataTypes, Sequelize } from "sequelize"; import { DataTypes, Sequelize } from "sequelize";
import { BlacklistUsers } from "./models/blacklistusers"; import { BlacklistUser } from "./models/blacklistuser";
import { CommandBlacklist } from "./models/commandblacklist"; import { CommandBlacklist } from "./models/commandblacklist";
import { Players } from "./models/players"; import { Player } from "./models/player";
export const db = new Sequelize({ export const db = new Sequelize({
dialect: 'sqlite', dialect: 'sqlite',
@ -9,14 +9,14 @@ export const db = new Sequelize({
logging: false logging: false
}); });
BlacklistUsers.init({ BlacklistUser.init({
user_id: { user_id: {
type: DataTypes.TEXT, type: DataTypes.TEXT,
primaryKey: true primaryKey: true
} }
}, },
{ {
tableName: 'BlacklistUsers', tableName: 'BlacklistUser',
sequelize: db sequelize: db
}); });
@ -33,7 +33,7 @@ CommandBlacklist.init({
sequelize: db sequelize: db
}); });
Players.init({ Player.init({
user_id: { user_id: {
type: DataTypes.TEXT, type: DataTypes.TEXT,
primaryKey: true primaryKey: true
@ -47,7 +47,7 @@ Players.init({
} }
}, },
{ {
tableName: 'Players', tableName: 'Player',
sequelize: db sequelize: db
}); });

View File

@ -0,0 +1,5 @@
import { InferAttributes, InferCreationAttributes, Model } from "sequelize";
export class BlacklistUser extends Model<InferAttributes<BlacklistUser>, InferCreationAttributes<BlacklistUser>> {
declare readonly user_id: string
}

View File

@ -1,5 +0,0 @@
import { InferAttributes, InferCreationAttributes, Model } from "sequelize";
export class BlacklistUsers extends Model<InferAttributes<BlacklistUsers>, InferCreationAttributes<BlacklistUsers>> {
declare readonly user_id: string
}

View File

@ -1,6 +1,6 @@
import { CreationOptional, InferAttributes, InferCreationAttributes, Model } from "sequelize"; import { CreationOptional, InferAttributes, InferCreationAttributes, Model } from "sequelize";
export class Players extends Model<InferAttributes<Players>, InferCreationAttributes<Players>> { export class Player extends Model<InferAttributes<Player>, InferCreationAttributes<Player>> {
declare readonly user_id: string declare readonly user_id: string
declare start: number declare start: number
declare spent: CreationOptional<number> declare spent: CreationOptional<number>

View File

@ -1,5 +1,5 @@
import { ApplicationCommandOptionData, ApplicationCommandOptionType, CommandInteraction } from "discord.js" import { ApplicationCommandOptionData, ApplicationCommandOptionType, CommandInteraction } from "discord.js"
import { Players } from "../models/players" import { Player } from "../models/player"
import { SlashCommand } from "./slash" import { SlashCommand } from "./slash"
export class InitCommand implements SlashCommand { export class InitCommand implements SlashCommand {
@ -11,7 +11,7 @@ export class InitCommand implements SlashCommand {
args: ApplicationCommandOptionData[] = [] args: ApplicationCommandOptionData[] = []
async execute(int: CommandInteraction) { async execute(int: CommandInteraction) {
const player = await Players.findOne({ const player = await Player.findOne({
where: { where: {
user_id: int.user.id user_id: int.user.id
} }
@ -22,7 +22,7 @@ export class InitCommand implements SlashCommand {
ephemeral: true ephemeral: true
}); });
Players.create({ Player.create({
user_id: int.user.id, user_id: int.user.id,
start: Math.floor(Date.now()/1000) start: Math.floor(Date.now()/1000)
}); });