Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shiba!!!!! #16

Merged
merged 1 commit into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions commands/shiba/random_shiba.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import discord
from ..modules.async_utils import _async_get_json


def register_commands(tree, this_guild: discord.Object):
@tree.command(
name="shiba",
description="Shiba",
guild=this_guild,
)
async def random_shiba(
interaction: discord.Interaction,
):
shiba_json = await _async_get_json(
"https://dog.ceo/api/breed/shiba/images/random"
)
if shiba_json is None or shiba_json["status"] != "success": # ):
return await interaction.response.send_message(
"Sorry, we couldn't find any dogs ):"
)
await interaction.response.send_message(shiba_json["message"])
8 changes: 6 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
from commands.edit_entry import edit_entry_cmd
from commands.one_o_one import one_o_one
from commands import hgs
from commands.shiba import random_shiba
import sys

# load environment vars (from .env)
load_dotenv()
prod = len(sys.argv) > 1 and sys.argv[1] == 'prod'
TOKEN = os.getenv('DISCORD_TOKEN_DEV' if not prod else 'DISCORD_TOKEN')
prod = len(sys.argv) > 1 and sys.argv[1] == "prod"
TOKEN = os.getenv("DISCORD_TOKEN_DEV" if not prod else "DISCORD_TOKEN")
GUILD = os.getenv("DISCORD_GUILD")

deployment_date = datetime.datetime.now()
Expand All @@ -43,6 +44,7 @@
async def test_slash_command(interaction: discord.Interaction):
await interaction.response.send_message("https://placetw.com/")


# * simple echo command with param explanation
@tree.command(
name="echo",
Expand All @@ -67,13 +69,15 @@ async def test_slash_command(interaction: discord.Interaction):
"""
await interaction.response.send_message(msg)


# * register commands from other files
fetch_entry_cmd.register_commands(tree, this_guild)
fetch_entry_ui.register_commands(tree, this_guild)
one_o_one.register_commands(tree, this_guild)
# edit_entry_modal.register_commands(tree, this_guild, client)
edit_entry_cmd.register_commands(tree, this_guild, client)
hgs.register_commands(tree, this_guild)
random_shiba.register_commands(tree, this_guild)


# sync the slash commands to server
Expand Down