Skip to content

Commit

Permalink
Merge pull request #213 from alexraskin/cat-fact-favicon-fix-gh-update
Browse files Browse the repository at this point in the history
✨ Refactor: Update bot commands for fetching cat facts.
  • Loading branch information
alexraskin authored May 22, 2024
2 parents 63aee42 + f2a0a56 commit 61eab62
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 49 deletions.
16 changes: 0 additions & 16 deletions .dockerignore

This file was deleted.

16 changes: 0 additions & 16 deletions .zed/settings.json

This file was deleted.

12 changes: 1 addition & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,16 @@ If you follow LhCloudy on twitch, you will know, that he will not share what Lh

## Deploy

This bot is completely managed by terraform and is deployed on [Railway](https://railway.app/). If you are wanting to deploy this bot, you can do so by following the instructions below.

A few things you will need:

- Discord bot
- Mongo database (I use atlas)
- A Railway account
- Amazon S3 Bucket

Take a look in the [`/example-files`](https://github.com/alexraskin/lhbot/tree/main/example-files) folder for examples of the files you will need to create.

## Deploying the bot to Railway via Terraform

1. Clone the repository
2. Change `dir` to `infrastructure/terraform/bot`
3. Create a `terraform.tfvars` The bot will look for all these environment variables [in this file](hhttps://github.com/alexraskin/lhbot/blob/main/infrastructure/terraform/bot/shared-envs.tf)
4. Run `terraform init`
5. Run `terraform apply`

___

## Run the bot locally

To run the bot locally, you will need to fill in the `.env` file all the values that are missing.
Expand Down
15 changes: 15 additions & 0 deletions bot/cogs/fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,21 @@ async def cat(self, ctx: commands.Context):
return
else:
await ctx.send(f"{cat_url}/cat/{data['_id']}")

@commands.hybrid_command(name="catfact", with_app_command=True)
@commands.guild_only()
@app_commands.guild_only()
async def cat_fact(self, ctx: commands.Context):
"""
Get a random cat fact from catfact.ninja
"""
response = await self.client.session.get("https://catfact.ninja/fact")
data = await response.json()
if response.status != 200:
await ctx.send("Could not find a cat fact!")
return
else:
await ctx.send(data["fact"])

@commands.hybrid_command(
name="dog", aliases=["dogpic", "doggo"], with_app_command=True
Expand Down
2 changes: 1 addition & 1 deletion bot/cogs/lhguess.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ async def lhdelete(self, ctx: commands.Context, guess_id: int):
if ctx.guild.id != self.client.config.main_guild:
await ctx.send("This command can only be used in Cloudy's Discord.")
return
guess = await self.collection.find_one({"_id": ObjectId(guess_id)}) # type: ignore
guess = await self.collection.find_one({"_id": ObjectId(guess_id)})

if not guess:
raise commands.BadArgument("Could not find a guess with that ID!")
Expand Down
Binary file removed bot/cogs/static/images/favicon.ico
Binary file not shown.
5 changes: 0 additions & 5 deletions example-files/example.env
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ superusers=
admin_roles=
GIPHY_API_KEY=
BOT_NAME=
AWS_ACCESS_KEY=
AWS_SECRET_ACCESS_KEY=
AWS_REGION=
S3_BUCKET_NAME=
DOCKER_ENABLED=
TWITCH_CLIENT_ID=
TWITCH_CLIENT_SECRET=
GITHUB_PAT=
Expand Down

0 comments on commit 61eab62

Please sign in to comment.