Skip to content
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
17 changes: 0 additions & 17 deletions .devcontainer/Dockerfile

This file was deleted.

63 changes: 0 additions & 63 deletions .devcontainer/devcontainer.json

This file was deleted.

3 changes: 1 addition & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
!/docker-compose.yml
!/Dockerfile
!/.dockerignore
!/poetry.lock
!/pyproject.toml
!/uv.lock
!/.env.example
!/run.sh
!/README.md
!/LICENSE.md

Expand Down
15 changes: 7 additions & 8 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,33 @@ on: workflow_dispatch

jobs:
build:

runs-on: ubuntu-latest
env:
repo_name: 'dysta/jukebot'
repo_name: "dysta/jukebot"

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v7

- name: Login to Docker Hub
uses: docker/login-action@v3
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v5
uses: docker/build-push-action@v7
with:
context: .
file: Dockerfile
push: true
tags: '${{ env.repo_name }}:latest'
tags: "${{ env.repo_name }}:latest"

- name: Update repo description
uses: peter-evans/dockerhub-description@v3
uses: peter-evans/dockerhub-description@v5
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: ${{ env.repo_name }}
short-description: Discord music bot written in Python 3
readme-filepath: ./README.md
readme-filepath: ./README.md
52 changes: 26 additions & 26 deletions .github/workflows/python-unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ name: JukeBot CI Full
on:
push:
branches:
- 'main'
- "main"
pull_request:
branches:
- '**'
- "**"

jobs:
unit-tests:
Expand All @@ -19,29 +19,29 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
python-version: ["3.12", "3.13", "3.14"]

steps:
- name: Checkout
uses: actions/checkout@v5

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

- name: Set up Poetry
uses: Gr1N/setup-poetry@v9

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
restore-keys: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}

- name: Install dependencies
run: poetry install --without dev

- name: Launch unit test
run: poetry run task tests
- name: Checkout
uses: actions/checkout@v7

- name: Install uv and set the Python version
uses: astral-sh/setup-uv@v9.0.0
with:
python-version: ${{ matrix.python-version }}
enable-cache: true

# - name: Cache dependencies
# uses: actions/cache@v6
# with:
# path: ~/.cache/uv/virtualenvs
# key: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }}
# restore-keys: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }}

- name: Install dependencies
run: uv sync --frozen --no-dev

- name: Launch unit test
run: uv run task tests
env:
CI: true
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
**/__pycache__

.env
.tools/

**/__pycache__
**/.mypy_cache

**/.ruff_cache
**/.idea

**/logs/*
.devcontainer/devcontainer-lock.json
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
11 changes: 2 additions & 9 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,10 @@
"configurations": [
{
"name": "Python: Module",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "jukebot",
"justMyCode": false
},
{
"name": "Python: Current File",
"type": "python",
"request": "test", // <----- this is for tests
"console": "integratedTerminal",
"justMyCode": false
}
}
]
}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"python.testing.pytestEnabled": false,
"python.testing.unittestEnabled": true,
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
"editor.defaultFormatter": "charliermarsh.ruff"
},
"python.formatting.provider": "none"
}
25 changes: 13 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
FROM debian AS deno-dl

RUN apt-get update && apt-get install -y curl unzip \
&& curl -fsSL https://deno.land/install.sh | sh

# syntax=docker/dockerfile:1.7
FROM python:3.12-slim

WORKDIR /app

COPY --from=deno-dl /root/.deno/bin/deno /usr/local/bin/deno
COPY --from=ghcr.io/astral-sh/uv:0.11 /uv /uvx /bin/
COPY --from=denoland/deno:bin-2.9.4 /deno /usr/local/bin/deno

ENV UV_COMPILE_BYTECODE=1 \
UV_LINK_MODE=copy

RUN apt-get update && \
apt-get install --no-install-recommends -y ffmpeg && \
apt-get clean && rm -rf /var/lib/apt/lists/*

RUN pip install --no-cache-dir -U poetry
COPY pyproject.toml uv.lock ./

COPY poetry.lock pyproject.toml ./

RUN poetry config virtualenvs.create false \
&& poetry install --no-root --no-interaction --no-ansi --compile --without dev -E speed
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --locked --no-dev --extra speed --no-install-project

COPY . ./

CMD ["/bin/sh", "run.sh"]
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --locked --no-dev --extra speed

CMD ["uv", "run", "--no-sync", "python", "-m", "jukebot"]
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
# JukeBot
[![Powered by Disnake](https://custom-icon-badges.herokuapp.com/badge/-Powered%20by%20Disnake-0d1620?logo=nextcord)](https://github.com/DisnakeDev/disnake "Powered by Disnake")
[![Powered by Poetry](https://custom-icon-badges.herokuapp.com/badge/-Powered%20by%20Poetry-0d1620?logo=poetry)](https://python-poetry.org "Powered by Poetry") \
[![Powered by Poetry](https://custom-icon-badges.herokuapp.com/badge/-Powered%20by%20uv-0d1620?logo=uv)](https://docs.astral.sh/uv/ "Powered by uv") \
Discord music bot written in Python 3
___

## 🧩 Deployment without Docker
```
git clone https://github.com/Dysta/JukeBot
cd JukeBot
poetry install
uv sync --locked
```

## ⚙ Configuration
Rename `.env.example` to `.env` and fill in the values.

## 🚀 Launch
Run `poetry run task start`.
Run `uv run task start`.

## ⁉ Other
The bot needs [ffmpeg](https://ffmpeg.org/) to work.
The bot needs [ffmpeg](https://ffmpeg.org/) and [ffprobe](https://ffmpeg.org/) to work.

### Install on Windows
Use the package manager [Chocolatey](https://community.chocolatey.org/) and run in an **admin shell** `choco install ffmpeg`.

Expand All @@ -36,9 +37,8 @@ Run `docker run --name jukebot --restart on-failure:3 --env-file .env dysta/juke

___

## 🔮 Devcontainer
Clone the project then open it in `vscode`. If you have the `devcontainer` extension, it will ask you to reopen the project in a devcontainer. If not, open the commands prompt then search for **reopen in container**. \
All the needs will be automatically installed.
## 🧰 Mise
Clone the project then in your terminal type `mise install` then `mise run install`. It will download both `ffmpeg` and `ffprobe` binary, add in the path and your good to go !

___

Expand Down
2 changes: 1 addition & 1 deletion jukebot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "0.1.0"
from .jukebot import JukeBot
from .jukebot import JukeBot as JukeBot
15 changes: 8 additions & 7 deletions jukebot/__main__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from __future__ import annotations

import asyncio
import logging as plogging
import os
import sys
from typing import List, Optional, Set

from disnake import Activity, ActivityType
from disnake.ext import commands
Expand All @@ -14,12 +13,12 @@
from jukebot.utils import Extensions, intents, logging


def get_owner_ids() -> Set[int]:
def get_owner_ids() -> set[int]:
ids = os.environ["BOT_OWNER_IDS"].split(",")
return set(map(int, ids))


def get_test_guilds_ids() -> Optional[List[int]]:
def get_test_guilds_ids() -> list[int] | None:
ids = list(filter(lambda x: x, os.environ["BOT_TEST_GUILD_IDS"].split(",")))
if not ids:
return None
Expand All @@ -35,7 +34,7 @@ def main():
)

bot = JukeBot(
activity=Activity(name=f"some good vibes 🎶", type=ActivityType.listening),
activity=Activity(name="some good vibes 🎶", type=ActivityType.listening),
intents=intents.get(),
owner_ids=get_owner_ids(),
test_guilds=get_test_guilds_ids(),
Expand All @@ -48,7 +47,7 @@ def main():
except commands.ExtensionNotFound as e:
logger.error(e)

logger.info(f"Starting bot...")
logger.info("Starting bot...")
bot.run(os.environ["BOT_TOKEN"])


Expand All @@ -57,6 +56,8 @@ def main():
import uvloop

uvloop.install()
asyncio.set_event_loop(uvloop.new_event_loop())
logger.opt(lazy=True).info("Bot launch with uvloop.")
except ImportError:
logger.opt(lazy=True).info("Bot launch without speed extra.")
logger.opt(lazy=True).info("Bot launch without uvloop.")
main()
Loading
Loading