Skip to content

Commit b75169b

Browse files
authored
feat: add dreamconta service
1 parent 004a9ee commit b75169b

4 files changed

Lines changed: 119 additions & 17 deletions

File tree

command/infos/botinfo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ async def botinfo(interaction: discord.Interaction):
4242
inline=False
4343
)
4444

45-
embed.set_footer(text="PerfectTea © 2026")
45+
embed.set_footer(text="PerfectTea © 2025-present")
4646

4747

4848
embed.set_image(url="https://imgur.com/oiTh7tz")

command/infos/perfil.py

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,48 @@
1-
from database import checar_saldo
1+
from database.database import checar_saldo
22
import discord
3+
from discord import app_commands
34
from discord.ext import commands
5+
from dreamconta.conta import update_user_profile, get_user_profile, load_contas
46

57
intents = discord.Intents.default()
68
intents.members = True
79

810
bot = commands.Bot(command_prefix='+', intents=intents)
911

10-
@bot.tree.command(name="perfil", description="Veja o Perfil de Alguém!")
11-
async def perfil(interaction: discord.Interaction, user: discord.Member):
12-
13-
embed = discord.Embed(
14-
title=f"Perfil de {user}",
15-
colour=discord.Colour.dark_blue(),
16-
)
17-
18-
saldo = await checar_saldo(user)
19-
20-
joined = user.joined_at.strftime("%d/%m/%Y %H:%M:%S") if user.joined_at else "Indisponível"
21-
22-
embed.set_footer(text=f"MoonCoins: {saldo} | Entrou em: {joined}")
23-
24-
await interaction.response.send_message(embed=embed)
12+
@bot.tree.command(name="perfil", description="Configura ou visualiza suas informações de perfil")
13+
@app_commands.describe(bio="Sua biografia curta")
14+
async def perfil(interaction: discord.Interaction, user: discord.Member, bio: str = None):
15+
user_id = str(interaction.user.id)
16+
profiles = load_contas()
17+
18+
19+
if user_id not in profiles:
20+
await interaction.response.send_message(
21+
"❌ Você ainda não tem uma **DreamConta**!\n"
22+
"Use o comando `/registrar` para criar sua conta antes de usar este recurso.",
23+
ephemeral=True
24+
)
25+
return
26+
27+
if bio:
28+
29+
update_user_profile(user_id, "bio", bio)
30+
await interaction.response.send_message(f"Perfil atualizado com sucesso! Bio: `{bio}`", ephemeral=True)
31+
else:
32+
33+
profile = get_user_profile(user_id)
34+
user_bio = profile.get("bio", "Nenhuma bio definida.")
35+
36+
embed = discord.Embed(
37+
title=f"Perfil de {interaction.user.name}",
38+
description=user_bio,
39+
color=discord.Color.blurple()
40+
)
41+
42+
saldo = await checar_saldo(user)
43+
44+
joined = user.joined_at.strftime("%d/%m/%Y %H:%M:%S") if user.joined_at else "Indisponível"
45+
46+
embed.set_footer(text=f"MoonCoins: {saldo} | Entrou em: {joined}")
47+
48+
await interaction.response.send_message(embed=embed, ephemeral=True)

dreamconta/conta.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import discord
2+
from discord.ext import commands
3+
from discord import app_commands
4+
import os
5+
import json
6+
7+
intents = discord.Intents.default()
8+
intents.members = True
9+
10+
bot = commands.Bot(command_prefix="+", intents=intents)
11+
12+
CONTA_PATH = "dreamconta.json"
13+
14+
def load_contas():
15+
if not os.path.exists(CONTA_PATH):
16+
return {}
17+
18+
with open(CONTA_PATH, 'r', encoding='utf-8') as f:
19+
try:
20+
return json.load(f)
21+
except json.JSONDecodeError:
22+
return {}
23+
24+
def save(data):
25+
with open(CONTA_PATH, 'w', encoding='utf-8') as f:
26+
json.dump(data, f, indent=4, ensure_ascii=False)
27+
28+
def get_user_profile(user_id: int):
29+
profiles = load_contas()
30+
return profiles.get(str(user_id), {})
31+
32+
def update_user_profile(user_id: int, key: str, value):
33+
profiles = load_contas()
34+
uid = str(user_id)
35+
36+
if uid not in profiles:
37+
profiles[uid] = {}
38+
39+
profiles[uid][key] = value
40+
save(profiles)
41+
42+
@bot.tree.command(name="registrar", description="[DreamConta] Registre sua DreamConta!")
43+
@app_commands.describe(
44+
nome="Seu nome/apelido principal",
45+
bio="Uma breve biografia sobre você",
46+
jogo="Seu jogo favorito"
47+
)
48+
async def registrar_conta(interaction: discord.Interaction, bio: str, jogo: str, nome: str):
49+
user_id = str(interaction.user.id)
50+
profiles = load_contas()
51+
52+
if user_id in profiles:
53+
await interaction.response.send_message("❌ **|** Você já possui uma DreamConta! Use `/perfil` para ver seu perfil na DreamConta!", ephemeral=True)
54+
return
55+
56+
profiles[user_id] = {
57+
"nome": nome,
58+
"bio": bio,
59+
"jogo_favorito": jogo,
60+
"criado_em": discord.utils.utcnow().isoformat()
61+
}
62+
63+
save(profiles)
64+
65+
embed = discord.Embed(
66+
title="✨ Conta Registrada com Sucesso!",
67+
description="Seus dados foram salvos e já podem ser usados em outros comandos da LuaBot.",
68+
color=discord.Color.green()
69+
)
70+
embed.add_field(name="Nome", value=nome, inline=True)
71+
embed.add_field(name="Jogo Favorito", value=jogo, inline=True)
72+
embed.add_field(name="Bio", value=bio, inline=False)
73+
74+
await interaction.response.send_message(embed=embed, ephemeral=True)

main.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from command.infos import userinfo, botinfo, perfil, galleryofmoon
1616
from shih.shih_manager import DiscordTokenManager, MongoDBTokenManager
1717
from caramelo.blacklist.blacklist import blacklist_add, save_blacklist, blacklist_data, blacklist_remove
18+
from dreamconta.conta import registrar_conta
1819
from caramelo.caramelo import lock, unlock
1920

2021

@@ -78,6 +79,9 @@ async def on_ready():
7879
bot.tree.add_command(blacklist_add) # comando de adicionar um usuário na blacklist
7980
bot.tree.add_command(blacklist_remove) # Comando de Remover um usuário da blacklist!
8081

82+
# Comandos da DreamConta
83+
bot.tree.add_command(registrar_conta)
84+
8185

8286
try:
8387
synced = await bot.tree.sync()

0 commit comments

Comments
 (0)