Skip to content

Commit

Permalink
fix bug in channel, remove config cmds
Browse files Browse the repository at this point in the history
  • Loading branch information
Selyss committed Dec 17, 2023
1 parent 16622f3 commit a703866
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 35 deletions.
2 changes: 0 additions & 2 deletions cogs/inquiry.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,7 @@ def __init__(self) -> None:

async def callback(self, inter: nextcord.Interaction) -> None:
if isinstance(inter.channel, nextcord.TextChannel):
print(AD_CHANNEL)
target_channel = inter.guild.get_channel(AD_CHANNEL)
print(target_channel)
em = nextcord.Embed()
em.title = "Advertisement"
em.set_author(icon_url=inter.user.avatar, name=inter.user.name)
Expand Down
38 changes: 5 additions & 33 deletions cogs/ticket.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import json
from os import getenv
from nextcord import SlashOption, TextChannel, slash_command
from nextcord.ext.commands import Bot, Cog
import nextcord

CLOSED_CATEGORY = 1182473403303723128

with open("config.json", "r", encoding="utf-8") as conf:
config = json.load(conf)
CLOSED_CATEGORY = int(getenv("CLOSED_CATEGORY"))


class CloseRequest(nextcord.ui.View):
Expand Down Expand Up @@ -35,43 +32,18 @@ def __init__(self, inter: nextcord.Interaction):

@nextcord.ui.button(label="Acknowledge", style=nextcord.ButtonStyle.blurple)
async def accept(self, button: nextcord.ui.Button, inter: nextcord.Interaction):
category = nextcord.utils.get(inter.guild.categories, id=CLOSED_CATEGORY)
await self.inter.channel.send("Closing ticket...")
await self.inter.channel.edit(category=CLOSED_CATEGORY)
await self.inter.channel.edit(category=category)
await self.inter.channel.set_permissions(
self.inter.author, read_messages=False, send_messages=False
self.inter.user, read_messages=False, send_messages=False
)


class Ticket(Cog):
def __init__(self, bot: Bot) -> None:
self.bot = bot

@slash_command(name="config", description="set bot config")
async def set_log_channel(
self,
inter: nextcord.Interaction,
request_channel: TextChannel = SlashOption(
description="channel to recieve requests",
required=False,
),
ad_channel: TextChannel = SlashOption(
description="channel to recieve advertisements",
required=False,
),
):
config["request_channel"] = request_channel.id
config["advertise_channel"] = ad_channel.id
with open("config.json", "w", encoding="utf-8") as config_file:
json.dump(config, config_file, indent=4)

await inter.send(
f"""
Request channel set to <#{request_channel.id}>
Advertisement channel set to <#{ad_channel.id}>
""",
ephemeral=True,
)

@slash_command(name="close", description="close a ticket")
async def close_ticket(self, inter: nextcord.Interaction):
if inter.channel.category_id == CLOSED_CATEGORY:
Expand Down

0 comments on commit a703866

Please sign in to comment.