> ## Documentation Index
> Fetch the complete documentation index at: https://blog.cytric.nl/llms.txt
> Use this file to discover all available pages before exploring further.

# Discord.py Template

> A starter template for hosting Discord.py bots on Cytric.nl

# Discord.py Bot Template

This page provides a starter template for building and hosting Discord.py bots on Cytric.nl. You can use this template to quickly set up your bot and deploy it to GitHub and Cytric.

## Features

* Python 3.8+
* Discord.py library
* Ready for deployment to Cytric
* Example GitHub Actions workflow

## Example Bot Code

```python theme={null}
import discord
from discord.ext import commands
import os

intents = discord.Intents.default()
bot = commands.Bot(command_prefix="!", intents=intents)

@bot.event
async def on_ready():
    print(f"Logged in as {bot.user}")

@bot.command()
async def ping(ctx):
    await ctx.send("Pong!")

bot.run(os.getenv("DISCORD_TOKEN"))
```

## Deploy to GitHub

Use our official template: [Cytric-Bot-Template-PY](https://github.com/Cytric/Cytric-Bot-Template-PY)

1. Fork or clone the template repository.
2. Add your bot token as a GitHub secret named `DISCORD_TOKEN`.
3. Push your code changes to GitHub.

## Example GitHub Actions Workflow

Create `.github/workflows/deploy.yml`:

```yaml theme={null}
name: Deploy Discord.py Bot
on:
  push:
    branches: [main]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: "3.8"
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install discord.py
      - name: Run bot
        env:
          DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
        run: |
          python bot.py
```

## Resources

* [discord.py Documentation](https://discordpy.readthedocs.io/en/stable/)
* [Cytric Python Hosting](https://Cytric.nl)
