Compare commits
No commits in common. "f12bb11ffbb83cc099242d95cc89eb89abd46d7a" and "cfcc8ad1008a1925026d0bb99c4afddcc557564e" have entirely different histories.
f12bb11ffb
...
cfcc8ad100
4 changed files with 13 additions and 51 deletions
|
@ -11,7 +11,6 @@ import CardConstants from "../constants/CardConstants";
|
|||
export default class Claim extends ButtonEvent {
|
||||
public override async execute(interaction: ButtonInteraction) {
|
||||
if (!interaction.guild || !interaction.guildId) return;
|
||||
if (!interaction.channel) return;
|
||||
|
||||
await interaction.deferUpdate();
|
||||
|
||||
|
@ -22,26 +21,15 @@ export default class Claim extends ButtonEvent {
|
|||
|
||||
AppLogger.LogSilly("Button/Claim", `Parameters: cardNumber=${cardNumber}, claimId=${claimId}, droppedBy=${droppedBy}, userId=${userId}`);
|
||||
|
||||
const user = await User.FetchOneById(User, userId) || new User(userId, CardConstants.StartingCurrency);
|
||||
|
||||
AppLogger.LogSilly("Button/Claim", `${user.Id} has ${user.Currency} currency`);
|
||||
|
||||
if (!user.RemoveCurrency(CardConstants.ClaimCost)) {
|
||||
await interaction.channel.send(`${interaction.user}, Not enough currency! You need ${CardConstants.ClaimCost} currency, you have ${user.Currency}!`);
|
||||
return;
|
||||
}
|
||||
|
||||
await user.Save(User, user);
|
||||
|
||||
const claimed = await eClaim.FetchOneByClaimId(claimId);
|
||||
|
||||
if (claimed) {
|
||||
await interaction.channel.send(`${interaction.user}, This card has already been claimed!`);
|
||||
await interaction.reply("This card has already been claimed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (claimId == CoreClient.ClaimId && userId != droppedBy) {
|
||||
await interaction.channel.send(`${interaction.user}, The latest dropped card can only be claimed by the user who dropped it!`);
|
||||
await interaction.reply("The latest dropped card can only be claimed by the user who dropped it");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -55,6 +43,17 @@ export default class Claim extends ButtonEvent {
|
|||
|
||||
await inventory.Save(Inventory, inventory);
|
||||
|
||||
const user = await User.FetchOneById(User, userId) || new User(userId, CardConstants.StartingCurrency);
|
||||
|
||||
AppLogger.LogSilly("Button/Claim", `${user.Id} has ${user.Currency} currency`);
|
||||
|
||||
if (!user.RemoveCurrency(CardConstants.ClaimCost)) {
|
||||
await interaction.reply(`Not enough currency! You need 10 currency, you have ${user.Currency}`);
|
||||
return;
|
||||
}
|
||||
|
||||
await user.Save(User, user);
|
||||
|
||||
const claim = new eClaim(claimId);
|
||||
claim.SetInventory(inventory);
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@ import Config from "../database/entities/app/Config";
|
|||
import CardDropHelperMetadata from "../helpers/CardDropHelperMetadata";
|
||||
import path from "path";
|
||||
import AppLogger from "../client/appLogger";
|
||||
import User from "../database/entities/app/User";
|
||||
import CardConstants from "../constants/CardConstants";
|
||||
|
||||
export default class Reroll extends ButtonEvent {
|
||||
public override async execute(interaction: ButtonInteraction) {
|
||||
|
@ -25,20 +23,6 @@ export default class Reroll extends ButtonEvent {
|
|||
return;
|
||||
}
|
||||
|
||||
let user = await User.FetchOneById(User, interaction.user.id);
|
||||
|
||||
if (!user) {
|
||||
user = new User(interaction.user.id, CardConstants.StartingCurrency);
|
||||
await user.Save(User, user);
|
||||
|
||||
AppLogger.LogInfo("Commands/Drop", `New user (${interaction.user.id}) saved to the database`);
|
||||
}
|
||||
|
||||
if (user.Currency < CardConstants.ClaimCost) {
|
||||
await interaction.reply(`Not enough currency! You need ${CardConstants.ClaimCost} currency, you have ${user.Currency}!`);
|
||||
return;
|
||||
}
|
||||
|
||||
const randomCard = CardDropHelperMetadata.GetRandomCard();
|
||||
|
||||
if (!randomCard) {
|
||||
|
|
|
@ -8,8 +8,6 @@ import Config from "../database/entities/app/Config";
|
|||
import CardDropHelperMetadata from "../helpers/CardDropHelperMetadata";
|
||||
import path from "path";
|
||||
import AppLogger from "../client/appLogger";
|
||||
import User from "../database/entities/app/User";
|
||||
import CardConstants from "../constants/CardConstants";
|
||||
|
||||
export default class Drop extends Command {
|
||||
constructor() {
|
||||
|
@ -33,20 +31,6 @@ export default class Drop extends Command {
|
|||
return;
|
||||
}
|
||||
|
||||
let user = await User.FetchOneById(User, interaction.user.id);
|
||||
|
||||
if (!user) {
|
||||
user = new User(interaction.user.id, CardConstants.StartingCurrency);
|
||||
await user.Save(User, user);
|
||||
|
||||
AppLogger.LogInfo("Commands/Drop", `New user (${interaction.user.id}) saved to the database`);
|
||||
}
|
||||
|
||||
if (user.Currency < CardConstants.ClaimCost) {
|
||||
await interaction.reply(`Not enough currency! You need ${CardConstants.ClaimCost} currency, you have ${user.Currency}!`);
|
||||
return;
|
||||
}
|
||||
|
||||
const randomCard = CardDropHelperMetadata.GetRandomCard();
|
||||
|
||||
if (!randomCard) {
|
||||
|
|
|
@ -36,11 +36,6 @@ export default class Trade extends Command {
|
|||
|
||||
AppLogger.LogSilly("Commands/Trade", `Parameters: user=${user.id}, give=${give.value}, receive=${receive.value}`);
|
||||
|
||||
if (interaction.user.id == user.id) {
|
||||
await interaction.reply("You can not create a trade with yourself.");
|
||||
return;
|
||||
}
|
||||
|
||||
const giveItemEntity = await Inventory.FetchOneByCardNumberAndUserId(interaction.user.id, give.value!.toString());
|
||||
const receiveItemEntity = await Inventory.FetchOneByCardNumberAndUserId(user.id, receive.value!.toString());
|
||||
|
||||
|
|
Loading…
Reference in a new issue