Skip to content

Commit

Permalink
refractor: basic commands
Browse files Browse the repository at this point in the history
  • Loading branch information
howardt12345 committed Nov 3, 2023
1 parent a690e32 commit b79fb58
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 20 deletions.
38 changes: 38 additions & 0 deletions commands/basic/basic_commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

from discord import app_commands

import discord

def register_commands(
tree: discord.app_commands.CommandTree,
guilds_dict: dict,
):
guilds = [ # TW and Baltics server
discord.Object(id=int(server_id))
for server_id in guilds_dict.keys()
]
@tree.command(
name="website",
description="Responds with the placeTW website link",
guilds=guilds,
)
async def website(interaction: discord.Interaction):
await interaction.response.send_message("https://placetw.com/")


@tree.command(
name="invite",
description="Invite this bot to your server!",
guilds=guilds,
)
async def invite_link(interaction: discord.Interaction):
await interaction.response.send_message("https://discord.com/oauth2/authorize?client_id=1134650883637006407&&permissions=2147484672&scope=bot")

@tree.command(
name="echo",
description="Echoes whatever string is fed",
guilds=guilds,
)
@app_commands.describe(given_str="The string you want echoed backed")
async def echo(interaction: discord.Interaction, given_str: str):
await interaction.response.send_message(f"You sent this: `{given_str}`")
23 changes: 3 additions & 20 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import datetime

# user commands
from commands.basic import basic_commands
from commands.fetch_entry import fetch_entry_cmd
from commands.fetch_entry import fetch_entry_ui
from commands.edit_entry import edit_entry_cmd
Expand Down Expand Up @@ -51,31 +52,12 @@
) # basically refers to this server


@tree.command(
name="website",
description="Responds with the placeTW website link",
guild=placetw_guild,
)
async def test_slash_command(interaction: discord.Interaction):
await interaction.response.send_message("https://placetw.com/")


@tree.command(
name="echo",
description="Echoes whatever string is fed",
guild=placetw_guild,
)
@app_commands.describe(given_str="The string you want echoed backed")
async def test_slash_command(interaction: discord.Interaction, given_str: str):
await interaction.response.send_message(f"You sent this: `{given_str}`")


@tree.command(
name="deployment-info",
description="Returns information about the bot deployment",
guild=placetw_guild,
)
async def test_slash_command(interaction: discord.Interaction):
async def deployment_info(interaction: discord.Interaction):
msg = f"""
PlaceTW discord bot ({'prod' if prod else 'dev'} deployment)
Branch deployed: `{Repo().active_branch.name}`
Expand All @@ -90,6 +72,7 @@ async def test_slash_command(interaction: discord.Interaction):
edit_entry_cmd.register_commands(tree, placetw_guild, client)
restart.register_commands(tree, placetw_guild)
watching.register_commands(tree, placetw_guild, client)
basic_commands.register_commands(tree, GUILDS_DICT)

# * register commands to the other servers

Expand Down

0 comments on commit b79fb58

Please sign in to comment.