Skip to content

Commit

Permalink
Merge pull request #6 from Shulchl/origin
Browse files Browse the repository at this point in the history
Melhorando
  • Loading branch information
Shulchl authored Aug 21, 2022
2 parents 9ae4e6c + 1ecea59 commit 3337032
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 98 deletions.
3 changes: 2 additions & 1 deletion base/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ async def get_roles(member: discord.Member, guild, roles=[
943172687642132591,
943193084584402975,
943251043838468127,
949805774484426783
949805774484426783,
1010184007394283630
]):
rr = []
for role in member.roles:
Expand Down
106 changes: 39 additions & 67 deletions base/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,19 @@ async def connect(self) -> None:
try:
await self.conn.fetch(
"INSERT INTO itens (name, type, value, img, imgd, img_profile, lvmin) "
"VALUES ('Novato','Moldura',1000,'src/molduras-loja/#1.png',"
"'src/molduras/molduras-perfil/titulos/#1E.png','src/molduras/molduras-perfil/bordas/#1.png', 0 )"
"VALUES ('Novato','Moldura',1000,'src/molduras-loja/#1.png',"
"'src/molduras/molduras-perfil/titulos/#1E.png','src/molduras/molduras-perfil/bordas/#1.png', 0 )"
" ON CONFLICT (name) DO NOTHING")

await self.conn.fetch(
"INSERT INTO itens (name, type, value, img, imgd, img_profile, lvmin) "
"VALUES ('Soldado Nadir','Moldura', 500000,'src/molduras-loja/#1.png',"
" 'src/molduras/molduras-perfil/titulos/#1E.png', 'src/molduras/molduras-perfil/bordas/#1.png', 10) ON CONFLICT (name) DO NOTHING")
"INSERT INTO itens (name, type, value, img, imgd, img_profile, lvmin) "
"VALUES ('Soldado Nadir','Moldura', 500000,'src/molduras-loja/#1.png',"
" 'src/molduras/molduras-perfil/titulos/#1E.png', 'src/molduras/molduras-perfil/bordas/#1.png', 10) ON CONFLICT (name) DO NOTHING")

await self.conn.fetch(
"INSERT INTO itens (name, type, value, img, imgd, img_profile, lvmin) "
"VALUES ('Sargento Aurora','Moldura', 1000000,'src/molduras-loja/#2.png',"
" 'src/molduras/molduras-perfil/titulos/#2E.png', 'src/molduras/molduras-perfil/bordas/#2.png', 20) ON CONFLICT (name) DO NOTHING")
"INSERT INTO itens (name, type, value, img, imgd, img_profile, lvmin) "
"VALUES ('Sargento Aurora','Moldura', 1000000,'src/molduras-loja/#2.png',"
" 'src/molduras/molduras-perfil/titulos/#2E.png', 'src/molduras/molduras-perfil/bordas/#2.png', 20) ON CONFLICT (name) DO NOTHING")

await self.conn.fetch(
"INSERT INTO itens (name, type, value, img, imgd, img_profile, lvmin) "
Expand Down Expand Up @@ -647,30 +647,14 @@ def drawloja(self, total, itens, coin: int, userImg: BytesIO) -> BytesIO:
plain = plain.convert('RGBA')

userImg_Big = plain.copy()
# userImg = plain.resize((342, 342))

# bigsize = (userImg.size[ 0 ] * 3, userImg.size[ 1 ] * 3)
# mask = Image.new('L', bigsize, 0)
# draw = ImageDraw.Draw(mask)
# draw.ellipse((0, 0) + bigsize, fill=255)
# mask = mask.resize(userImg.size, Image.ANTIALIAS)
# userImg.putalpha(mask)

# output = ImageOps.fit(userImg, mask.size, centering=(0.5, 0.5))
# output.putalpha(mask)



# Itens
# altura = 190*3
oriOriginal = Image.open(r"src\imgs\extra\ori.png")
starOriginal = Image.open(r"src\imgs\extra\Pin-Star.png")


total_page = total/6 if total/6 == int() else int(total/6+1)
images = []
count = 0
ccount = 0
for i in range(total_page):
bg = Image.new('RGBA', (1280, 950), (0, 45, 62, 255))
bg_draw = ImageDraw.Draw(bg)
Expand All @@ -682,35 +666,20 @@ def drawloja(self, total, itens, coin: int, userImg: BytesIO) -> BytesIO:
profileFundo = Image.composite(userImg_Big, bg, mask)
profileBlur = profileFundo.filter(ImageFilter.GaussianBlur(radius=10))
bg.paste(profileBlur, (0, 0))
# self.gradientLeft(1.2, 1, bg)
# self.gradientRight(1.2, 1, bg)
# quad1 = Image.new(mode = "RGB", size = (311, 110), color = (0, 56, 76))
# bg.paste(quad1, (0, 30))
# quad2 = Image.new(mode = "RGB", size = (311, 110), color = (0, 56, 76))
# bg.paste(quad2, (969, 30))

# bg_draw.rounded_rectangle([(25, 30), (1245, 150)], 25, fill=(0, 56, 76))

# Titles
bg_draw.text((640, 90), "LOJA", font=self.class_font_montbold,
anchor="ms", fill=(219, 239, 255))
for t in range(6):
if count <= total:
larg_inic = 420 * ( count )
if larg_inic < 0:
larg_inic = 0



larg_baixo = 420 * ( count - 4)
if larg_baixo < 0:
larg_baixo = 0
anchor="ms", fill=(219, 239, 255))

tcount = 0
ccount = 0
if tcount == 3:
tcount = 0
ccount = 0

for t in range(7):

ori_pos_baixo = 436 * ( t - 3 )
if count < total:
list_itens = list(itens[ count ].values())

list_itens = list(itens[ count -1 ].values())
if int(list_itens[ 0 ][ 'value' ]) <= int(coin):
valueColor = (0, 247, 132)
else:
Expand All @@ -720,14 +689,20 @@ def drawloja(self, total, itens, coin: int, userImg: BytesIO) -> BytesIO:
list_itens[ 0 ][ 'name' ]) == "Chave" else Image.open(list_itens[ 0 ][ 'img' ])
lar = (itemImg.size[ 0 ], itemImg.size[ 1 ])
# print(list_itens)
ori_pos = 15

altura = 180
altura_baixo = 570
largura = 382

larg_inic = 420 * ccount
larg_baixo = 420 * tcount

ori_pos = 420 * ccount
ori_pos_baixo = 420* tcount

if larg_baixo > 840:
break

if larg_inic <= 840:
print(larg_inic)
# 1 row
bg_draw.rounded_rectangle(
[ (37 + larg_inic, altura), ((larg_inic + largura - 2), 320 + altura) ], 25,
Expand Down Expand Up @@ -788,17 +763,21 @@ def drawloja(self, total, itens, coin: int, userImg: BytesIO) -> BytesIO:

ori = oriOriginal.resize((70, 71), Image.NEAREST)
bg.paste(ori, (ori_pos, 467), ori)
ccount += 1

else:
print(larg_baixo)
elif larg_baixo <= 840:



altura = 570

bg_draw.rounded_rectangle(
[ (37 + larg_baixo, altura_baixo), ((larg_baixo + largura - 2), 320 + altura_baixo) ], 25,
[ (37 + larg_baixo, altura), ((larg_baixo + largura - 2), 320 + altura) ], 25,
fill=(0, 247, 132))
bg_draw.rounded_rectangle(
[ (35 + larg_baixo, altura_baixo), ((larg_baixo + largura), 315 + altura_baixo) ], 25, fill=(0, 45, 62))
[ (35 + larg_baixo, altura), ((larg_baixo + largura), 315 + altura) ], 25, fill=(0, 45, 62))
bg_draw.rounded_rectangle(
[ (30 + larg_baixo, altura_baixo), ((larg_baixo + largura) + 5, 95 + altura_baixo) ], 25, fill=(0, 56, 76))
[ (30 + larg_baixo, altura), ((larg_baixo + largura) + 5, 95 + altura) ], 25, fill=(0, 56, 76))

if list_itens[ 0 ][ 'dest' ] == "False":
color = (161, 177, 191)
Expand Down Expand Up @@ -834,16 +813,15 @@ def drawloja(self, total, itens, coin: int, userImg: BytesIO) -> BytesIO:
bg_draw.text((larg_baixo + largText + 135, 868),
f" #{list_itens[ 0 ][ 'id' ]}", font=self.class_font_montbold_ori,
fill=(0, 198, 244))

if lar[ 0 ] > 250:
bg.paste(
itemImg, (int((larg_baixo + 20) + ((largura - lar[ 0 ]) / 2)), 735), itemImg)
else:
bg.paste(itemImg, (35 + 110 + larg_baixo, 682), itemImg)



ori = oriOriginal.resize((70, 71), Image.NEAREST)
bg.paste(ori, (ori_pos_baixo, 855), ori)
tcount += 1

count += 1
bg_draw.text((100, 54), "Suas oris",
Expand All @@ -860,9 +838,7 @@ def drawloja(self, total, itens, coin: int, userImg: BytesIO) -> BytesIO:
font=self.class_font_montbold_ori, fill=(219, 239, 255))
# SUBTITLE
bg_draw.text((630, 135), "Use os botões abaixo par navegar entre as páginas.",
font=self.class_font_opensans, anchor="ms", fill=(219, 239, 255))

ccount += 1
font=self.class_font_opensans, anchor="ms", fill=(219, 239, 255))

#bg.paste(output, (100, 193), output)

Expand All @@ -877,10 +853,6 @@ def drawloja(self, total, itens, coin: int, userImg: BytesIO) -> BytesIO:
raise i
else:
images.append(f"{u}.png")


print("Done.")
print(ccount)
return images

class Top:
Expand Down
4 changes: 2 additions & 2 deletions cmds/loja.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ async def loja(self, interaction: discord.Interaction, member: discord.Member =
#print(f"{type(botVar.oldImgs[0])} oldimg")
#print(f"{pageFile} pagefile")
pages = [os.path.join('./_temp/', i) for i in pages]
view = Paginacao(pages,10, interaction.user)
view = Paginacao(pages, 60, interaction.user)
await interaction.response.send_message(file=dFile(rf'{pages[0]}'), view=view, ephemeral=True)
out = interaction.edit_original_response
view.response = out
Expand Down Expand Up @@ -451,4 +451,4 @@ async def on_submit(self, interaction: Interaction) -> None:
self.stop()

async def setup(bot: commands.Bot) -> None:
await bot.add_cog(Shop(bot), guilds=[ discord.Object(id=943170102759686174), discord.Object(id=1010183521907789977)])
await bot.add_cog(Shop(bot), guilds=[ discord.Object(id=943170102759686174), discord.Object(id=1010183521907789977)])
26 changes: 13 additions & 13 deletions cmds/mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,35 +427,35 @@ async def ranking(self, ctx, opt: Optional[Literal["Ori", "Nivel"]]):
async with session.get(f"{ctx.author.display_avatar.url}?size=1024?format=png") as resp:
profile_bytes = await resp.read()


if not opt:
opt = "Nivel"

if opt == "Ori":
rows = await self.db.fetch(
"SELECT id, coin FROM users ORDER BY coin Desc")
"SELECT id, coin FROM users ORDER BY coin Desc LIMIT 10")
elif opt == "Nivel":
rows = await self.db.fetch(
"SELECT id, rank, xptotal FROM users ORDER BY xptotal Desc")
"SELECT id, rank, xptotal FROM users ORDER BY xptotal Desc LIMIT 10")
if rows:
user_position = 0
count = 0
# if (total/3) > int(total/3):
# return await ctx.send(f"O limite de páginas é {int(total/3)}", delete_after=5)
# elif (total/3) < int(total/3):
# return await ctx.send(f"O limite de páginas é {int(total/3)+1}", delete_after=5)
try:
users = []
while count < len(rows):
user_position = 0
count = 0
for i in range(len(rows)):
user = ctx.guild.get_member(int(rows[count][0]))

try:
user = user.name
if user:
avatar = user.display_avatar.url
except:
user = user
if user == ctx.author.name:
user_position = i

else:
user = "Desconhecido#0000"
avatar = "src/imgs/extra/spark.png"

if user == ctx.author.name:
user_position = count

rank_image = await self.db.fetch(f"SELECT badges FROM ranks WHERE lv <= {rows[count][1]} ORDER BY lv Desc LIMIT 1")
if rank_image:
Expand Down
3 changes: 1 addition & 2 deletions cmds/perfil.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ async def on_message(self, message) -> None:
current_xp = 0

@app_commands.command(name='perfil')
@app_commands.guilds(discord.Object(id=943170102759686174))
async def perfil(self, interaction: discord.Interaction, member: discord.Member = None) -> None:

if member:
Expand Down Expand Up @@ -167,4 +166,4 @@ async def perfil(self, interaction: discord.Interaction, member: discord.Member


async def setup(bot: commands.Bot) -> None:
await bot.add_cog(Perfil(bot), guilds=[ discord.Object(id=943170102759686174) ])
await bot.add_cog(Perfil(bot), guilds=[ discord.Object(id=943170102759686174), discord.Object(id=1010183521907789977)])
14 changes: 1 addition & 13 deletions cmds/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def __init__(self, bot: commands.Bot) -> None:
#@longest_cooldown
@app_commands.command(name='nivel', description='Monstrará a barra de progresso, bem como a medalha de seu nível.')
@app_commands.describe(member='Marque o usuário para mostrar seu nível. (opcional)')
@app_commands.guilds(discord.Object(id=943170102759686174))
async def nivel(self, interaction: discord.Interaction, member: discord.Member = None) -> None:
if member:
uMember = member
Expand Down Expand Up @@ -104,7 +103,6 @@ async def nivel_error(self, interaction: discord.Interaction, error):
delete_after=5)

@app_commands.command()
@app_commands.guilds(discord.Object(id=943170102759686174))
async def getavatar(self, interaction: discord.Interaction, member: discord.Member = None) -> None:
if member:
uMember = member
Expand All @@ -116,7 +114,6 @@ async def getavatar(self, interaction: discord.Interaction, member: discord.Memb
return await interaction.response.send_message("Não consegui pegar o avatar do usuário. Provavelmente é padrão do discord xD", ephemeral=True)

@app_commands.command()
@app_commands.guilds(discord.Object(id=943170102759686174))
async def getbanner(self, interaction: discord.Interaction, member: discord.Member = None) -> None:
if member:
uMember = member
Expand All @@ -132,7 +129,6 @@ async def getbanner(self, interaction: discord.Interaction, member: discord.Memb


@app_commands.command(name='pescar')
@app_commands.guilds(discord.Object(id=943170102759686174))
@activity_cooldown
async def pescar(self, interaction: discord.Interaction):
if interaction.user.id not in self.brake:
Expand Down Expand Up @@ -160,7 +156,6 @@ async def pescar(self, interaction: discord.Interaction):


@app_commands.command(name='topori')
@app_commands.guilds(discord.Object(id=943170102759686174))
@activity_cooldown
async def topori(self, interaction: discord.Interaction):
member = interaction.user
Expand Down Expand Up @@ -202,7 +197,6 @@ async def topori(self, interaction: discord.Interaction):

# classe
@app_commands.command(name='classes')
@app_commands.guilds(discord.Object(id=943170102759686174))
@activity_cooldown
async def classes(self, interaction: discord.Interaction):
await self.db.fetch(
Expand Down Expand Up @@ -236,7 +230,6 @@ async def classes(self, interaction: discord.Interaction):

# @activity_cooldown
@app_commands.command(name='info')
@app_commands.guilds(discord.Object(id=943170102759686174))
async def info(self, interaction: discord.Interaction, *, content: str) -> None:
info = "".join(content)
size = len(info)
Expand All @@ -263,15 +256,13 @@ async def info_error(self, interaction: discord.Interaction, error: app_commands
error, ephemeral=True)

@app_commands.command(name='delinfo')
@app_commands.guilds(discord.Object(id=943170102759686174))
@activity_cooldown
async def delinfo(self, interaction: discord.Interaction) -> None:
await self.db.fetch(f"UPDATE users SET info = (\'\') WHERE id = ('{interaction.user.id}')")
await interaction.response.send_message("```Campo de informações atualizado. "
"Visualize utilizando d.perfil```", ephemeral=True)

@app_commands.command(name='niver')
@app_commands.guilds(discord.Object(id=943170102759686174))
@app_commands.checks.cooldown(1, 86400, key=lambda i: (i.guild_id, i.user.id))
async def niver(self, interaction: discord.Interaction, niver: str) -> None:

Expand All @@ -292,14 +283,12 @@ async def niver_error(self, interaction: discord.Interaction, error: app_command
ephemeral=True)

@app_commands.command(name='delniver')
@app_commands.guilds(discord.Object(id=943170102759686174))
@longest_cooldown
async def delniver(self, interaction: discord.Interaction) -> None:
await self.db.fetch(f"UPDATE users SET birth = ('???') WHERE id = ('{interaction.user.id}')")
await interaction.response.send_message("```Aniversário atualizado!```", ephemeral=True)

@app_commands.command(name='inv')
@app_commands.guilds(discord.Object(id=943170102759686174))
@activity_cooldown
async def inv(self, interaction: discord.Interaction) -> None:
invent = await self.db.fetch(f"SELECT inv FROM users WHERE id=('{interaction.user.id}')")
Expand Down Expand Up @@ -327,7 +316,6 @@ async def inv(self, interaction: discord.Interaction) -> None:
return await interaction.response.send_message("Você não tem nenhum item.", ephemeral=True)

@app_commands.command(name='daily') #description='Use diariamente para receber recompensas incríveis'
@app_commands.guilds(discord.Object(id=943170102759686174))
# @app_commands.checks.cooldown(1, 86400)
async def daily(self, interaction: discord.Interaction):
chest_itens = {'chest': 80, 'ori': 10, 'xp': 10}
Expand Down Expand Up @@ -516,4 +504,4 @@ async def buykey(self, interaction: discord.Interaction, button: discord.ui.Butt


async def setup(bot: commands.Bot) -> None:
await bot.add_cog(User(bot), guilds=[ discord.Object(id=943170102759686174) ])
await bot.add_cog(User(bot), guilds=[ discord.Object(id=943170102759686174), discord.Object(id=1010183521907789977)])

0 comments on commit 3337032

Please sign in to comment.