Skip to content

Commit

Permalink
Suggestme V3 - permissions update + embed editting
Browse files Browse the repository at this point in the history
  • Loading branch information
nottherealtar authored Apr 12, 2024
1 parent 3930348 commit 95c1cfd
Showing 1 changed file with 57 additions and 46 deletions.
103 changes: 57 additions & 46 deletions suggestme/suggestme.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,60 +17,71 @@ def __init__(self, bot):
self.suggestion_count = 0

@commands.command()
async def suggestme(self, ctx, *, suggestion: str):
"""
Lets members with the Verified role to suggest features for the server and these suggestions get posted in a suggestions channel for the staff to review and for the server to vote for.
"""
# Check if the user has the Verified role
verified_role = utils.get(ctx.guild.roles, name="Verified")
if verified_role is None:
await ctx.send("The Verified role does not exist.")
return
async def suggestme(self, ctx, *, suggestion: str):
"""
Lets members with the Verified role to suggest features for the server and these suggestions get posted in a suggestions channel for the staff to review and for the server to vote for.
"""
# Check if the command is used in the 'suggestme' channel
if ctx.channel.name != 'suggestme':
await ctx.send("Please use this command in the 'suggestme' channel.")
return

if verified_role in ctx.author.roles:
# Increment the suggestion count
self.suggestion_count += 1
# Check if the user has the Verified role
verified_role = utils.get(ctx.guild.roles, name="Verified")
if verified_role is None:
await ctx.send("The Verified role does not exist.")
return

# Get the current timestamp
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
if verified_role in ctx.author.roles:
# Increment the suggestion count
self.suggestion_count += 1

# Create an embed with the suggestion
embed = Embed(title=f"Suggestion #{self.suggestion_count} has been added by {ctx.author.name}", description=f'"{suggestion}" - {timestamp}', color=0x800080)
embed.set_thumbnail(url='https://cdn.discordapp.com/attachments/1170989523895865424/1228294937288769567/360_F_528295970_32SSCHm39wg6hufvVjxEpSxAzU5cew29-removebg-preview.png?ex=662b85cd&is=661910cd&hm=c6c99cd66b7510d2806fcc3dcec59c64a3642b5223ebcad45fb54eda903e9117&')
# Get the current timestamp
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")

# Send the suggestion to the context channel
message = await ctx.send(embed=embed)
# Create an embed with the suggestion
embed = Embed(title=f"Suggestion #{self.suggestion_count} by {ctx.author.name}", description=suggestion, color=0x800080)
embed.set_thumbnail(url='https://cdn.discordapp.com/attachments/1170989523895865424/1228294937288769567/360_F_528295970_32SSCHm39wg6hufvVjxEpSxAzU5cew29-removebg-preview.png?ex=662b85cd&is=661910cd&hm=c6c99cd66b7510d2806fcc3dcec59c64a3642b5223ebcad45fb54eda903e9117&')
embed.set_footer(text=f"Suggested on {timestamp}")

# Add reactions for voting, verifying, and deleting
await message.add_reaction("👍")
await message.add_reaction("👎")
await message.add_reaction("✅")
await message.add_reaction("❌")
# Send the suggestion to the context channel
message = await ctx.send(embed=embed)

await ctx.send("Your suggestion has been posted.")
else:
await ctx.send("You must have the Verified role to suggest features.")
# Add reactions for voting, verifying, and deleting
await message.add_reaction("👍")
await message.add_reaction("👎")
await message.add_reaction("✅")
await message.add_reaction("❌")

# Delete the command message to avoid clutter
await ctx.message.delete()
else:
await ctx.send("You must have the Verified role to suggest features.")

@commands.Cog.listener()
async def on_reaction_add(self, reaction, user):
# Check if the reaction is on a suggestion and the user is a staff member
staff_role = utils.get(user.guild.roles, name="Staff")
if staff_role is None:
await user.send("The Staff role does not exist.")
return
async def on_reaction_add(self, reaction, user):
# Check if the reaction is on a suggestion and the user is a staff member
staff_role = utils.get(user.guild.roles, name="Staff")
if staff_role is None:
await user.send("The Staff role does not exist.")
return

# Check if the reaction is added in the 'suggestme' channel
if reaction.message.channel.name != 'suggestme':
return

if reaction.message.embeds and "Suggestion #" in reaction.message.embeds[0].title and staff_role in user.roles:
if str(reaction.emoji) == "✅":
# Get the suggestions channel
suggestions_channel = utils.get(reaction.message.guild.channels, name="suggestions")
if suggestions_channel is None:
await user.send("The suggestions channel does not exist.")
return
if reaction.message.embeds and "Suggestion #" in reaction.message.embeds[0].title and staff_role in user.roles:
if str(reaction.emoji) == "✅":
# Get the suggestions channel
suggestions_channel = utils.get(reaction.message.guild.channels, name="suggestions")
if suggestions_channel is None:
await user.send("The suggestions channel does not exist.")
return

# Publish the suggestion to the suggestions channel
await suggestions_channel.send(embed=reaction.message.embeds[0])
await reaction.message.delete()
# Publish the suggestion to the suggestions channel
await suggestions_channel.send(embed=reaction.message.embeds[0])
await reaction.message.delete()

elif str(reaction.emoji) == "❌":
# Delete the suggestion
await reaction.message.delete()
elif str(reaction.emoji) == "❌":
# Delete the suggestion
await reaction.message.delete()

0 comments on commit 95c1cfd

Please sign in to comment.