Skip to content

Commit

Permalink
Merge pull request #3 from heroescreed/Version-1.1.1
Browse files Browse the repository at this point in the history
Version 1.1.1
  • Loading branch information
heroescreed authored Jul 23, 2024
2 parents a497bc0 + 7ec6ddd commit 0ea1323
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions cogs/commands/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async def settings(self, interaction: nextcord.Interaction) -> None:
channels.append(await interaction.guild.fetch_channel(id)) # Fetches channel and adds it to channels list
except NotFound: # If channel has been deleted, remove it from the database list
remove_channel(interaction.guild_id, id)
embed.add_field(name="Channels added to list:", value=", ".join([i.mention for i in channels]), inline=False)
embed.add_field(name=f"Channels added to {get_channel_mode(interaction.guild_id)}:", value=", ".join([i.mention for i in channels]), inline=False)
embed.add_field(name="Role Mode:", value=get_role_mode(interaction.guild_id).capitalize())
roles: List[nextcord.Role] = []
for id in get_roles(interaction.guild_id): # Iterates through each role id in the database list
Expand All @@ -36,7 +36,7 @@ async def settings(self, interaction: nextcord.Interaction) -> None:
roles.append(role) # Adds role to roles list
else: # If role not found remove it from the database list
remove_role(interaction.guild_id, id)
embed.add_field(name="Roles added to list:", value=", ".join([i.mention for i in roles]), inline=False)
embed.add_field(name=f"Roles added to {get_role_mode(interaction.guild_id)}:", value=", ".join([i.mention for i in roles]), inline=False)
embed.set_footer(text="Coded by @heroescreed")
embed.set_thumbnail(interaction.guild.icon.url if interaction.guild.icon else None) # Sets thumbnail to be guild icon, if it has one
await interaction.send(embed=embed, view=Options(interaction.user.id))
Expand Down
28 changes: 14 additions & 14 deletions views/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async def __generate_embed(self, interaction: nextcord.Interaction) -> nextcord.
channels.append(await interaction.guild.fetch_channel(id)) # Fetches channel and adds it to channels list
except NotFound: # If channel has been deleted, remove it from the database list
remove_channel(interaction.guild_id, id)
embed.add_field(name="Channels added to list:", value=", ".join([i.mention for i in channels]), inline=False)
embed.add_field(name=f"Channels added to {get_channel_mode(interaction.guild_id)}:", value=", ".join([i.mention for i in channels]), inline=False)
embed.add_field(name="Role Mode:", value=get_role_mode(interaction.guild_id).capitalize())
roles: List[nextcord.Role] = []
for id in get_roles(interaction.guild_id): # Iterates through each role id in the database list
Expand All @@ -32,7 +32,7 @@ async def __generate_embed(self, interaction: nextcord.Interaction) -> nextcord.
roles.append(role) # Adds role to roles list
else: # If role not found remove it from the database list
remove_role(interaction.guild_id, id)
embed.add_field(name="Roles added to list:", value=", ".join([i.mention for i in roles]), inline=False)
embed.add_field(name=f"Roles added to {get_role_mode(interaction.guild_id)}:", value=", ".join([i.mention for i in roles]), inline=False)
embed.set_footer(text="Coded by @heroescreed")
embed.set_thumbnail(interaction.guild.icon.url if interaction.guild.icon else None) # Sets thumbnail to be guild icon, if it has one
return embed
Expand Down Expand Up @@ -66,25 +66,25 @@ async def toggle_channel_mode(self, button: nextcord.ui.Button, interaction: nex
@nextcord.ui.button(label="Add Channel", style=nextcord.ButtonStyle.green, row=1)
async def add_channel(self, button: nextcord.ui.Button, interaction: nextcord.Interaction) -> None:
channelview = ChannelSelect(interaction.user.id) # Create channel select view object
msg = await interaction.send(embed=nextcord.Embed(title="Select Channel", description="Select the channel you wish to add to the list", colour=COLOUR_MAIN), view=channelview, ephemeral=True)
msg = await interaction.send(embed=nextcord.Embed(title="Select Channel", description=f"Select the channel you wish to add to the {get_channel_mode(interaction.guild_id)}", colour=COLOUR_MAIN), view=channelview, ephemeral=True)
await channelview.wait() # Wait for a selection to be made
if not channelview.value.id in get_channels(interaction.guild_id): # If channel id isnt in database list then add it to the database
add_channel(interaction.guild_id, channelview.value.id)
await msg.edit(embed=create_success_embed(title="Success", description="Sucessfully added channel to the list"), view=None)
await msg.edit(embed=create_success_embed(title="Success", description=f"Sucessfully added channel to the {get_channel_mode(interaction.guild_id)}"), view=None)
else: # If channel id is in database list then tell the user and do nothing
await msg.edit(embed=create_warning_embed(title="Warning", description="Channel was already in the list, no changes have been made"), view=None)
await msg.edit(embed=create_warning_embed(title="Warning", description=f"Channel was already in the {get_channel_mode(interaction.guild_id)}, no changes have been made"), view=None)
await interaction.edit(embed=await self.__generate_embed(interaction)) # Regenerate options embed

@nextcord.ui.button(label="Remove Channel", style=nextcord.ButtonStyle.red, row=1)
async def remove_channel(self, button: nextcord.ui.Button, interaction: nextcord.Interaction) -> None:
channelview = ChannelSelect(interaction.user.id) # Create channel select view object
msg = await interaction.send(embed=nextcord.Embed(title="Select Channel", description="Select the channel you wish to remove from the list", colour=COLOUR_MAIN), view=channelview, ephemeral=True)
msg = await interaction.send(embed=nextcord.Embed(title="Select Channel", description=f"Select the channel you wish to remove from the {get_channel_mode(interaction.guild_id)}", colour=COLOUR_MAIN), view=channelview, ephemeral=True)
await channelview.wait() # Wait for a selection to be made
if channelview.value.id in get_channels(interaction.guild_id): # If channel id is in database list then remove it from the database
remove_channel(interaction.guild_id, channelview.value.id)
await msg.edit(embed=create_success_embed(title="Success", description="Sucessfully removed channel from the list"), view=None)
await msg.edit(embed=create_success_embed(title="Success", description=f"Sucessfully removed channel from the {get_channel_mode(interaction.guild_id)}"), view=None)
else: # If channel id isnt in database list then tell the user and do nothing
await msg.edit(embed=create_warning_embed(title="Warning", description="Channel was not in the list, no changes have been made"), view=None)
await msg.edit(embed=create_warning_embed(title="Warning", description=f"Channel was not in the {get_channel_mode(interaction.guild_id)}, no changes have been made"), view=None)
await interaction.edit(embed=await self.__generate_embed(interaction)) # Regenerate options embed

@nextcord.ui.button(label="Toggle Role Blacklist", style=nextcord.ButtonStyle.blurple, row=2)
Expand All @@ -103,23 +103,23 @@ async def toggle_role_mode(self, button: nextcord.ui.Button, interaction: nextco
@nextcord.ui.button(label="Add Role", style=nextcord.ButtonStyle.green, row=2)
async def add_role(self, button: nextcord.ui.Button, interaction: nextcord.Interaction) -> None:
roleview = Role_Select(interaction.user.id) # Create role select view object
msg = await interaction.send(embed=nextcord.Embed(title="Select role", description="Select the role you wish to add to the list", colour=COLOUR_MAIN), view=roleview, ephemeral=True)
msg = await interaction.send(embed=nextcord.Embed(title="Select role", description=f"Select the role you wish to add to the {get_role_mode(interaction.guild_id)}", colour=COLOUR_MAIN), view=roleview, ephemeral=True)
await roleview.wait() # Wait for a selection to be made
if not roleview.value.id in get_roles(interaction.guild_id): # If role id isnt in database list then add it to the database
add_role(interaction.guild_id, roleview.value.id)
await msg.edit(embed=create_success_embed(title="Success", description="Sucessfully added role to the list"), view=None)
await msg.edit(embed=create_success_embed(title="Success", description=f"Sucessfully added role to the {get_role_mode(interaction.guild_id)}"), view=None)
else: # If role id is in database list then tell the user and do nothing
await msg.edit(embed=create_warning_embed(title="Warning", description="Role was already in the list, no changes have been made"), view=None)
await msg.edit(embed=create_warning_embed(title="Warning", description=f"Role was already in the {get_role_mode(interaction.guild_id)}, no changes have been made"), view=None)
await interaction.edit(embed=await self.__generate_embed(interaction)) # Regenerate options embed

@nextcord.ui.button(label="Remove Role", style=nextcord.ButtonStyle.red, row=2)
async def remove_role(self, button: nextcord.ui.Button, interaction: nextcord.Interaction) -> None:
roleview = Role_Select(interaction.user.id) # Create role select view object
msg = await interaction.send(embed=nextcord.Embed(title="Select Role", description="Select the role you wish to remove from the list", colour=COLOUR_MAIN), view=roleview, ephemeral=True)
msg = await interaction.send(embed=nextcord.Embed(title="Select Role", description=f"Select the role you wish to remove from the {get_role_mode(interaction.guild_id)}", colour=COLOUR_MAIN), view=roleview, ephemeral=True)
await roleview.wait() # Wait for a selection to be made
if roleview.value.id in get_roles(interaction.guild_id): # If role id is in database list then remove it from the database
remove_role(interaction.guild_id, roleview.value.id)
await msg.edit(embed=create_success_embed(title="Success", description="Sucessfully removed role from the list"), view=None)
await msg.edit(embed=create_success_embed(title="Success", description=f"Sucessfully removed role from the {get_role_mode(interaction.guild_id)}"), view=None)
else: # If role id isnt in database list then tell the user and do nothing
await msg.edit(embed=create_warning_embed(title="Warning!", description="Role was not in the list, no changes have been made"), view=None)
await msg.edit(embed=create_warning_embed(title="Warning!", description=f"Role was not in the {get_role_mode(interaction.guild_id)}, no changes have been made"), view=None)
await interaction.edit(embed=await self.__generate_embed(interaction)) # Regenerate options embed

0 comments on commit 0ea1323

Please sign in to comment.