Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
Make code great again
Browse files Browse the repository at this point in the history
  • Loading branch information
nixxoq committed Nov 6, 2023
1 parent b80720e commit 3bd6efa
Show file tree
Hide file tree
Showing 16 changed files with 138 additions and 281 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
- [ ] Ticket system
- [ ] Economy System
- [ ] Giveaways
- [ ] Forms ([read about this on Google Docs](https://docs.google.com/document/d/1LywTG8IN6ACVAJMPqUHMXY8DrSV-DpPOFIEdCt6OEVk/edit))
- [ ]
Forms ([read about this on Google Docs](https://docs.google.com/document/d/1LywTG8IN6ACVAJMPqUHMXY8DrSV-DpPOFIEdCt6OEVk/edit))
- [ ] ... (Fill this lol)


## Developers:

#### [/lazy/dev](https://github.com/devbutlazy)

#### [Weever](https://github.com/prunus1337)

#### [Snaky](https://github.com/Snaky1a)
133 changes: 0 additions & 133 deletions src/cogs/backups.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import asyncio
import io
import os
from typing import Optional

import disnake
Expand Down Expand Up @@ -264,27 +263,6 @@ async def cog_load(self) -> None:
@commands.has_permissions(administrator=True)
@commands.cooldown(1, 5, commands.BucketType.guild)
async def backup(self, ctx: commands.Context) -> None:
# if ctx.invoked_subcommand is None:
# embed = disnake.Embed(
# title="<:backup:1168599276520226826> Backup commands",
# color=0x2F3136,
# description=(
# f"`{ctx.prefix}backup create` – Create/update backup\n"
# f"`{ctx.prefix}backup delete` – Delete backup\n"
# f"`{ctx.prefix}backup load` – Load backup\n"
# f"`{ctx.prefix}backup file` – JSON file of server backup"
# ),
# )
#
# if backups.check_backup(ctx.guild):
# data = await backups.get(guild_id=ctx.guild.id)
# data = data["backup_data"]
# embed.add_field(
# name="Last Backup:",
# value=f"<t:{data['info']['created']}:f> (<t:{data['info']['created']}:R>)",
# )
#
# await ctx.send(embed=embed)
embed = disnake.Embed(color=0x2F3136)
embed.title = "Backup system"
embed.add_field(
Expand All @@ -309,117 +287,6 @@ async def backup(self, ctx: commands.Context) -> None:
)
await ctx.send(embed=embed, view=BackupsView(self.bot))

# @backup.command()
# @commands.cooldown(1, 5, commands.BucketType.guild)
# @is_owner()
# async def create(self, ctx: commands.Context) -> None:
# global msg
# embed = disnake.Embed(color=0x2F3136)
# try:
# embed.title = "<a:loading:1168599537682755584> Please wait..."
# embed.description = "Creating a server backup..."
# msg = await ctx.send(embed=embed)
#
# backup_data = await BackupGuild(ctx.guild).create()
#
# await self.backups.update_backups_info(ctx.guild.id, backup_data)
#
# embed.colour = 0x2F3136
# embed.title = "Finished"
# embed.description = "Server backup has been successfully created"
#
# with io.StringIO() as temp_file:
# ujson.dump(backup_data, temp_file, indent=4)
# temp_file.seek(0)
# file_data = temp_file.read().encode()
# await msg.edit(
# embed=embed, file=disnake.File(fp=io.BytesIO(file_data), filename="backup.json")
# )
#
# except (Exception, ExceptionGroup) as e:
# embed.colour = 0x2F3136
# embed.title = "An error occurred"
# embed.description = "An error occurred when trying to save the server."
# await msg.edit(embed=embed)
# raise e
#
# @backup.command()
# @commands.cooldown(1, 5, commands.BucketType.guild)
# @is_owner()
# @has_bot_permissions()
# async def load(self, ctx: commands.Context) -> None:
# embed = disnake.Embed(color=0x2F3136)
# if ctx.message.attachments:
# temp_file = await save_file_to_memory(ctx.message.attachments[0])
# data = ujson.load(temp_file)
# else:
# data = await self.backups.get(ctx.guild.id, to_return="backup_data")
#
# if not data:
# embed.title = "An error occurred"
# embed.description = "There is no backup for this server"
# await ctx.send(embed=embed)
# return
#
# embed.title = "<a:loading:1168599537682755584> Loading Backup"
# embed.set_footer(text=ctx.author, icon_url=ctx.author.avatar)
#
# msg = await ctx.send(embed=embed)
#
# await BackupGuild(ctx.guild).restore(data=data, message=msg)
#
# @backup.command()
# @commands.cooldown(1, 50, commands.BucketType.guild)
# @commands.has_permissions(administrator=True)
# async def file(self, ctx: commands.Context) -> None:
# if backups.check_backup(ctx.guild):
# backup = {
# "guild": {},
# "text_channels": {},
# "voice_channels": {},
# "categories": {},
# "roles": {},
# }
# data = await self.backups.get(ctx.guild.id, to_return="backup_data")
#
# backup["guild"]["name"] = data["guild"]["name"]
# backup["guild"]["afk_timeout"] = data["guild"]["afk_timeout"]
# backup["guild"]["description"] = data["guild"]["description"]
# backup["text_channels"] = data["text"]
# backup["voice_channels"] = data["voice"]
# backup["categories"] = data["category"]
# backup["roles"] = data["roles"]
#
# with open(f"{str(ctx.guild.id)}.json", "w") as f:
# ujson.dump(backup, f, indent=4)
#
# await ctx.send(file=disnake.File(f"{str(ctx.guild.id)}.json"))
# os.remove(f"{str(ctx.guild.id)}.json")
# else:
# embed = disnake.Embed(
# colour=0x2F3136,
# title="An error occurred",
# description="There isn't any backup created for this server",
# )
#
# await ctx.send(embed=embed)
#
# @backup.command()
# @is_owner()
# async def delete(self, ctx: commands.Context) -> None:
# embed = disnake.Embed(color=0x2F3136)
#
# if backups.check_backup(ctx.guild):
# await self.backups.remove_from_db({"_id": ctx.guild.id})
# embed.title = "Finished"
# embed.description = "Server backup has been successfully deleted"
# await ctx.send(embed=embed)
# else:
# embed.title = "An error occurred"
# embed.description = "Server backup hasn't been deleted."
# embed.set_footer(text=ctx.author, icon_url=ctx.author.avatar)
# await ctx.send(embed=embed)


def setup(bot: commands.Bot) -> None:
bot.add_cog(Backup(bot))
52 changes: 32 additions & 20 deletions src/cogs/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class BasicUtility(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.badges = {
# 0: "No Badge",
1: "<:staff:1168622635228344403>",
2: "<:partner:1168622631705137233>",
4: "<:hypesquad:1168622629901586605>",
Expand All @@ -38,10 +37,6 @@ def __init__(self, bot):
133172312: "<:synthdev:1169689479452311582>",
}

# @commands.command()
# async def test(self, ctx: commands.Context):
# await ctx.send(f"Test emoji: ")

@commands.slash_command(
name=Localized("user", key="USER_COMMAND_NAME"),
description=Localized(
Expand All @@ -60,8 +55,14 @@ async def user(
if user is None:
user = interaction.user

dev_badge = (
""
if not check_if_user_is_developer(bot=self.bot, user_id=user.id)
else " <:synthdev:1169689479452311582>"
)

embed = disnake.Embed(
title=f"@{user.name} / {user.id} {'' if not check_if_user_is_developer(bot=self.bot, user_id=user.id) else ' <:synthdev:1169689479452311582>'}",
title=f"@{user.name} / {user.id} {dev_badge}",
color=0x2B2D31,
description=f"[Link to DM](discord://discord.com/users/{user.id})",
)
Expand Down Expand Up @@ -139,16 +140,24 @@ async def server(self, interaction: disnake.MessageCommandInteraction):
)
embed.add_field(
name="Main Information",
value=f"<:owner:1169684595697004616> **Owner:** {interaction.guild.owner.mention} ({interaction.guild.owner.id})\n"
f"<:created_at:1169684592006017034> **Created at:** {format_dt(interaction.guild.created_at, style='f')}\n"
f"<:boost:1169685353515462697> **Boosts:** {interaction.guild.premium_subscription_count}\n"
f"<:star:1169685347576336385> **Emojis:** {emoji_count}\n"
f"<:link:1169685349409226893> **Icon:** [click]({interaction.guild.icon})\n"
f"<:channels:1169684589640429599> **Channels:** {len(interaction.guild.channels)}\n"
f"<:design:1169686174374301746> <:channels:1169684589640429599> **Text Channels:** {len(interaction.guild.text_channels)}\n"
f"<:design:1169686174374301746> <:voice:1169684588315029534> **Voice Channels:** {len(interaction.guild.voice_channels)}\n"
f"<:design:1169686174374301746> <:category:1169684586666663999> **Categories:** {len(interaction.guild.categories)}\n"
f"<:design:1169688944502378536> <:thread:1169685355423866963> **Threads:** {len(interaction.guild.threads)}\n\n",
value=(
f"<:owner:1169684595697004616> **Owner:** "
f"{interaction.guild.owner.mention} ({interaction.guild.owner.id})\n"
f"<:created_at:1169684592006017034> **Created at:** "
f"{format_dt(interaction.guild.created_at, style='f')}\n"
f"<:boost:1169685353515462697> **Boosts:** {interaction.guild.premium_subscription_count}\n"
f"<:star:1169685347576336385> **Emojis:** {emoji_count}\n"
f"<:link:1169685349409226893> **Icon:** [click]({interaction.guild.icon})\n"
f"<:channels:1169684589640429599> **Channels:** {len(interaction.guild.channels)}\n"
f"<:design:1169686174374301746> <:channels:1169684589640429599> "
f"**Text Channels:** {len(interaction.guild.text_channels)}\n"
f"<:design:1169686174374301746> <:voice:1169684588315029534>"
f" **Voice Channels:** {len(interaction.guild.voice_channels)}\n"
f"<:design:1169686174374301746> <:category:1169684586666663999>"
f" **Categories:** {len(interaction.guild.categories)}\n"
f"<:design:1169688944502378536> <:thread:1169685355423866963>"
f" **Threads:** {len(interaction.guild.threads)}\n\n"
),
inline=False,
)
embed.add_field(
Expand Down Expand Up @@ -245,10 +254,13 @@ async def botinfo(self, interaction: disnake.MessageCommandInteraction):
)
embed.add_field(
name="Popularity",
value=f"<:info:1169685342077583480> Servers: **{len(self.bot.guilds)}**\n"
f"<:globe:1169690501063123065> Big servers (1000+): **{len([g for g in self.bot.guilds if g.member_count >= 1000])}**\n"
f"<:members:1169684583369949285> Users: **{len(set(self.bot.get_all_members()))}**\n"
f"<:channels:1169684589640429599> Channels: **{len(ch)}**\n",
value=(
f"<:info:1169685342077583480> Servers: **{len(self.bot.guilds)}**\n"
f"<:globe:1169690501063123065> Big servers (1000+): "
f"**{len([g for g in self.bot.guilds if g.member_count >= 1000])}**\n"
f"<:members:1169684583369949285> Users: **{len(set(self.bot.get_all_members()))}**\n"
f"<:channels:1169684589640429599> Channels: **{len(ch)}**\n"
),
inline=False,
)
embed.add_field(
Expand Down
25 changes: 17 additions & 8 deletions src/cogs/economy.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ def __init__(
@ui.button(emoji="βœ…", style=ButtonStyle.secondary, custom_id="test")
async def yes_callback(self, _: ui.Button, interaction: MessageInteraction) -> None:
await interaction.send(content="Please, wait...")

received_balance = await self.economy.get_balance(user_id=self.receiver.id)
new_received_balance = received_balance + self.money

old_bal_sender = await self.economy.get_balance(user_id=self.ctx.author.id)
new_sender_balance = old_bal_sender - self.money
print(new_received_balance, new_sender_balance)

try:
await self.economy.update_db(
{"id": self.receiver.id}, {"balance": new_received_balance}
Expand Down Expand Up @@ -113,7 +115,10 @@ async def balance(self, interaction: CommandInteraction):
await interaction.send(
embed=Embed(
title="Balance",
description=f"{interaction.author.name}, your balance:\n**Cash:** {money} πŸͺ™\n**Bank:** {bank}πŸͺ™\n**Total:** {total}πŸͺ™",
description=(
f"{interaction.author.name}, your balance:"
f"\n**Cash:** {money} πŸͺ™\n**Bank:** {bank}πŸͺ™\n**Total:** {total}πŸͺ™"
),
),
ephemeral=True,
)
Expand Down Expand Up @@ -179,7 +184,10 @@ async def bank(
await interaction.send(
embed=Embed(
title="Balance",
description=f"{interaction.author.name}, your balance now:\n**Cash:** {cash} πŸͺ™\n**Bank:** {bank}πŸͺ™\n**Total:** {total}πŸͺ™",
description=(
f"{interaction.author.name}, your balance now:"
f"\n**Cash:** {cash} πŸͺ™\n**Bank:** {bank}πŸͺ™\n**Total:** {total}πŸͺ™"
),
)
)

Expand Down Expand Up @@ -218,12 +226,13 @@ async def pay(
description="You can't transfer less than 1 πŸͺ™",
color=Color.red(),
).set_footer(text=f"Command executed by {interaction.author}"),
) #
)
else:
if isinstance(user, Member):
res = user.id
else:
res = await MemberConverter().convert(interaction, user)
res = (
user.id
if isinstance(user, Member)
else await MemberConverter().convert(interaction, str(user))
)
await interaction.send(
f"Are you sure you want transfer {money} πŸͺ™ to {res.mention}?",
view=Buttons(
Expand Down
Loading

0 comments on commit 3bd6efa

Please sign in to comment.