Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Vylpes committed Jun 13, 2024
2 parents 7a352a8 + f4d0199 commit f968332
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# any secret values.

BOT_TOKEN=
BOT_VER=0.6.3
BOT_VER=0.6.4
BOT_AUTHOR=Vylpes
BOT_OWNERID=147392775707426816
BOT_CLIENTID=682942374040961060
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "card-drop",
"version": "0.6.3",
"version": "0.6.4",
"main": "./dist/bot.js",
"typings": "./dist",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions src/buttonEvents/Claim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ export default class Claim extends ButtonEvent {
return;
}

await user.Save(User, user);

const claimed = await eClaim.FetchOneByClaimId(claimId);

if (claimed) {
Expand All @@ -45,6 +43,8 @@ export default class Claim extends ButtonEvent {
return;
}

await user.Save(User, user);

let inventory = await Inventory.FetchOneByCardNumberAndUserId(userId, cardNumber);

if (!inventory) {
Expand Down
3 changes: 3 additions & 0 deletions src/client/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ import { Interaction } from "discord.js";
import ChatInputCommand from "./interactionCreate/ChatInputCommand";
import Button from "./interactionCreate/Button";
import AppLogger from "./appLogger";
import NewUserDiscovery from "./interactionCreate/middleware/NewUserDiscovery";

export class Events {
public async onInteractionCreate(interaction: Interaction) {
if (!interaction.guildId) return;

await NewUserDiscovery(interaction);

if (interaction.isChatInputCommand()) {
AppLogger.LogVerbose("Client", `ChatInputCommand: ${interaction.commandName}`);
ChatInputCommand.onChatInput(interaction);
Expand Down
15 changes: 15 additions & 0 deletions src/client/interactionCreate/middleware/NewUserDiscovery.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Interaction } from "discord.js";
import User from "../../../database/entities/app/User";
import CardConstants from "../../../constants/CardConstants";
import AppLogger from "../../appLogger";

export default async function NewUserDiscovery(interaction: Interaction) {
const existingUser = await User.FetchOneById(User, interaction.user.id);

if (existingUser) return;

const newUser = new User(interaction.user.id, CardConstants.StartingCurrency);
await newUser.Save(User, newUser);

AppLogger.LogInfo("NewUserDiscovery", `Discovered new user ${interaction.user.id}`);
}

0 comments on commit f968332

Please sign in to comment.