better naming
This commit is contained in:
		
							parent
							
								
									7a979cda75
								
							
						
					
					
						commit
						0fb8358a86
					
				| @ -4,7 +4,7 @@ import strings from "./clientstrings.json"; | ||||
| import { Sequelize } from "sequelize"; | ||||
| import { CommandList } from "./commands/commandlist"; | ||||
| import { Command } from "./commands/command"; | ||||
| import { BlacklistUsers } from "./models/blacklistusers"; | ||||
| import { BlacklistUser } from "./models/blacklistuser"; | ||||
| import { CommandBlacklist } from "./models/commandblacklist"; | ||||
| import { SlashCommand } from "./slash/slash"; | ||||
| import { SlashCommandList } from "./slash/commandlist"; | ||||
| @ -30,7 +30,7 @@ export class CommandClient extends Client { | ||||
|         this.on('messageCreate', async (msg: Message) => { | ||||
|             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); | ||||
|         }); | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| import { Message, User } from "discord.js" | ||||
| import { Command } from "./command" | ||||
| import { UserArgument } from "../types/user" | ||||
| import { BlacklistUsers } from "../models/blacklistusers" | ||||
| import { BlacklistUser } from "../models/blacklistuser" | ||||
| 
 | ||||
| interface GlobalBlacklistArguments { | ||||
|     users: User[] | ||||
| @ -29,14 +29,14 @@ export class GlobalBlacklistCommand implements Command { | ||||
|         let replystr = ''; | ||||
| 
 | ||||
|         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) { | ||||
|                 row.destroy() | ||||
|                 replystr += `${user.tag}: removed\n` | ||||
|             } | ||||
|             else { | ||||
|                 await BlacklistUsers.create({ user_id: user.id }); | ||||
|                 await BlacklistUser.create({ user_id: user.id }); | ||||
|                 replystr += `${user.tag}: added\n` | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| import { DataTypes, Sequelize } from "sequelize"; | ||||
| import { BlacklistUsers } from "./models/blacklistusers"; | ||||
| import { BlacklistUser } from "./models/blacklistuser"; | ||||
| import { CommandBlacklist } from "./models/commandblacklist"; | ||||
| import { Players } from "./models/players"; | ||||
| import { Player } from "./models/player"; | ||||
| 
 | ||||
| export const db = new Sequelize({ | ||||
| 	dialect: 'sqlite', | ||||
| @ -9,14 +9,14 @@ export const db = new Sequelize({ | ||||
| 	logging: false | ||||
| }); | ||||
| 
 | ||||
| BlacklistUsers.init({ | ||||
| BlacklistUser.init({ | ||||
|     user_id: { | ||||
|         type: DataTypes.TEXT, | ||||
|         primaryKey: true | ||||
|     } | ||||
| }, | ||||
| { | ||||
|     tableName: 'BlacklistUsers', | ||||
|     tableName: 'BlacklistUser', | ||||
|     sequelize: db | ||||
| }); | ||||
| 
 | ||||
| @ -33,7 +33,7 @@ CommandBlacklist.init({ | ||||
|     sequelize: db | ||||
| }); | ||||
| 
 | ||||
| Players.init({ | ||||
| Player.init({ | ||||
|     user_id: { | ||||
|         type: DataTypes.TEXT, | ||||
|         primaryKey: true | ||||
| @ -47,7 +47,7 @@ Players.init({ | ||||
|     } | ||||
| }, | ||||
| { | ||||
|     tableName: 'Players', | ||||
|     tableName: 'Player', | ||||
|     sequelize: db | ||||
| }); | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										5
									
								
								src/models/blacklistuser.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/models/blacklistuser.ts
									
									
									
									
									
										Normal 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 | ||||
| } | ||||
| @ -1,5 +0,0 @@ | ||||
| import { InferAttributes, InferCreationAttributes, Model } from "sequelize"; | ||||
| 
 | ||||
| export class BlacklistUsers extends Model<InferAttributes<BlacklistUsers>, InferCreationAttributes<BlacklistUsers>> { | ||||
|     declare readonly user_id: string | ||||
| } | ||||
| @ -1,6 +1,6 @@ | ||||
| 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 start: number | ||||
|     declare spent: CreationOptional<number> | ||||
| @ -1,5 +1,5 @@ | ||||
| import { ApplicationCommandOptionData, ApplicationCommandOptionType, CommandInteraction } from "discord.js" | ||||
| import { Players } from "../models/players" | ||||
| import { Player } from "../models/player" | ||||
| import { SlashCommand } from "./slash" | ||||
| 
 | ||||
| export class InitCommand implements SlashCommand { | ||||
| @ -11,7 +11,7 @@ export class InitCommand implements SlashCommand { | ||||
|     args: ApplicationCommandOptionData[] = [] | ||||
| 
 | ||||
| 	async execute(int: CommandInteraction) { | ||||
|         const player = await Players.findOne({ | ||||
|         const player = await Player.findOne({ | ||||
|             where: { | ||||
|                 user_id: int.user.id | ||||
|             } | ||||
| @ -22,7 +22,7 @@ export class InitCommand implements SlashCommand { | ||||
|             ephemeral: true | ||||
|         }); | ||||
| 
 | ||||
|         Players.create({ | ||||
|         Player.create({ | ||||
|             user_id: int.user.id, | ||||
|             start: Math.floor(Date.now()/1000) | ||||
|         }); | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user