Skip to content

Commit

Permalink
Handle errors when fetching channel (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghostopheles authored Nov 4, 2023
2 parents 31833cb + 4ae5e5a commit 0bf3acd
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 26 deletions.
23 changes: 1 addition & 22 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,6 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
uses: sigstore/cosign-installer@9becc617647dfa20ae7b1151972e9b3a2c338a2b
with:
cosign-release: 'v1.13.1'

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

Expand Down Expand Up @@ -86,19 +79,5 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
platforms: linux/arm/v7
secrets: DEBUG=False


# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
COSIGN_EXPERIMENTAL: "true"
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1.4

FROM --platform=$TARGETPLATFORM python:latest
FROM --platform=$TARGETPLATFORM python:3.11.6

WORKDIR /usr/algalon

Expand Down
23 changes: 21 additions & 2 deletions cogs/watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,31 @@ async def distribute_embed(self, first_run: bool = False):
continue

for embed in embeds:
channel = await guild.fetch_channel(embed["target"])
try:
channel = await guild.fetch_channel(embed["target"])
except discord.NotFound:
logger.error(f"Chosen channel not found for guild {guild}")
continue
except discord.Forbidden:
logger.error(
f"No permission to access chosen channel for guild {guild}"
)
continue

actual_embed = embed["embed"] # god save me

if actual_embed and channel:
logger.info("Sending CDN update post and tweet...")
message = await channel.send(embed=actual_embed) # type: ignore
try:
message = await channel.send(embed=actual_embed) # type: ignore
except discord.NotFound:
logger.error(f"Chosen channel not found for guild {guild}")
continue
except discord.Forbidden:
logger.error(
f"No permission to post to chosen channel for guild {guild}"
)
continue

if channel.id == int(os.getenv("ANNOUNCEMENT_CHANNEL")):
await message.publish()
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
py-cord
py-cord[speed]
httpx
tweepy[async]

0 comments on commit 0bf3acd

Please sign in to comment.