Skip to content

Commit

Permalink
Merge pull request #172 from MiscGuild/backend-redo
Browse files Browse the repository at this point in the history
Backend redo
  • Loading branch information
Amxgh authored Mar 21, 2024
2 parents e4e3b7a + c848fee commit 64859d2
Show file tree
Hide file tree
Showing 7 changed files with 300 additions and 119 deletions.
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

0 comments on commit 64859d2

Please sign in to comment.