Skip to content

Commit

Permalink
Fixed some things in /bump and made the bot handle non-admin discord …
Browse files Browse the repository at this point in the history
…permissions
  • Loading branch information
QWERTZexe committed Aug 23, 2024
1 parent c526ae3 commit d080602
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
11 changes: 8 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,22 @@ async def bump(interaction: discord.Interaction):
if "TICKET" not in interaction.channel.topic:
await interaction.response.send_message(embed=discord.Embed(description="This command can only be used in ticket channels.", color=discord.Color.red()), ephemeral=True)
return
await interaction.response.defer(thinking=True)

if get(interaction.user.roles, id=MOD_ROLE_ID) or interaction.user.id == 971316880243576862 or interaction.user.guild_permissions.administrator:
await interaction.response.defer(thinking=True,ephemeral=True)
try:
member = interaction.channel.topic.split("-")[1]
em = discord.Embed(title="Are you still here?",
description="We have received no feedback from your side recently", color=discord.Color.yellow())
await interaction.channel.send(f"Hello <@{member}> :wave:", embed=em)
err = 0
except:
pass
await interaction.followup.send(f"Successfully bumped the ticket!", ephemeral=True)
err = 1
await interaction.channel.send(f"Hello <@{member}> :wave:", embed=em)
if err == 0:
await interaction.followup.send(f"Successfully bumped the ticket!", ephemeral=True)
else:
await interaction.followup.send(f"**__ERROR__** bumping the ticket!", ephemeral=True)
else:
await interaction.followup.send(f"Sorry, this command is only for staff!", ephemeral=True)

Expand Down
6 changes: 4 additions & 2 deletions utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ async def create_partner_ticket(client: discord.Client, username: str, servernam
# Allow the ticket creator to see and write in the channel
member = await guild.fetch_member(memberid)
await channel.set_permissions(member, read_messages=True, send_messages=True)
# Allow the bot too
await channel.set_permissions(guild.get_member(client.user.id), read_messages=True, send_messages=True)

# Allow users with the mod role to see and write in the channel
mod_role = guild.get_role(MOD_ROLE_ID)
Expand Down Expand Up @@ -333,11 +335,11 @@ async def create_ticket(client: discord.Client, username: str, memberid: int, re
await channel.edit(topic=f"TICKET-{str(memberid)}")
# Set up permissions
await channel.set_permissions(guild.default_role, read_messages=False, send_messages=False)

# Allow the ticket creator to see and write in the channel
member = await guild.fetch_member(memberid)
await channel.set_permissions(member, read_messages=True, send_messages=True)

# Allow the bot too
await channel.set_permissions(await guild.fetch_member(client.user.id), read_messages=True, send_messages=True)
# Allow users with the mod role to see and write in the channel
mod_role = guild.get_role(MOD_ROLE_ID)
await channel.set_permissions(mod_role, read_messages=True, send_messages=True)
Expand Down

0 comments on commit d080602

Please sign in to comment.