Skip to content

Commit

Permalink
Remove staff from db action type
Browse files Browse the repository at this point in the history
  • Loading branch information
bugsbirb committed May 2, 2024
1 parent 1f511a2 commit 39b9eae
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
17 changes: 15 additions & 2 deletions Cogs/Configuration/Views/infractionsview.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,25 @@ def __init__(self, author, name):
options = [
discord.SelectOption(label="Send to channel", emoji="<:tag:1234998802948034721>"),
discord.SelectOption(label="Give Roles", emoji="<:Promotion:1234997026677198938>"),
discord.SelectOption(label='Remove Roles', emoji="<:Infraction:1223063128275943544>")
discord.SelectOption(label='Remove Roles', emoji="<:Infraction:1223063128275943544>"),
discord.SelectOption(label="Staff Database Removal",emoji="<:staffdb:1206253848298127370>" )
]
super().__init__(placeholder='Infraction Type Action', min_values=1, max_values=3, 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 not 'Send to channel' and 'Give Roles' and 'Remove Roles' in options:
await interaction.response.edit_message(content=f"{tick} Succesfully setup 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)
Expand All @@ -225,6 +236,7 @@ async def callback(self, interaction: discord.Interaction):
await interaction.response.edit_message(view=view)
return


class TypeChannel(discord.ui.ChannelSelect):
def __init__(self, author, name, selected):
super().__init__(placeholder='Infractions Type Channel', channel_types=[discord.ChannelType.text, discord.ChannelType.news])
Expand Down Expand Up @@ -257,6 +269,7 @@ async def callback(self, interaction: discord.Interaction):
view = discord.ui.View()
view.add_item(Removeroles(self.author, self.name, self.selected))
await interaction.response.edit_message(content=f"{tick} Succesfully set channel, now set the removed roles!", view=view)

else:
await interaction.response.edit_message(content=f"{tick} Succesfully setup Infraction type.", view=None)

Expand Down Expand Up @@ -338,7 +351,7 @@ async def callback(self, interaction: discord.Interaction):
class EditInfractionModal(discord.ui.Modal):
def __init__(self, author):
self.author = author
super().__init__(title="Create Infraction Type")
super().__init__(title="Edit Infraction Type")

type_input = discord.ui.TextInput(
label='Type',
Expand Down
9 changes: 8 additions & 1 deletion Cogs/Modules/infractions.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
infractiontypes = db['infractiontypes']
infractiontypeactions = db['infractiontypeactions']
options = db['module options']
staffdb = db['staff database']

class Infractions(commands.Cog):
def __init__(self, client: commands.Bot):
self.client = client
Expand Down Expand Up @@ -284,6 +286,10 @@ async def infract(self, ctx: commands.Context, staff: discord.User, action: disc
pass
except discord.HTTPException:
pass
if typeactions.get('dbremoval', False) == True:
await staffdb.delete_one({"staff_id": staff.id})





Expand Down Expand Up @@ -920,7 +926,8 @@ async def callback(self, interaction: discord.Interaction):
except discord.HTTPException:
pass


if typeactions.get('dbremoval', False) == True:
await staffdb.delete_one({"staff_id": user.id})


if typeactions.get('channel'):
Expand Down

0 comments on commit 39b9eae

Please sign in to comment.