Skip to content

Commit

Permalink
Adding /erlc bans as well as fixing join logs and kill logs most likely
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeyUsersREC committed Mar 6, 2024
1 parent 596bbb9 commit 4378887
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 3 deletions.
41 changes: 41 additions & 0 deletions cogs/ERLC.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,47 @@ async def operate_and_reload_commandlogs(msg, guild_id: str):

await operate_and_reload_commandlogs(None, guild_id)

@server.command(
name="bans",
description="Filter the bans of your server."
)
@is_staff()
@is_server_linked()
async def bans(self, ctx: commands.Context, username: typing.Optional[str], user_id: typing.Optional[int]):
guild_id = ctx.guild.id
# status: ServerStatus = await self.bot.prc_api.get_server_status(guild_id)
bans: list[prc_api.BanItem] = await self.bot.prc_api.fetch_bans(guild_id)
embed = discord.Embed(
color=BLANK_COLOR,
title="Bans",
description=""
)
status = username or user_id

if not username and user_id:
username = "[PLACEHOLDER]"

if not user_id and username:
user_id = "999999999999999999999999"

for log in bans:
if str(username or "") in str(log.username) or str(user_id or "") in str(log.user_id):
if len(embed.description) > 3800:
break
embed.description += f"> [{log.username}:{log.user_id}](https://roblox.com/users/{log.user_id}/profile)\n"

if embed.description in ['', '\n']:
embed.description = "> This ban was not found." if status else "> Bans were not found in your server."


embed.set_author(
name=ctx.guild.name,
icon_url=ctx.guild.icon.url
)

await ctx.send(embed=embed)


@server.command(
name="players",
description="See all players in the server."
Expand Down
7 changes: 7 additions & 0 deletions erm.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,13 @@ async def iterate_prc_logs():
# This means the key is most likely banned or revoked.
await bot.server_keys.delete_by_id(guild.id)
continue
except Exception as e:
channel = await bot.fetch_channel(1213523576603410452)
await channel.send(content=f"[3] {(str(e) or repr(e))=}")
with push_scope() as scope:
scope.level = "error"
capture_exception(e)
continue


sorted_kill_logs = sorted(kill_logs, key=lambda x: x.timestamp, reverse=False)
Expand Down
6 changes: 3 additions & 3 deletions utils/prc_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ async def fetch_bans(self, guild_id: int):

if status_code == 200:
return [BanItem(
username=int(user_id),
user_id=username
user_id=int(user_id),
username=username
) for user_id, username in response_json.items()]
else:
raise ResponseFailure(
Expand Down Expand Up @@ -287,7 +287,7 @@ async def unban_user(self, guild_id: int, user_id: int):
# # await client.run_command(0, '')
# logs = (await client.fetch_server_logs(0))
# for log in logs:
# # print(f"{datetime.datetime.fromtimestamp(log.timestamp).strftime('%m/%d/%Y, %H:%M:%S')} | {log.username}: {log.command}")
# # print(f"{datetime.datetime.fromtimestamp(log.timestamp).strftime('%m/%d/%Y, %H:%M:%S')} | {log.username}: {log}")
#
#
# asyncio.run(main())
Expand Down

0 comments on commit 4378887

Please sign in to comment.