Skip to content

Commit

Permalink
Added migrate command
Browse files Browse the repository at this point in the history
  • Loading branch information
raluvy95 committed Jun 3, 2024
1 parent 85414f2 commit 5dda9ad
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions src/commands/level/migrate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { Message } from "eris";
import { client } from "../../client/Client";
import { MovCommand } from "../../client/Command";
import { ILevelDB } from "../../interfaces/database";

async function generator(msg: Message, args: string[]) {
const userId = args[0];
const xp = args[1];
const totalXP = args[2];
const level = args[3];
if (!userId || !xp || !totalXP || !level) {
client.createMessage(
msg.channel.id,
`Usage: \`${msg.prefix}${msg.command} <userid> <xp> <totalXP> <level>\``,
);
return;
}
if (await client.database.level.has(userId)) {
client.database.level.set<ILevelDB>(userId, {
xp: Number(xp),
level: Number(level),
totalxp: Number(totalXP),
});
client.createMessage(
msg.channel.id,
"That user is already exist, but I will overwrite it.",
);
return;
}
client.database.level.set<ILevelDB>(userId, {
xp: Number(xp),
level: Number(level),
totalxp: Number(totalXP),
});
client.createMessage(
msg.channel.id,
`Successfully set for \`${userId}\`'s level and xp`,
);
return;
}

class Migrate extends MovCommand {
constructor() {
super("migrate", generator, {
description: "Same thing as adduserlb, but with totalxp as an argument.",
requirements: {
userIDs: process.env.OWNER_ID!.split(" ")
}
})
}
}

export default new Migrate();

0 comments on commit 5dda9ad

Please sign in to comment.