more sensible
This commit is contained in:
parent
ffd9ad39e7
commit
d38653bf5a
@ -1,23 +1,23 @@
|
||||
import { GuildMember, User } from "discord.js";
|
||||
import { Snowflake } from "discord.js";
|
||||
import { CommandClient } from "./commandclient";
|
||||
import { Player } from "./models/player";
|
||||
|
||||
export class CBClient extends CommandClient {
|
||||
async createPlayer(user: User | GuildMember) {
|
||||
async createPlayer(user_id: Snowflake) {
|
||||
return await Player.create({
|
||||
user_id: user.id,
|
||||
user_id: user_id,
|
||||
start: Math.floor(Date.now()/1000)
|
||||
});
|
||||
}
|
||||
|
||||
async findOrCreatePlayer(user: User | GuildMember) {
|
||||
async findOrCreatePlayer(user_id: Snowflake) {
|
||||
const player = await Player.findOne({
|
||||
where: {
|
||||
user_id: user.id
|
||||
user_id: user_id
|
||||
}
|
||||
});
|
||||
|
||||
if (!player) return await this.createPlayer(user);
|
||||
if (!player) return await this.createPlayer(user_id);
|
||||
return player;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user