Skip to content

Commit

Permalink
Roblox + ERM intergrations
Browse files Browse the repository at this point in the history
  • Loading branch information
bugsbirb committed Feb 2, 2025
1 parent a779e50 commit c1cf6eb
Show file tree
Hide file tree
Showing 12 changed files with 599 additions and 145 deletions.
285 changes: 149 additions & 136 deletions Cogs/Configuration/Components/Infractions.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
Customisation = DB["Customisation"]



class InfractionOption(discord.ui.Select):
def __init__(self, author: discord.Member):
super().__init__(
Expand Down Expand Up @@ -565,7 +566,7 @@ async def on_submit(self, interaction: discord.Interaction):
return await interaction.response.send_message(
embed=embed, ephemeral=True
)
view = discord.ui.View()
view = Done()
view.add_item(InfractionTypesAction(self.author, self.name.value))
return await interaction.response.edit_message(
content=f"{tick} **{interaction.user.display_name}**, you are now editing the infraction type.",
Expand Down Expand Up @@ -674,198 +675,210 @@ def __init__(self, author, name):
emoji="<:erm:1203823601107861504>",
description="Requires ERM API",
),
discord.SelectOption(
label="Kick Group Member", emoji="<:robloxWhite:1200584000390053899>"
),
discord.SelectOption(
label="Change Group Role", emoji="<:robloxWhite:1200584000390053899>"
),
]
super().__init__(
placeholder="Infraction Type Action",
placeholder="Select Infraction Actions",
min_values=1,
max_values=3,
max_values=1,
options=options,
row=0,
)

async def callback(self, interaction: discord.Interaction):
options = self.values
view = discord.ui.View()
filter = {"guild_id": interaction.guild.id, "name": self.name}
if "Staff Database Removal" in options:
await infractiontypeactions.update_one(
filter, {"$set": {"name": self.name, "dbremoval": True}}, upsert=True
if interaction.user.id != self.author.id:
return await interaction.response.send_message(
embed=discord.Embed(
description=f"{redx} This is not your panel!",
color=discord.Color.red(),
),
ephemeral=True,
)
from utils.roblox import GroupRoles

if (
"Send to channel" not in options
and "Give Roles" not in options
and "Remove Roles" not in options
and "Staff Database Removal" not in options
and "Void Shift" not in options
and "Kick Group Member" not in options
):
await interaction.response.edit_message(
content=f"{tick} successfully setup Infraction type.", view=None
)
return
if "Void Shift" in options:
await infractiontypeactions.update_one(
filter, {"$set": {"name": self.name, "voidshift": True}}, upsert=True
)
if (
"Send to channel" not in options
and "Give Roles" not in options
and "Remove Roles" not in options
and "Staff Database Removal" not in options
and "Kick Group Member" not in options
):
await interaction.response.edit_message(
content=f"{tick} successfully setup Infraction type.", view=None
filter = {"guild_id": interaction.guild.id, "name": self.name}
update_data = {"name": self.name}
view = discord.ui.View()

action_mapping = {
"Send to channel": TypeChannel,
"Give Roles": GiveRoles,
"Remove Roles": RemoveRoles,
"Change Group Role": ChangeGroupRole,
}

option = self.values[0]
if option == "Change Group Role":
Roles = await GroupRoles(interaction)
if Roles == 0:
return await interaction.response.send_message(
f"{crisis} **{interaction.user.display_name},** you haven't setup roblox groups.",
ephemeral=True
)
return
if "Kick Group Member" in options:
await infractiontypeactions.update_one(
filter, {"$set": {"name": self.name, "kickgroup": True}}, upsert=True
)
if (
"Send to channel" not in options
and "Give Roles" not in options
and "Remove Roles" not in options
and "Staff Database Removal" not in options
and "Void Shift" not in options
):
await interaction.response.edit_message(
content=f"{tick} successfully setup Infraction type.", view=None
if Roles == 1:
return await interaction.response.send_message(
f"{crisis} **{interaction.user.display_name},** the servers auth token has either expired or someone reset it.",
ephemeral=True

)
return
Roles = Roles.get("groupRoles")
options = []
for role in Roles:
options.append(
discord.SelectOption(
label=f"{role.get('displayName')}",
value=role.get("path"),
)
)
view.add_item(ChangeGroupRole(self.author, self.name, options))

if option in action_mapping and option != "Change Group Role":
view.add_item(action_mapping[option](self.author, self.name))
else:
update_data[option.lower().replace(" ", "")] = True

await infractiontypeactions.update_one(
filter, {"$set": update_data}, upsert=True
)
await interaction.response.edit_message(
content=f"{tick} Infraction type successfully updated.",
view=view if view.children else None,
)


if (
"Send to channel" not in options
and "Give Roles" not in options
and "Remove Roles" not in options
and "Staff Database Removal" not in options
class Done(discord.ui.View):
class Done(discord.ui.Button):
def __init__(
self, label: str, style: discord.ButtonStyle, author: discord.Member
):
super().__init__(label=label, style=style, row=3)
self.author = author

async def callback(self, interaction: discord.Interaction):
if interaction.user.id != self.author.id:
return await interaction.response.send_message(
embed=discord.Embed(
description=f"{redx} This is not your panel!",
color=discord.Color.red(),
),
ephemeral=True,
)
await interaction.response.edit_message(
content=f"{tick} successfully setup Infraction type.", view=None
content=f"{tick} **{interaction.user.display_name},** succesfully updated infraction type.",
view=None,
)
return

if "Send to channel" in options:
view.add_item(TypeChannel(self.author, self.name, options))
await interaction.response.edit_message(view=view)
return
elif "Give Roles" in options:
view.add_item(GiveRoles(self.author, self.name, options))
await interaction.response.edit_message(view=view)
return

elif "Remove Roles" in options:
view.add_item(Removeroles(self.author, self.name, options))
await interaction.response.edit_message(view=view)
return


class TypeChannel(discord.ui.ChannelSelect):
def __init__(self, author, name, selected):
def __init__(self, author, name):
super().__init__(
placeholder="Infractions Type Channel",
placeholder="Select a Channel",
channel_types=[discord.ChannelType.text, discord.ChannelType.news],
)
self.author = author
self.name = name
self.selected = selected
self.author, self.name = author, name

async def callback(self, interaction: discord.Interaction):
if interaction.user.id != self.author.id:
embed = discord.Embed(
description=f"{redx} **{interaction.user.display_name},** this is not your panel!",
color=discord.Colour.brand_red(),
return await interaction.response.send_message(
embed=discord.Embed(
description=f"{redx} This is not your panel!",
color=discord.Color.red(),
),
ephemeral=True,
)
return await interaction.response.send_message(embed=embed, ephemeral=True)
ChannelID = self.values[0]

filter = {"guild_id": interaction.guild.id, "name": self.name}

await infractiontypeactions.update_one(
filter, {"$set": {"name": self.name, "channel": ChannelID.id}}, upsert=True
filter, {"$set": {"channel": self.values[0].id}}, upsert=True
)
await interaction.response.edit_message(
content=f"{tick} Channel set.",
view=None,
)

if "Give Roles" in self.selected:
view = discord.ui.View()
view.add_item(GiveRoles(self.author, self.name, self.selected))
await interaction.response.edit_message(
content=f"{tick} successfully set channel, now set the given roles!",
view=view,
)
elif "Remove Roles" in self.selected:
view = discord.ui.View()
view.add_item(Removeroles(self.author, self.name, self.selected))
await interaction.response.edit_message(
content=f"{tick} successfully set channel, now set the removed roles!",
view=view,
)

else:
await interaction.response.edit_message(
content=f"{tick} successfully setup Infraction type.", view=None
class RemoveRoles(discord.ui.RoleSelect):
def __init__(self, author, name):
super().__init__(placeholder="Select Removed Roles", max_values=10)
self.author, self.name = author, name

async def callback(self, interaction: discord.Interaction):
if interaction.user.id != self.author.id:
return await interaction.response.send_message(
embed=discord.Embed(
description=f"{redx} This is not your panel!",
color=discord.Color.red(),
),
ephemeral=True,
)

filter = {"guild_id": interaction.guild.id, "name": self.name}
await infractiontypeactions.update_one(
filter,
{"$set": {"removedroles": [role.id for role in self.values]}},
upsert=True,
)
await interaction.response.edit_message(
content=f"{tick} Removed roles set.", view=None
)


class GiveRoles(discord.ui.RoleSelect):
def __init__(self, author, name, selected):
super().__init__(placeholder="Given Roles", max_values=10)
self.author = author
self.name = name
self.selected = selected
def __init__(self, author, name):
super().__init__(placeholder="Select Given Roles", max_values=10)
self.author, self.name = author, name

async def callback(self, interaction: discord.Interaction):
if interaction.user.id != self.author.id:
embed = discord.Embed(
description=f"{redx} **{interaction.user.display_name},** this is not your panel!",
color=discord.Colour.brand_red(),
return await interaction.response.send_message(
embed=discord.Embed(
description=f"{redx} This is not your panel!",
color=discord.Color.red(),
),
ephemeral=True,
)
return await interaction.response.send_message(embed=embed, ephemeral=True)
SelectedRoleIds = [role.id for role in self.values]

filter = {"guild_id": interaction.guild.id, "name": self.name}
await infractiontypeactions.update_one(
filter,
{"$set": {"name": self.name, "givenroles": SelectedRoleIds}},
{"$set": {"givenroles": [role.id for role in self.values]}},
upsert=True,
)

if "Remove Roles" in self.selected:
view = discord.ui.View()
view.add_item(Removeroles(self.author, self.name, self.selected))
await interaction.response.edit_message(
content=f"{tick} successfully set channel, now set the removed roles!",
view=view,
)
else:
await interaction.response.edit_message(
content=f"{tick} successfully setup Infraction type.", view=None
)
await interaction.response.edit_message(
content=f"{tick} Given roles set.", view=None
)


class Removeroles(discord.ui.RoleSelect):
def __init__(self, author, name, selected):
super().__init__(placeholder="Removed Roles", max_values=10)
self.author = author
self.name = name
self.selected = selected
class ChangeGroupRole(discord.ui.Select):
def __init__(self, author, name, options):
super().__init__(
options=options, placeholder="What should we change their role to?"
)
self.author, self.name = author, name

async def callback(self, interaction: discord.Interaction):
if interaction.user.id != self.author.id:
embed = discord.Embed(
description=f"{redx} **{interaction.user.display_name},** this is not your panel!",
color=discord.Colour.brand_red(),
return await interaction.response.send_message(
embed=discord.Embed(
description=f"{redx} This is not your panel!",
color=discord.Color.red(),
),
ephemeral=True,
)
return await interaction.response.send_message(embed=embed, ephemeral=True)
Selected = [role.id for role in self.values]

filter = {"guild_id": interaction.guild.id, "name": self.name}
await infractiontypeactions.update_one(
filter,
{"$set": {"name": self.name, "removedroles": Selected}},
{"$set": {"grouprole": self.values[0]}},
upsert=True,
)

await interaction.response.edit_message(
content=f"{tick} successfully setup Infraction type.", view=None
content=f"{tick} Group role changed.", view=None
)


Expand Down
4 changes: 2 additions & 2 deletions Cogs/Configuration/Components/Modmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self, author: discord.User, type):
discord.SelectOption(
label="Modmail Categories",
description="Allows users to make different categories in the modmail system. ",
emoji="<:intergrations:1272191311234990131>",
emoji="<:integrations:1272191311234990131>",
),
]

Expand All @@ -53,7 +53,7 @@ def __init__(self, author: discord.User, type):
discord.SelectOption(
label="Modmail Categories",
description="Allows users to make different categories in the modmail system. ",
emoji="<:intergrations:1272191311234990131>",
emoji="<:integrations:1272191311234990131>",
),
]

Expand Down
Loading

0 comments on commit c1cf6eb

Please sign in to comment.