dont merge - i was having conflicts #2

Closed
HotPlate wants to merge 4 commits from (deleted):main into main
4 changed files with 62 additions and 10 deletions

View File

@@ -12,12 +12,12 @@
"typescript": "^5"
},
"scripts": {
"generate": "drizzle-kit generate",
"migrate": "drizzle-kit migrate",
"db:push": "drizzle-kit push",
"generate": "docker compose run --rm app bun drizzle-kit generate",
"migrate": "docker compose run --rm app bun drizzle-kit migrate",
"db:push": "docker compose run --rm app bun drizzle-kit push",
"deploy": "docker compose run --rm app bun src/scripts/deploy.ts",
"dev": "bun --watch src/index.ts",
"db:studio": "drizzle-kit studio"
"db:studio": "docker compose run --rm -p 4983:4983 app bun drizzle-kit studio --host 127.0.0.1"
},
"dependencies": {
"discord.js": "^14.25.1",

View File

@@ -0,0 +1,10 @@
import { createCommand } from "@lib/utils";
import { SlashCommandBuilder, EmbedBuilder } from "discord.js";
export const cookies = createCommand({
data: new SlashCommandBuilder().setName("cookies").setDescription("Say sadhasj"),
execute: async (interaction) => {
const embed = new EmbedBuilder().setDescription("HELLO sandwich");
await interaction.reply({ embeds: [embed] });
}
});

View File

@@ -1,13 +1,29 @@
import { createCommand } from "@lib/utils";
import { getUserBalance } from "@/modules/economy/economy.service";
import { SlashCommandBuilder, EmbedBuilder } from "discord.js";
import { createUser, getUserById } from "@/modules/users/users.service";
import { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits } from "discord.js";
export const balance = createCommand({
data: new SlashCommandBuilder().setName("balance").setDescription("Check your balance"),
execute: async (interaction) => {
const balance = await getUserBalance(interaction.user.id) || 0;
const embed = new EmbedBuilder().setDescription(`Your balance is ${balance}`);
data: new SlashCommandBuilder()
.setName("balance")
.setDescription("Check your balance")
,execute: async (interaction) => {
const user = interaction.user;
// Ensure user exists in DB
let dbUser = await getUserById(user.id);
if (!dbUser) {
await createUser(user.id);
}
const balance = await getUserBalance(user.id);
const embed = new EmbedBuilder()
.setTitle(`${user.username}'s Balance`)
.setDescription(`💰 **${balance} coins**`)
.setColor("Green");
await interaction.reply({ embeds: [embed] });
}
});

View File

@@ -0,0 +1,26 @@
import { createCommand } from "@lib/utils";
import { getUserBalance, setUserBalance } from "@/modules/economy/economy.service";
import { createUser, getUserById } from "@/modules/users/users.service";
import { SlashCommandBuilder, EmbedBuilder } from "discord.js";
export const setbalance = createCommand({
data: new SlashCommandBuilder().setName("setbalance").setDescription("Set your balance").addUserOption(option => option.setName("user").setDescription("The user to set the balance for").setRequired(true)).addNumberOption(option =>
option.setName("amount")
.setDescription("The amount to set your balance to")
.setRequired(true)
), execute: async (interaction) => {
const user = await getUserById(interaction.options.getUser("user", true).id);
if (!user) {
await createUser(interaction.options.getUser("user", true).id);
} else {
console.log(`User ${interaction.options.getUser("user", true).id} already exists.`);
}
const amount = interaction.options.getNumber("amount", true);
const oldbalance = await getUserBalance(interaction.options.getUser("user", true).id);
await setUserBalance(interaction.options.getUser("user", true).id, amount);
const balance = await getUserBalance(interaction.options.getUser("user", true).id) ;
const embed = new EmbedBuilder().setDescription(`${interaction.options.getUser("user", true).username}'s old balance is: ${oldbalance}. ${interaction.options.getUser("user", true).username}'s amount is ${amount}. ${interaction.options.getUser("user", true).username}'s new balance is ${balance}.`);
await interaction.reply({ embeds: [embed] });
}
});