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

New Features #110

Open
wants to merge 101 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 89 commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
93ff5b6
Fixed Bugs
shashankpandey04 Aug 1, 2024
4e501f0
Updated on_message.py
shashankpandey04 Aug 1, 2024
3dfc66d
Updated on_message.py
shashankpandey04 Aug 1, 2024
fa0ed87
Updated on_message.py
shashankpandey04 Aug 1, 2024
2578b93
Updated CustomCommands,py
shashankpandey04 Aug 1, 2024
736fa65
Updated erm.py
shashankpandey04 Aug 1, 2024
a4c321f
Updated on_message.py
shashankpandey04 Aug 1, 2024
36119c5
Updated on_message.py
shashankpandey04 Aug 1, 2024
d099798
Merged
shashankpandey04 Aug 1, 2024
efb73b6
Updated erm.py
shashankpandey04 Aug 1, 2024
a0c3ca2
Updated menu.py
shashankpandey04 Aug 1, 2024
f5726ea
Updated erm.py
shashankpandey04 Aug 1, 2024
a47afc6
Fixed Duty Admin/Manage Bug
shashankpandey04 Aug 3, 2024
7164606
Fixed erlc logs embed bug
shashankpandey04 Aug 3, 2024
6d72c73
Updated Auto Kick/Ban Logging
shashankpandey04 Aug 5, 2024
090efd1
Fixed Data Retention
shashankpandey04 Aug 5, 2024
f1133ad
Fixing Merge
shashankpandey04 Aug 5, 2024
836c162
Merge branch 'main' of https://github.com/shashankpandey04/ERM
shashankpandey04 Aug 5, 2024
843efcc
Fixed on_message.py
shashankpandey04 Aug 5, 2024
c2811e8
Moved functions to utils.py
shashankpandey04 Aug 5, 2024
e6325b5
Updated menu.py
shashankpandey04 Aug 5, 2024
2868836
Updated menu.py
shashankpandey04 Aug 5, 2024
302f57f
Merge branch 'MikeyUsersREC:main' into main
shashankpandey04 Aug 6, 2024
2bab767
Merge branch 'MikeyUsersREC:main' into main
shashankpandey04 Aug 7, 2024
096b956
Review Patched
shashankpandey04 Aug 7, 2024
a47a218
Merge branch 'main' of https://github.com/shashankpandey04/ERM
shashankpandey04 Aug 7, 2024
27aab69
Updated ShiftLogging.py
shashankpandey04 Aug 7, 2024
bb5b049
Updated ShiftLogging.py
shashankpandey04 Aug 7, 2024
97240f6
Added `h` aliases in duty history.
shashankpandey04 Aug 7, 2024
dcf4b8d
Updated menu.py
shashankpandey04 Aug 7, 2024
5b6050f
Merge branch 'main' into main
shashankpandey04 Aug 7, 2024
14e18bb
Updated erm.py
shashankpandey04 Aug 7, 2024
9a71d08
Updated ERLC.py
shashankpandey04 Aug 8, 2024
03c80ea
Merge branch 'main' of https://github.com/shashankpandey04/ERM
shashankpandey04 Aug 8, 2024
05dc12c
Fixing db schema
shashankpandey04 Aug 12, 2024
58ee5bc
Updating on_punishment.py
shashankpandey04 Aug 12, 2024
bbf7462
Updated on_punishment.py
shashankpandey04 Aug 12, 2024
42215fe
Merge main branch from "https://github.com/MikeyUsersREC/ERM"
shashankpandey04 Aug 12, 2024
158987a
Updated Shift Reports
shashankpandey04 Aug 14, 2024
7c0f677
Updated on_message.py
shashankpandey04 Aug 14, 2024
d928b20
Fixed ERLC Statistics
shashankpandey04 Aug 14, 2024
dc5ebe7
Updated LOA
shashankpandey04 Aug 14, 2024
897bb62
Updated ERLC.py
shashankpandey04 Aug 18, 2024
f401e94
Updated Discord Checks
shashankpandey04 Aug 18, 2024
262501d
Updated ERLC.py
shashankpandey04 Aug 18, 2024
ae75a64
Updated ERLC.py
shashankpandey04 Aug 18, 2024
5ed3216
Fixed Player Join/Leave Log and Kill Logs
shashankpandey04 Aug 19, 2024
35c58f3
Updated ShiftLogging.py
shashankpandey04 Aug 19, 2024
390bf5e
Custom Command Embed Edit
shashankpandey04 Aug 21, 2024
d0028d0
Merge branch 'MikeyUsersREC:main' into main
shashankpandey04 Aug 28, 2024
f255931
Changed Code
shashankpandey04 Aug 28, 2024
a55d6c2
Merge branch 'MikeyUsersREC:main' into main
shashankpandey04 Aug 29, 2024
84e0af9
Updated prc_api.py
shashankpandey04 Aug 30, 2024
1fe9721
Updated on_message.py
shashankpandey04 Sep 1, 2024
bd0aefd
Merge branch 'MikeyUsersREC:main' into main
shashankpandey04 Sep 3, 2024
6dc0f7a
Merge branch 'MikeyUsersREC:main' into main
shashankpandey04 Sep 22, 2024
d911a82
Merge branch 'MikeyUsersREC:main' into main
shashankpandey04 Sep 25, 2024
fdc469a
Merge branch 'main' of https://github.com/shashankpandey04/ERM
shashankpandey04 Sep 26, 2024
8e075e1
Updated prc_api.py
shashankpandey04 Sep 26, 2024
6cbc667
Added LOA View command
shashankpandey04 Sep 26, 2024
3036362
Updated ActivityNotice.py
shashankpandey04 Sep 26, 2024
d5a2d01
Merge branch 'MikeyUsersREC:main' into main
shashankpandey04 Oct 11, 2024
9dd48c6
Merge branch 'main' of https://github.com/shashankpandey04/ERM
shashankpandey04 Oct 11, 2024
f292a9b
Updated Activity Notice
shashankpandey04 Oct 11, 2024
533f29a
Changed Added
shashankpandey04 Oct 11, 2024
1c2d978
Merge branch 'MikeyUsersREC:main' into main
shashankpandey04 Oct 11, 2024
e1e42b2
Merge branch 'MikeyUsersREC:main' into main
shashankpandey04 Oct 11, 2024
c14148e
Merge branch 'MikeyUsersREC:main' into main
shashankpandey04 Oct 11, 2024
b5f7fbc
Merge branch 'main' of https://github.com/shashankpandey04/ERM
shashankpandey04 Oct 13, 2024
95f1617
Updated utils.py
shashankpandey04 Oct 13, 2024
12018c4
Updated utils.py
shashankpandey04 Oct 13, 2024
03c3c1c
Merge branch 'MikeyUsersREC:main' into main
shashankpandey04 Oct 14, 2024
3421b78
Updated Discord Check
shashankpandey04 Oct 15, 2024
f06f942
Merge branch 'MikeyUsersREC:main' into main
shashankpandey04 Nov 4, 2024
dde3eee
Merge branch 'MikeyUsersREC:main' into main
shashankpandey04 Nov 9, 2024
f4e570f
Merge branch 'MikeyUsersREC:main' into main
shashankpandey04 Nov 15, 2024
5dad595
Merge branch 'main' of https://github.com/shashankpandey04/ERM
shashankpandey04 Nov 22, 2024
61d0ed6
Allowing Admin Role To Accept LOAs
shashankpandey04 Nov 22, 2024
05d2927
Updated menu.py
shashankpandey04 Nov 22, 2024
74c87d0
Updated prc_api.py
shashankpandey04 Nov 22, 2024
94c6a72
Updaed erm.py
shashankpandey04 Nov 22, 2024
668ca1d
Updated erm.py
shashankpandey04 Nov 22, 2024
e8d8f25
Updated on_message.py
shashankpandey04 Nov 22, 2024
9faaced
Updated menu.py
shashankpandey04 Nov 22, 2024
4a78b94
Updated erm.py
shashankpandey04 Nov 22, 2024
3c3e4af
Updated Discord Checks
shashankpandey04 Nov 22, 2024
a21ac84
Updated menus.py
shashankpandey04 Nov 22, 2024
3f24b20
Updated menu.py
shashankpandey04 Nov 22, 2024
39be997
Updated on_punishment.py
shashankpandey04 Nov 23, 2024
cf2717a
Updated Code
shashankpandey04 Dec 3, 2024
e17170b
Updated PRC_API
shashankpandey04 Dec 3, 2024
43787c3
Fixed ERM Link Command
shashankpandey04 Dec 3, 2024
19f9b00
Merge branch 'MikeyUsersREC:main' into main
shashankpandey04 Dec 4, 2024
53bc7a8
Merge branch 'main' of https://github.com/shashankpandey04/ERM
shashankpandey04 Dec 8, 2024
c4945b5
Merge branch 'MikeyUsersREC:main' into main
shashankpandey04 Dec 26, 2024
17ce13e
Updated erm.py
shashankpandey04 Dec 28, 2024
6cdb34e
Merge branch 'main' of https://github.com/shashankpandey04/ERM
shashankpandey04 Jan 2, 2025
0d6a7c5
Fixed Conflicts
shashankpandey04 Jan 2, 2025
23ddc79
Automated Discord Checks
shashankpandey04 Jan 3, 2025
8ecc06b
Merge branch 'MikeyUsersREC:main' into main
shashankpandey04 Jan 3, 2025
aaf5701
Merge branch 'main' of https://github.com/shashankpandey04/ERM
shashankpandey04 Jan 3, 2025
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
5 changes: 4 additions & 1 deletion .env.template
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good

Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,7 @@ AI_API_ENABLED=TRUE # TRUE, or FALSE
# Other ERM API Services
API_PRIVATE_KEY=
API_STATIC_TOKEN=
BASE_API_URL=
BASE_API_URL=
# PRC API Services
PRC_API_URL=
PRC_API_KEY=
130 changes: 125 additions & 5 deletions cogs/ActivityNotices.py
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im fine with the /loa view, /ra view stuff
but, you cant have an ephemeral paginator; so you have to pick one or the other
i found this out the hard way with the paginator being broken on /loa active for a long time so we had to scrap the ephemeral part of it

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you might wanna add an exception handler to starting, just in case people put like 21/10/2024 or smth

Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ async def respond(embed: discord.Embed):
)


async def core_command_request(self, ctx: commands.Context, request_type_object: str, duration: str, reason: str, return_bypass = None, override_victim = None):
async def core_command_request(self, ctx: commands.Context, request_type_object: str, duration: str, reason: str, return_bypass = None, override_victim = None, starting: str = None):
settings = await self.bot.settings.find_by_id(ctx.guild.id)
if not settings.get('staff_management') or not settings.get('staff_management', {}).get(
f'{request_type_object.lower()}_role', None) or not settings.get('staff_management', {}).get('enabled'):
Expand Down Expand Up @@ -522,6 +522,9 @@ async def core_command_request(self, ctx: commands.Context, request_type_object:
)

current_timestamp = int(datetime.datetime.now().timestamp())
if starting:
start_after_seconds = time_converter(starting)
current_timestamp += start_after_seconds

expiry_timestamp = current_timestamp + duration_seconds

Expand Down Expand Up @@ -640,6 +643,100 @@ def setup_embed() -> discord.Embed:
await ctx.send(
embed=embeds[0]
)

async def core_command_view(self, ctx: commands.Context, request_type_object: str):
settings = await self.bot.settings.find_by_id(ctx.guild.id)
if not settings.get('staff_management') or not settings.get('staff_management', {}).get(f'{request_type_object.lower()}_role', None):
await ctx.send(
embed=discord.Embed(
title="Not Enabled",
description=f"{request_type_object.upper()} Requests are not enabled on this server.",
color=BLANK_COLOR
)
)
return

request_upper = request_type_object.upper()

all_requests = []
async for item in self.bot.loas.db.find({
"guild_id": ctx.guild.id,
"user_id": ctx.author.id,
"type": request_upper
}):
all_requests.append(item)

def setup_embed() -> discord.Embed:
embed = discord.Embed(
title="Activity Notices",
color=BLANK_COLOR
)
embed.set_author(
name=ctx.guild.name,
icon_url=ctx.guild.icon
)
return embed

embeds = []
for item in all_requests:
if len(embeds) == 0:
embeds.append(setup_embed())
if len(embeds[-1].fields) > 4:
embeds.append(setup_embed())
embeds[-1].add_field(
name=f"{item['type']}",
value=(
f"> **Reason:** {item['reason']}\n"
f"> **Started At:** <t:{int(item.get('started_at', int(item['_id'].split('_')[2])))}>\n"
f"> **Ended At:** <t:{int(item['expiry'])}>"
),
inline=False
)
pages = [
CustomPage(
embeds=[embed],
identifier=str(index + 1)
) for index, embed in enumerate(embeds)
]
if len(pages) == 0:
return await ctx.send(
embed=discord.Embed(
title="No Activity Notices",
description="There were no active Activity Notices found.",
color=BLANK_COLOR
)
)

if ctx.interaction:
interaction = ctx.interaction
else:
interaction = ctx

if len(pages) != 1:
paginator = SelectPagination(ctx.author.id, pages=pages)
try:
await interaction.response.send_message(
embed=embeds[0],
view=paginator,
ephemeral=True
)
except:
await interaction.channel.send(
embed=embeds[0],
view=paginator
)

else:
try:
await interaction.response.send_message(
embed=embeds[0],
ephemeral=True
)
except:
await interaction.channel.send(
embed=embeds[0],
)


class StaffManagement(commands.Cog):
def __init__(self, bot):
Expand Down Expand Up @@ -676,8 +773,9 @@ async def ra_active(self, ctx):
@is_staff()
@app_commands.describe(time="How long are you going to be on RA for? (s/m/h/d)")
@app_commands.describe(reason="What is your reason for going on RA?")
async def ra_request(self, ctx, time, *, reason):
await self.core_commands.core_command_request(ctx, 'ra', time, reason)
@app_commands.describe(starting="When would you like to start your RA? (s/m/h/d)")
async def ra_request(self, ctx, time, *, reason,starting: str = None):
await self.core_commands.core_command_request(ctx, 'ra', time, reason, starting=starting)

@commands.guild_only()
@ra.command(
Expand All @@ -697,6 +795,17 @@ async def ra_admin(self, ctx, member: discord.Member):
await log_command_usage(self.bot,ctx.guild, ctx.user, f"RA Admin: {member}")
await self.core_commands.core_command_admin(ctx, 'ra', member)

@commands.guild_only()
@ra.command(
name="view",
description="View your active RA",
extras={"category": "Staff Management"},
with_app_command=True,
)
@is_staff()
async def ra_view(self, ctx):
await self.core_commands.core_command_view(ctx, 'ra')

@commands.hybrid_group(
name="loa",
description="File a Leave of Absence request",
Expand All @@ -708,6 +817,16 @@ async def ra_admin(self, ctx, member: discord.Member):
async def loa(self, ctx, time, *, reason):
await ctx.invoke(self.bot.get_command("loa request"), time=time, reason=reason)

@commands.guild_only()
@loa.command(
name="view",
description="View your active LOA",
extras={"category": "Staff Management"},
with_app_command=True,
)
@is_staff()
async def loa_view(self, ctx):
await self.core_commands.core_command_view(ctx, 'loa')

@loa.command(
name="active",
Expand All @@ -728,8 +847,9 @@ async def loa_active(self, ctx):
@is_staff()
@app_commands.describe(time="How long are you going to be on LoA for? (s/m/h/d)")
@app_commands.describe(reason="What is your reason for going on LoA?")
async def loa_request(self, ctx, time, *, reason):
await self.core_commands.core_command_request(ctx, 'loa', time, reason)
@app_commands.describe(starting="When would you like to start your LOA? (s/m/h/d)")
async def loa_request(self, ctx, time, *, reason, starting: str = None):
await self.core_commands.core_command_request(ctx, 'loa', time, reason, starting=starting)

@commands.guild_only()
@loa.command(
Expand Down
4 changes: 2 additions & 2 deletions cogs/CustomCommands.py
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still dont know why we need to replace CustomCommandModification with CustomCommandModificationEdit

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
EmbedCustomisation,
MessageCustomisation,
RemoveCustomCommand,
YesNoColourMenu, CustomCommandOptionSelect, CustomCommandModification,
YesNoColourMenu, CustomCommandOptionSelect, CustomCommandModification, CustomCommandModificationEdit,
CounterButton, ViewVotersButton
)
from utils.autocompletes import command_autocomplete
Expand Down Expand Up @@ -206,7 +206,7 @@ async def custom_manage(self, ctx):
)
)
status = False
view = CustomCommandModification(ctx.author.id, data)
view = CustomCommandModificationEdit(ctx.author.id, data)
if status == True:
await new_msg.edit(view=view,
embed=discord.Embed(
Expand Down
77 changes: 57 additions & 20 deletions cogs/ERLC.py
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i mean, simplifying the regex to a kv dict { name | display | global: member } doesnt sound like that bad of an idea in retrospect
but, two people can have the same display, name, or global name, and then it'd replace the person in the dictionary with that
just something to consider

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed 👍
Suppose you have three members:
Quprgaming
quprgaming
Bajah with a global name of Rajah
Then,

    'quprgaming': [member1, member2], 
    'bajah': [member3], 
    'Rajah': [member3] 
}```

Then the condition 
`if player_username_lower in guild_members_dict and guild_members_dict[player_username_lower]:`
Will check if the user is in guild members and present in that name key of guild member.
This will avoid the confusion between different members with same name.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good!

Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ async def server(self, ctx: commands.Context):
async def erlc_message(self, ctx: commands.Context, *, message: str):
guild_id = ctx.guild.id

try:
message = message.replace("`", "'")
except Exception:
pass

command_response = await self.bot.prc_api.run_command(guild_id, f":m {message}")
if command_response[0] == 200:
Expand Down Expand Up @@ -84,6 +88,11 @@ async def erlc_message(self, ctx: commands.Context, *, message: str):
async def erlc_hint(self, ctx: commands.Context, *, hint: str):
guild_id = ctx.guild.id

try:
hint = hint.replace("`", "'")
except Exception:
pass

await self.secure_logging(guild_id, ctx.author.id, 'Hint', hint)

command_response = await self.bot.prc_api.run_command(guild_id, f":h {hint}")
Expand Down Expand Up @@ -159,6 +168,11 @@ async def server_link(self, ctx: commands.Context, key: str):
async def server_send_command(self, ctx: commands.Context, *, command: str):
if command[0] != ':':
command = ':' + command

try:
command = command.replace("`", "'")
except Exception:
pass
elevated_privileges = None
status: ServerStatus = await self.bot.prc_api.get_server_status(ctx.guild.id)
for item in (status.co_owner_ids + [status.owner_id]):
Expand Down Expand Up @@ -444,7 +458,9 @@ async def operate_and_reload_commandlogs(msg, guild_id: str):
for log in sorted_logs:
if len(embed.description) > 3800:
break
embed.description += f"> [{log.username}](https://roblox.com/users/{log.user_id}/profile) ran the command `{log.command}` • <t:{int(log.timestamp)}:R>\n"
#Replacing ` with " " to prevent markdown issues
command_text = log.command.replace("`", " ")
embed.description += f"> [{log.username}](https://roblox.com/users/{log.user_id}/profile) ran the command `{command_text}` • <t:{int(log.timestamp)}:R>\n"

if embed.description in ['', '\n']:
embed.description = "> No player logs found."
Expand Down Expand Up @@ -692,35 +708,56 @@ async def check(self, ctx: commands.Context):
description=""
)

for player in players:
pattern = re.compile(re.escape(player.username), re.IGNORECASE)
member_found = False
guild_members_dict = {}
for member in ctx.guild.members:
guild_members_dict[member.name.lower()] = member
guild_members_dict[member.display_name.lower()] = member
if hasattr(member, 'global_name') and member.global_name:
guild_members_dict[member.global_name.lower()] = member

for member in ctx.guild.members:
if pattern.search(member.name) or pattern.search(member.display_name) or (hasattr(member, 'global_name') and member.global_name and pattern.search(member.global_name)):
member_found = True
break
guild_member_keys = set(guild_members_dict.keys())
all_users = []

if not member_found:
try:
discord_id = await get_discord_by_roblox(self.bot, player.username)
if discord_id:
member = ctx.guild.get_member(discord_id)
if member:
member_found = True
except discord.HTTPException:
pass
for player in players:
player_username_lower = player.username.lower()

if not member_found:
embed.description += f"> [{player.username}](https://roblox.com/users/{player.id}/profile)\n"
if player_username_lower in guild_member_keys:
continue

if embed.description == "":
try:
discord_id = await get_discord_by_roblox(self.bot, player.username)
if discord_id:
member = ctx.guild.get_member(discord_id)
if member:
continue
except discord.HTTPException:
pass

embed.description += f"> [{player.username}](https://roblox.com/users/{player.id}/profile)\n"
all_users.append(player.username)

if not all_users:
embed.description = "> All players are in the Discord server."

embed.set_author(
name=ctx.guild.name,
icon_url=ctx.guild.icon
)
sett = self.bot.settings.find_by_id(guild_id)
if all_users and len(all_users) > 0:
try:
message = sett.get('ERLC', {}).get('discord_checks', {}).get('message', "Please join the Discord server.")
command = f":pm {','.join(all_users)} {message}"
await self.bot.prc_api.run_command(guild_id, command)
embed.set_footer(
text="A message has been sent to the players who are not in the Discord server."
)
except KeyError:
pass
else:
embed.set_footer(
text="No-one needs to be messaged."
)
await msg.edit(embed=embed)

async def setup(bot):
Expand Down
2 changes: 1 addition & 1 deletion cogs/Punishments.py
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah ok good
you actually followed through on what i said

Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ async def punishments(self, ctx: commands.Context):
@is_staff()
async def punishment_manage(self, ctx: commands.Context):
embed = discord.Embed(
title="Staff Options",
title="Management Options",
description="Using this menu, you can **Manage Punishment Types** as well as **Modify Punishment**.",
color=BLANK_COLOR
)
Expand Down
Loading