Skip to content

Commit

Permalink
Adding Team Restrictions, adding Welcome Messaging - team restriction…
Browse files Browse the repository at this point in the history
… configuration not yet added
  • Loading branch information
Mikey committed Dec 29, 2024
1 parent adb15cb commit f8eb1fe
Show file tree
Hide file tree
Showing 12 changed files with 626 additions and 63 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ Pipfile.lock
.git/
package.json
package_lock.json
venv/
venv/
.venv/
5 changes: 1 addition & 4 deletions cogs/Actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ async def actions_manage(self, ctx: commands.Context):
title="Actions",
color=BLANK_COLOR
)
if isinstance(ctx, commands.Context):
await log_command_usage(self.bot,ctx.guild, ctx.author, f"Actions Manage")
else:
await log_command_usage(self.bot,ctx.guild, ctx.user, f"Actions Manage")
await log_command_usage(self.bot,ctx.guild, ctx.author, f"Actions Manage")
actions = [i async for i in self.bot.db.actions.find({'Guild': ctx.guild.id})]
for item in actions:
embed.add_field(
Expand Down
10 changes: 2 additions & 8 deletions cogs/ActivityNotices.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,10 +691,7 @@ async def ra_request(self, ctx, time, *, reason):
member="Who's RA would you like to administrate? Specify a Discord user."
)
async def ra_admin(self, ctx, member: discord.Member):
try:
await log_command_usage(self.bot,ctx.guild, ctx.author, f"RA Admin: {member}")
except:
await log_command_usage(self.bot,ctx.guild, ctx.user, f"RA Admin: {member}")
await log_command_usage(self.bot,ctx.guild, ctx.author, f"RA Admin: {member}")
await self.core_commands.core_command_admin(ctx, 'ra', member)

@commands.hybrid_group(
Expand Down Expand Up @@ -743,10 +740,7 @@ async def loa_request(self, ctx, time, *, reason):
member="Who's LOA would you like to administrate? Specify a Discord user."
)
async def loa_admin(self, ctx, member: discord.Member):
if isinstance(ctx, commands.Context):
await log_command_usage(self.bot,ctx.guild, ctx.author, f"LOA Admin: {member}")
else:
await log_command_usage(self.bot,ctx.guild, ctx.user, f"LOA Admin: {member}")
await log_command_usage(self.bot,ctx.guild, ctx.author, f"LOA Admin: {member}")

return await self.core_commands.core_command_admin(ctx, 'loa', member)

Expand Down
51 changes: 37 additions & 14 deletions cogs/Configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
YesNoColourMenu,
NextView, BasicConfiguration, LOAConfiguration, ShiftConfiguration, RAConfiguration,
PunishmentsConfiguration, GameSecurityConfiguration, GameLoggingConfiguration, AntipingConfiguration,
ActivityNoticeManagement, PunishmentManagement, ShiftLoggingManagement, ERMCommandLog, WhitelistVehiclesManagement
ActivityNoticeManagement, PunishmentManagement, ShiftLoggingManagement, ERMCommandLog, WhitelistVehiclesManagement,
PriorityRequestConfiguration
)
from utils.paginators import CustomPage, SelectPagination
from utils.utils import require_settings, generator, log_command_usage
Expand All @@ -35,10 +36,7 @@ def __init__(self, bot):
)
@is_management()
async def _setup(self, ctx: commands.Context):
if isinstance(ctx, commands.Context):
await log_command_usage(self.bot,ctx.guild, ctx.author, f"Setup")
else:
await log_command_usage(self.bot,ctx.guild, ctx.user, f"Setup")
await log_command_usage(self.bot,ctx.guild, ctx.author, f"Setup")
bot = self.bot
from utils.constants import base_configuration
current_settings = None
Expand Down Expand Up @@ -491,10 +489,7 @@ async def _config(self, ctx: commands.Context):
bot = self.bot
settings = await bot.settings.find_by_id(ctx.guild.id)

if isinstance(ctx, commands.Context):
await log_command_usage(self.bot,ctx.guild, ctx.author, f"Config")
else:
await log_command_usage(self.bot,ctx.guild, ctx.user, f"Config")
await log_command_usage(self.bot,ctx.guild, ctx.author, f"Config")

basic_settings_view = BasicConfiguration(bot, ctx.author.id, [
(
Expand Down Expand Up @@ -776,9 +771,31 @@ async def _config(self, ctx: commands.Context):
]
)

priority_settings = await self.bot.priority_settings.db.find_one({"guild_id": str(ctx.guild.id)})

priority_requests = PriorityRequestConfiguration(
bot,
ctx.author.id,
[
(
"Blacklisted Roles",
[discord.utils.get(ctx.guild.roles, id=int(role)) for role in (priority_settings or {}).get("blacklisted_roles") or [0]]
),
(
"Mentioned Roles",
[discord.utils.get(ctx.guild.roles, id=int(role)) for role in (priority_settings or {}).get("mentioned_roles") or [0]]
),
(
"Priority Channel",
[discord.utils.get(ctx.guild.channels, id=channel) if (
channel := ((priority_settings or {}).get("channel_id"))) else 0]
)
]
)

pages = []

for index, view in enumerate([basic_settings_view, loa_configuration_view, shift_management_view, ra_view, roblox_punishments, security_view, logging_view, antiping_view, erlc_view, erm_command_log_view]):
for index, view in enumerate([basic_settings_view, loa_configuration_view, shift_management_view, ra_view, roblox_punishments, security_view, logging_view, antiping_view, erlc_view, erm_command_log_view, priority_requests]):
corresponding_embeds = [
discord.Embed(
title="Basic Settings",
Expand Down Expand Up @@ -882,6 +899,15 @@ async def _config(self, ctx: commands.Context):
"**ERM Log Channel:** This channel is where ERM will log all administrative commands and configuration changes made by Admin & Management Roles. This is useful for auditing purposes, ensuring transparency, and detecting any potential abuse of administrative privileges. This is a critical part of ERM and should be enabled for all servers using ERM.\n\n"
"All commands such as Duty Admin, LOA Admin, RA Admin, Server Manage, Config, etc., as well as nearly all configuration changes, will be logged in this channel."
)
),
discord.Embed(
title="Priority Requests",
color=blank_color,
description=(
"**Blacklisted Roles:** These are the roles which are unable to use the ERM Priority Request system. They will not be able to submit priority requests if they have any of these roles.\n\n"
"**Mentioned Roles:** When a priority request is submitted, these roles will be mentioned in the accompanying message advising staff in regards to the priority request.\n\n"
"**Priority Channel:** This channel will be where priority requests are submitted, and where the message advising staff in regards to the priority request will be sent."
)
)

]
Expand Down Expand Up @@ -924,10 +950,7 @@ async def server(self, ctx: commands.Context):
@is_management()
@require_settings()
async def server_management(self, ctx: commands.Context):
if isinstance(ctx, commands.Context):
await log_command_usage(self.bot,ctx.guild, ctx.author, f"Server Manage")
else:
await log_command_usage(self.bot,ctx.guild, ctx.user, f"Server Manage")
await log_command_usage(self.bot,ctx.guild, ctx.author, f"Server Manage")

embeds = [
discord.Embed(
Expand Down
5 changes: 1 addition & 4 deletions cogs/CustomCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ async def custom(self, ctx):
async def custom_manage(self, ctx):
bot = self.bot
Data = await bot.custom_commands.find_by_id(ctx.guild.id)
if isinstance(ctx, commands.Context):
await log_command_usage(self.bot,ctx.guild, ctx.author, f"Custom Manage")
else:
await log_command_usage(self.bot,ctx.guild, ctx.user, f"Custom Manage")
await log_command_usage(self.bot,ctx.guild, ctx.author, f"Custom Manage")
if Data is None:
Data = {"_id": ctx.guild.id, "commands": []}

Expand Down
7 changes: 2 additions & 5 deletions cogs/ERLC.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ERLC(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot


@staticmethod
def is_server_linked():
async def predicate(ctx: commands.Context):
guild_id = ctx.guild.id
Expand Down Expand Up @@ -116,10 +116,7 @@ async def erlc_hint(self, ctx: commands.Context, *, hint: str):
key='Your PRC Server Key - check your server settings for details'
)
async def server_link(self, ctx: commands.Context, key: str):
if isinstance(ctx, commands.Context):
await log_command_usage(self.bot,ctx.guild, ctx.author, f"ERLC Link")
else:
await log_command_usage(self.bot,ctx.guild, ctx.user, f"ERLC Link")
await log_command_usage(self.bot,ctx.guild, ctx.author, f"ERLC Link")
status: int | ServerStatus = await self.bot.prc_api.send_test_request(key)
if isinstance(status, int):
await (ctx.send if not ctx.interaction else ctx.interaction.response.send_message)(
Expand Down
5 changes: 1 addition & 4 deletions cogs/Reminders.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ async def reminders(self, ctx):
@require_settings()
async def manage_reminders(self, ctx):
bot = self.bot
if isinstance(ctx, commands.Context):
await log_command_usage(self.bot,ctx.guild, ctx.author, f"Reminders Manage")
else:
await log_command_usage(self.bot,ctx.guild, ctx.user, f"Reminders Manage")
await log_command_usage(self.bot,ctx.guild, ctx.author, f"Reminders Manage")
reminder_data = await bot.reminders.find_by_id(ctx.guild.id)
if reminder_data is None:
reminder_data = {"_id": ctx.guild.id, "reminders": []}
Expand Down
5 changes: 1 addition & 4 deletions cogs/ShiftLogging.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,7 @@ async def duty_admin(self, ctx, member: discord.Member, type: str = "Default",fo
pass

shift = await self.bot.shift_management.get_current_shift(member, ctx.guild.id)
if isinstance(ctx, commands.Context):
await log_command_usage(self.bot,ctx.guild, ctx.author, f"Duty Admin for {member.name}")
else:
await log_command_usage(self.bot,ctx.guild, ctx.user, f"Duty Admin for {member.name}")
await log_command_usage(self.bot,ctx.guild, ctx.author, f"Duty Admin for {member.name}")
previous_shifts = [i async for i in self.bot.shift_management.shifts.db.find({
"UserID": member.id,
"Guild": ctx.guild.id,
Expand Down
Loading

0 comments on commit f8eb1fe

Please sign in to comment.