Skip to content

Commit

Permalink
config cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
Selyss committed Nov 26, 2023
1 parent 90c9a8b commit fd07ae3
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,5 @@ cython_debug/


marlow-bot/

config.json
12 changes: 6 additions & 6 deletions cogs/inquiry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from nextcord.ext.commands import Bot, Cog
import nextcord

EMBED_COLOR = 0xff88ff
EMBED_COLOR = 0xFF88FF


class QuestionForm(nextcord.ui.Modal):
Expand All @@ -24,13 +24,10 @@ def __init__(self):
async def callback(self, interaction: nextcord.Interaction) -> None:
response = "Placeholder."
if self.details.value != "":
response += (
"response"
)
response += "response"
await interaction.send(response)



class Inquiry(Cog):
def __init__(self, bot: Bot) -> None:
self.bot = bot
Expand All @@ -52,12 +49,15 @@ async def deploy(self, ctx) -> None:
async def btn_callback(interaction):
await interaction.response.send_modal(QuestionForm())

btn = nextcord.ui.Button(label="📝 Open Inquiry", style=nextcord.ButtonStyle.blurple)
btn = nextcord.ui.Button(
label="📝 Open Inquiry", style=nextcord.ButtonStyle.blurple
)
btn.callback = btn_callback
view = nextcord.ui.View()
view.add_item(btn)

await ctx.channel.send(embed=em, view=view)


def setup(bot: Bot) -> None:
bot.add_cog(Inquiry(bot))
31 changes: 31 additions & 0 deletions cogs/ticket.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from nextcord import SlashOption, TextChannel, slash_command
from nextcord.ext.commands import Bot, Cog
import nextcord
import json

with open("config.json", "r") as config_file:
config = json.load(config_file)


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,
channel: TextChannel = SlashOption(
description="channel to recieve requests",
required=True,
),
):
config["request_channel"] = channel.id
with open("config.json", "w") as config_file:
json.dump(config, config_file, indent=4)

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


def setup(bot: Bot) -> None:
bot.add_cog(Ticket(bot))
4 changes: 3 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
load_dotenv()

TOKEN = os.getenv("BOT")
EMBED_COLOR = 0xfffe88ff
EMBED_COLOR = 0xFFFE88FF

intents = nextcord.Intents.default()
intents.message_content = True

print("[System] Beginning load...")
bot = Bot(command_prefix="!", intents=intents)
bot.load_extension("cogs.inquiry")
bot.load_extension("cogs.ticket")


@bot.event
async def on_ready():
Expand Down

0 comments on commit fd07ae3

Please sign in to comment.