Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backend redo #172

Merged
merged 30 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
461d7a3
feat: created a new db table for discord members and their uuids.
Amxgh Mar 21, 2024
27de19c
feat: new function that fetches a user's uuid from db using their dis…
Amxgh Mar 21, 2024
c757bd0
feat: new function that adds a new user's discord id and uuid to the …
Amxgh Mar 21, 2024
8fa3a50
feat: new function that updates a member's uuid/inserts new member if…
Amxgh Mar 21, 2024
95daf68
feat: updated members table to include username
Amxgh Mar 21, 2024
ec0e70d
feat: changed functionality of get_uuid() to support the addition of…
Amxgh Mar 21, 2024
8fdca51
feat: changed functionality of insert_new_member() to support the ad…
Amxgh Mar 21, 2024
e6d883a
feat: changed functionality of update_member() to support the additi…
Amxgh Mar 21, 2024
1301b34
feat: updated qotd embed format
Amxgh Mar 21, 2024
babb0c1
refactor: changed function name to improve clarity
Amxgh Mar 21, 2024
145c61e
feat: new func that returns the player's username from their uuid usi…
Amxgh Mar 21, 2024
5d671ef
refactor: optimized imports
Amxgh Mar 21, 2024
0d45419
feat: set a max length for a qotd
Amxgh Mar 21, 2024
7f25c49
feat: gmember() now fetches the uuid and username from the db instead…
Amxgh Mar 21, 2024
0b29c4c
feat: invites() now fetches the uuid and username from the db instead…
Amxgh Mar 21, 2024
8ce37a4
feat: info() now fetches the uuid and username from the db instead of…
Amxgh Mar 21, 2024
41bcbcd
feat: dnkl_check() now fetches the uuid and username from the db inst…
Amxgh Mar 21, 2024
600a6d7
feat: removed rolecheck
Amxgh Mar 21, 2024
a5774d8
feat: implemented new rolecheck
Amxgh Mar 21, 2024
c5a8c5f
feat: updated rolecheck to change a former active member's nick if it…
Amxgh Mar 21, 2024
c68e843
feat: new class attributes, uuid and username
Amxgh Mar 21, 2024
ec77a2e
feat: String.gmember() only calls the mojang api if self.uuid and sel…
Amxgh Mar 21, 2024
1253b66
feat: String.info() only calls the mojang api if self.uuid and self.u…
Amxgh Mar 21, 2024
2e8edb0
feat: String.dnkl_check() only calls the mojang api if self.uuid and …
Amxgh Mar 21, 2024
1ea2c2e
feat: String.invites() only calls the mojang api if self.uuid and sel…
Amxgh Mar 21, 2024
f96efd5
fix: rolecheck fix
Amxgh Mar 21, 2024
a70793b
feat: implemented a new function that adds all players to the db
Amxgh Mar 21, 2024
7918cd1
feat: created a new function for the new command
Amxgh Mar 21, 2024
0e6b480
fix: fixed incorrect return statement.
Amxgh Mar 21, 2024
c848fee
feat: added a print statement at the end
Amxgh Mar 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/cogs/general.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import discord
from discord.ext import commands, bridge
from discord.commands import option
from discord.ext import commands, bridge

from src.func.String import String
from src.func.Union import Union



class General(commands.Cog, name="general"):
"""
Contains source, avatar, qotd.
Expand Down Expand Up @@ -47,17 +46,17 @@ class ModalCreator(discord.ui.Modal):
def __init__(self) -> None:
# fields = ["LABEL", "PLACEHOLDER", STYLE]
super().__init__(title="QOTD Creator")
self.add_item(discord.ui.InputText(label="What is the question of the day?", placeholder="Enter the question here", style=discord.InputTextStyle.long))

self.add_item(discord.ui.InputText(label="What is the question of the day?",
placeholder="Enter the question here",
max_length=256,
style=discord.InputTextStyle.long))

async def callback(self, interaction: discord.Interaction):
await interaction.response.send_message("The QOTD has been sent!")
await String(string=self.children[0].value).qotd(ctx)


await ctx.send_modal(modal=ModalCreator())



def setup(bot):
bot.add_cog(General(bot))
16 changes: 10 additions & 6 deletions src/cogs/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from src.func.Integer import Integer
from src.func.String import String
from src.utils.consts import gvg_info_embed, requirements_embed, resident_embed
from src.utils.discord_utils import name_grabber
from src.utils.db_utils import get_db_uuid_username_from_discord_id


class Guild(commands.Cog, name="guild"):
Expand All @@ -27,9 +27,10 @@ def __init__(self, bot):
async def gmember(self, ctx, name: str = None):
"""View the given user's guild experience over the past week!"""
if not name:
name = await name_grabber(ctx.author)

res = await String(string=name).gmember(ctx)
uuid, username = await get_db_uuid_username_from_discord_id(ctx.author.id)
res = await String(uuid=uuid, username=username).gmember(ctx)
else:
res = await String(string=name).gmember(ctx)
if isinstance(res, discord.Embed):
await ctx.respond(embed=res)
if isinstance(res, str):
Expand Down Expand Up @@ -91,8 +92,11 @@ async def invites(self, ctx, name: str = None):
"""View your invitation stats"""
await ctx.defer()
if not name:
name = await name_grabber(ctx.author)
await ctx.respond(embed=await String(name).invites())
uuid, _ = await get_db_uuid_username_from_discord_id(ctx.author.id)
res = await String(string=uuid).invites()
else:
res = await String(string=name).invites()
await ctx.respond(embed=res)

def setup(bot):
bot.add_cog(Guild(bot))
15 changes: 10 additions & 5 deletions src/cogs/hypixel.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from src.func.General import General
from src.func.String import String
from src.func.Union import Union
from src.utils.discord_utils import name_grabber
from src.utils.db_utils import get_db_uuid_username_from_discord_id


class Hypixel(commands.Cog, name="hypixel"):
Expand Down Expand Up @@ -47,8 +47,11 @@ async def sync(self, ctx, name, tag: str = None):
async def info(self, ctx, name: str = None):
"""View Hypixel stats of the given user!"""
if not name:
name = await name_grabber(ctx.author)
await ctx.respond(embed=await String(string=name).info())
uuid, username = await get_db_uuid_username_from_discord_id(ctx.author.id)
res = await String(uuid=uuid, username=username).info()
else:
res = await String(string=name).info()
await ctx.respond(embed=res)

@bridge.bridge_command(aliases=['dnkladd', 'dnkla'])
@commands.has_any_role("Staff")
Expand Down Expand Up @@ -93,9 +96,11 @@ async def dnkl_list(self, ctx):
async def dnkl_check(self, ctx, name: str = None):
"""Check whether you are eligible for the do-not-kick-list!"""
if not name:
name = await name_grabber(ctx.author)
uuid, username = await get_db_uuid_username_from_discord_id(ctx.author.id)
res = await String(uuid=uuid, username=username).dnklcheck()
else:
res = await String(string=name).dnklcheck()

res = await String(string=name).dnklcheck()
if isinstance(res, discord.Embed):
await ctx.respond(embed=res)
elif isinstance(res, str):
Expand Down
6 changes: 6 additions & 0 deletions src/cogs/staff.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ async def rolecheck(self, ctx, send_ping: bool = True):
"""Sync the names and roles of everyone in the discord!"""
await General.rolecheck(ctx, send_ping)

@bridge.bridge_command()
@commands.has_role("new role")
async def add_members(self, ctx):
await General.add_players(ctx)



def setup(bot):
bot.add_cog(Staff(bot))
Loading
Loading