Skip to content

Commit

Permalink
Merge pull request #166 from MiscGuild/bugfix
Browse files Browse the repository at this point in the history
Bugfix
  • Loading branch information
Amxgh authored Mar 1, 2024
2 parents 95f5166 + 27433da commit b6cee9e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
7 changes: 3 additions & 4 deletions src/cogs/staff.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from __main__ import bot

import discord
from discord.ext import commands, bridge
from discord.commands import option
from discord.ext import commands, bridge

from src.func.General import General
from src.func.Union import Union
Expand All @@ -26,7 +26,7 @@ async def inactive(self, ctx):
await ctx.respond(embed=embed)

@bridge.bridge_command(aliases=["fs"])
@commands.has_role("Staff")
@commands.has_any_role("Staff", "Discord Moderator")
@option(
name="member",
description="The Discord member who you would like to forcesync",
Expand Down Expand Up @@ -68,7 +68,7 @@ async def information(self, ctx):
await ctx.respond(embed=information_embed)

@bridge.bridge_command()
@commands.has_role("Staff")
@commands.has_any_role("Staff", "Discord Moderator")
@option(
name="send_ping",
description="Enter 'False' if you don't want to ping New Members upon completion of rolecheck",
Expand All @@ -80,6 +80,5 @@ async def rolecheck(self, ctx, send_ping: bool = True):
await General.rolecheck(ctx, send_ping)



def setup(bot):
bot.add_cog(Staff(bot))
22 changes: 11 additions & 11 deletions src/cogs/tickets.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import discord
from discord.ext import commands, bridge
from discord.commands import option
from discord.ext import commands, bridge

from src.utils.consts import milestone_categories
from src.func.General import General
from src.func.Listener import Listener
from src.func.String import String
from src.func.Union import Union
from src.utils.consts import milestone_categories


class Tickets(commands.Cog, name="tickets"):
Expand Down Expand Up @@ -35,15 +35,15 @@ async def register(self, ctx, name: str):
await ctx.respond(res)

@bridge.bridge_command(aliases=["del"])
@commands.has_role("Staff")
@commands.has_any_role("Staff", "Discord Moderator")
async def delete(self, ctx):
"""Delete a ticket!"""
res = await General.delete(ctx)
if res:
await ctx.respond(res)

@bridge.bridge_command()
@commands.has_role("Staff")
@commands.has_any_role("Staff", "Discord Moderator")
@option(
name="member",
description="The Discord user you would like to add to the ticket",
Expand All @@ -59,7 +59,7 @@ async def add(self, ctx, member: discord.Member):
await ctx.respond(embed=res)

@bridge.bridge_command()
@commands.has_role("Staff")
@commands.has_any_role("Staff", "Discord Moderator")
@option(
name="member",
description="The Discord user you would like to remove from the ticket",
Expand All @@ -75,7 +75,7 @@ async def remove(self, ctx, member: discord.Member):
await ctx.respond(embed=res)

@bridge.bridge_command()
@commands.has_role("Staff")
@commands.has_any_role("Staff", "Discord Moderator")
@option(
name="channel_name",
description="The new name for the channel",
Expand All @@ -87,7 +87,7 @@ async def rename(self, ctx, *, channel_name: str):
await ctx.respond(embed=await String(string=channel_name).rename(ctx))

@bridge.bridge_command()
@commands.has_role("Staff")
@commands.has_any_role("Staff", "Discord Moderator")
async def transcript(self, ctx):
"""Create a transcript for a ticket!"""
res = await General.transcript(ctx)
Expand Down Expand Up @@ -130,11 +130,11 @@ async def new(self, ctx):
await ctx.respond(await General.new(ctx))

@bridge.bridge_command(aliases=['AddMilestone'])
@commands.has_role('Staff')
@commands.has_any_role("Staff", "Discord Moderator")
@option(
name="gamemode",
description="The gamemode in which the milestone was achieved",
choices= [discord.OptionChoice(v, value=k) for k,v in milestone_categories.items()],
choices=[discord.OptionChoice(v, value=k) for k, v in milestone_categories.items()],
required=False
)
async def milestoneadd(self, ctx, gamemode: str = None, *, milestone: str = None):
Expand All @@ -143,14 +143,14 @@ async def milestoneadd(self, ctx, gamemode: str = None, *, milestone: str = None
await ctx.respond(embed=embed, view=view)

@bridge.bridge_command(aliases=['UpdateMilestone'])
@commands.has_role('Staff')
@commands.has_any_role("Staff", "Discord Moderator")
async def milestoneupdate(self, ctx):
"""Update a milestone that has already been registered"""
embed, view = await General.update_milestone(ctx)
await ctx.respond(embed=embed, view=view)

@bridge.bridge_command(aliases=["CompileMilestones", "mc", "cm", "CompileMilestone"])
@commands.has_role('Staff')
@commands.has_any_role("Staff", "Discord Moderator")
async def milestonecompile(self, ctx):
"""Compiles all milestones into one message and sends it to the milestones channel"""
await ctx.respond(await General.compile_milestones(ctx))
Expand Down
6 changes: 4 additions & 2 deletions src/func/Listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,11 @@ async def on_interaction(self):
if "custom_id" not in self.obj.data:
pass
elif self.obj.data["custom_id"] == "tickets":
await self.obj.response.send_message("Creating your ticket...", ephemeral=True)
ticket = await create_ticket(self.obj.user, f"ticket-{self.obj.user.name}")
await self.obj.response.send_message(f"Click the following link to go to your ticket! <#{ticket.id}>",
ephemeral=True)

await self.obj.edit_original_response(
content=f"Ticket created!\n**Click the link below to view your ticket.**\n<#{ticket.id}>")

# Reaction roles
elif self.obj.data["custom_id"] in reaction_roles.keys():
Expand Down
5 changes: 5 additions & 0 deletions src/utils/discord_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ async def create_ticket(user: discord.Member, ticket_name: str, category_name: s
# Set perms
await ticket.set_permissions(bot.guild.get_role(bot.guild.id), send_messages=False,
read_messages=False)
await ticket.set_permissions(bot.discord_mod, send_messages=True, read_messages=True,
add_reactions=True, embed_links=True,
attach_files=True,
read_message_history=True, external_emojis=True)
await ticket.set_permissions(bot.staff, send_messages=True, read_messages=True,
add_reactions=True, embed_links=True,
attach_files=True,
Expand Down Expand Up @@ -145,6 +149,7 @@ async def after_cache_ready():
bot.admin = discord.utils.get(bot.guild.roles, name="Admin")
bot.staff = discord.utils.get(bot.guild.roles, name="Staff")
bot.helper = discord.utils.get(bot.guild.roles, name="Helper")
bot.discord_mod = discord.utils.get(bot.guild.roles, name="Discord Moderator")
bot.former_staff = discord.utils.get(bot.guild.roles, name="Former Staff")
bot.new_member_role = discord.utils.get(bot.guild.roles, name="New Member")
bot.processing = discord.utils.get(bot.guild.roles, name="Processing")
Expand Down

0 comments on commit b6cee9e

Please sign in to comment.