Skip to content

Commit 721cc6f

Browse files
committed
Release version 4.0.1
2 parents e8cbdcd + bf67b53 commit 721cc6f

File tree

13 files changed

+415
-46
lines changed

13 files changed

+415
-46
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ cython_debug/
147147
.project
148148
/gallery-dl
149149
.ruff_cache
150+
compose-dev.yaml
150151

151152
# Docker Extras
152153
Dockerfile

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Rename this file to .env
2-
DISCORD_TOKEN=<YOUR_TOKEN_HERE>
2+
DISCORD_TOKEN=<Your token here>
33

44
# Used by old style prefix commands; this bot only has `sync` prefix command
55
PREFIX=>>

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,4 @@ cython_debug/
147147
.project
148148
/gallery-dl
149149
.ruff_cache
150+
compose-dev.yaml

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,17 @@ plugins:
2929
enabled: true
3030
clients: ["MUSIC", "WEB", "MWEB", "WEBEMBEDDED", "ANDROID_MUSIC", "ANDROID_VR", "TV", "TVHTML5EMBEDDED"]
3131
oauth:
32+
# See https://github.com/lavalink-devs/youtube-source?tab=readme-ov-file#using-oauth-tokens for more info
3233
enabled: true
33-
refreshToken: <Redacted>
34+
refreshToken: <Use your own oauth token here>
3435
lavalink:
3536
plugins:
3637
# See https://github.com/lavalink-devs/youtube-source for the latest version of the plugin
3738
- dependency: "dev.lavalink.youtube:youtube-plugin:1.11.4"
3839
server:
3940
password: "youshallnotpass"
4041
sources:
41-
youtube: fals
42+
youtube: false
4243
```
4344
4445
6. To use the AI chat command, set `OPENAI_API_KEY` and `OPENAI_MODEL_NAME` in `.env`.
@@ -63,7 +64,6 @@ Note: The `latest` tag refers to the latest stable version.
6364
- [ ] AI.draw: Add [stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui) support
6465
- [ ] Allow passing arguments to FFMPEG (for hardware acceleration)
6566
- [ ] Allow bot owner to run every command (including admin only commands)
66-
- [ ] Setup migration with alembic
6767

6868
## Notable commands
6969

alembic.ini

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# A generic, single database configuration.
2+
3+
[alembic]
4+
# path to migration scripts
5+
# Use forward slashes (/) also on windows to provide an os agnostic path
6+
script_location = migrations
7+
8+
# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s
9+
# Uncomment the line below if you want the files to be prepended with date and time
10+
# see https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file
11+
# for all available tokens
12+
# file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s
13+
14+
# sys.path path, will be prepended to sys.path if present.
15+
# defaults to the current working directory.
16+
prepend_sys_path = .
17+
18+
# timezone to use when rendering the date within the migration file
19+
# as well as the filename.
20+
# If specified, requires the python>=3.9 or backports.zoneinfo library and tzdata library.
21+
# Any required deps can installed by adding `alembic[tz]` to the pip requirements
22+
# string value is passed to ZoneInfo()
23+
# leave blank for localtime
24+
# timezone =
25+
26+
# max length of characters to apply to the "slug" field
27+
# truncate_slug_length = 40
28+
29+
# set to 'true' to run the environment during
30+
# the 'revision' command, regardless of autogenerate
31+
# revision_environment = false
32+
33+
# set to 'true' to allow .pyc and .pyo files without
34+
# a source .py file to be detected as revisions in the
35+
# versions/ directory
36+
# sourceless = false
37+
38+
# version location specification; This defaults
39+
# to migrations/versions. When using multiple version
40+
# directories, initial revisions must be specified with --version-path.
41+
# The path separator used here should be the separator specified by "version_path_separator" below.
42+
# version_locations = %(here)s/bar:%(here)s/bat:migrations/versions
43+
44+
# version path separator; As mentioned above, this is the character used to split
45+
# version_locations. The default within new alembic.ini files is "os", which uses os.pathsep.
46+
# If this key is omitted entirely, it falls back to the legacy behavior of splitting on spaces and/or commas.
47+
# Valid values for version_path_separator are:
48+
#
49+
# version_path_separator = :
50+
# version_path_separator = ;
51+
# version_path_separator = space
52+
# version_path_separator = newline
53+
#
54+
# Use os.pathsep. Default configuration used for new projects.
55+
version_path_separator = os
56+
57+
# set to 'true' to search source files recursively
58+
# in each "version_locations" directory
59+
# new in Alembic version 1.10
60+
# recursive_version_locations = false
61+
62+
# the output encoding used when revision files
63+
# are written from script.py.mako
64+
# output_encoding = utf-8
65+
66+
sqlalchemy.url = sqlite:///volume/db.sqlite3
67+
68+
69+
[post_write_hooks]
70+
# post_write_hooks defines scripts or Python functions that are run
71+
# on newly generated revision scripts. See the documentation for further
72+
# detail and examples
73+
74+
# format using "black" - use the console_scripts runner, against the "black" entrypoint
75+
# hooks = black
76+
# black.type = console_scripts
77+
# black.entrypoint = black
78+
# black.options = -l 79 REVISION_SCRIPT_FILENAME
79+
80+
# lint with attempts to fix using "ruff" - use the exec runner, execute a binary
81+
# hooks = ruff
82+
# ruff.type = exec
83+
# ruff.executable = %(here)s/.venv/bin/ruff
84+
# ruff.options = --fix REVISION_SCRIPT_FILENAME
85+
86+
# Logging configuration
87+
[loggers]
88+
keys = root,sqlalchemy,alembic
89+
90+
[handlers]
91+
keys = console
92+
93+
[formatters]
94+
keys = generic
95+
96+
[logger_root]
97+
level = WARNING
98+
handlers = console
99+
qualname =
100+
101+
[logger_sqlalchemy]
102+
level = WARNING
103+
handlers =
104+
qualname = sqlalchemy.engine
105+
106+
[logger_alembic]
107+
level = INFO
108+
handlers =
109+
qualname = alembic
110+
111+
[handler_console]
112+
class = StreamHandler
113+
args = (sys.stderr,)
114+
level = NOTSET
115+
formatter = generic
116+
117+
[formatter_generic]
118+
format = %(levelname)-5.5s [%(name)s] %(message)s
119+
datefmt = %H:%M:%S

compose.yaml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ services:
33
container_name: discordbot
44
image: regunakyle/my-discord-bot:latest
55
environment:
6-
DISCORD_TOKEN: <YOUR_TOKEN_HERE>
6+
DISCORD_TOKEN: <Your token here>
77
# Used by old style prefix commands; this bot only has the <PREFIX>sync prefix command
88
PREFIX: ">>"
99
# Maximum file upload size (in MiB), used by command like /pixiv
@@ -29,14 +29,21 @@ services:
2929
environment:
3030
SERVER_PORT: 2333
3131
LAVALINK_SERVER_PASSWORD: youshallnotpass
32-
LAVALINK_SERVER_SOURCES_YOUTUBE: false
32+
LAVALINK_SERVER_SOURCES_YOUTUBE: "false"
3333
# See https://github.com/lavalink-devs/youtube-source for the latest version of the plugin
34-
LAVALINK_PLUGINS_0_DEPENDENCY: dev.lavalink.youtube:youtube-plugin:1.3.0
35-
PLUGINS_YOUTUBE_ENABLED: true
34+
LAVALINK_PLUGINS_0_DEPENDENCY: dev.lavalink.youtube:youtube-plugin:1.11.4
35+
PLUGINS_YOUTUBE_ENABLED: "true"
3636
PLUGINS_YOUTUBE_CLIENTS_0: MUSIC
37-
PLUGINS_YOUTUBE_CLIENTS_1: ANDROID
38-
PLUGINS_YOUTUBE_CLIENTS_2: WEB
39-
PLUGINS_YOUTUBE_CLIENTS_3: TVHTML5EMBEDDED
37+
PLUGINS_YOUTUBE_CLIENTS_1: WEB
38+
PLUGINS_YOUTUBE_CLIENTS_2: MWEB
39+
PLUGINS_YOUTUBE_CLIENTS_3: WEBEMBEDDED
40+
PLUGINS_YOUTUBE_CLIENTS_4: ANDROID_MUSIC
41+
PLUGINS_YOUTUBE_CLIENTS_5: ANDROID_VR
42+
PLUGINS_YOUTUBE_CLIENTS_6: TV
43+
PLUGINS_YOUTUBE_CLIENTS_7: TVHTML5EMBEDDED
44+
# See https://github.com/lavalink-devs/youtube-source?tab=readme-ov-file#using-oauth-tokens for more info
45+
PLUGINS_YOUTUBE_OAUTH_ENABLED: "true"
46+
PLUGINS_YOUTUBE_OAUTH_REFRESHTOKEN: <Use your own oauth token here>
4047
restart: unless-stopped
4148

4249
volumes:

migrations/env.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
from logging.config import fileConfig
2+
3+
from alembic import context
4+
from sqlalchemy import engine_from_config, pool
5+
6+
from my_discord_bot.models._model_base import ModelBase
7+
8+
# this is the Alembic Config object, which provides
9+
# access to the values within the .ini file in use.
10+
config = context.config
11+
12+
# Interpret the config file for Python logging.
13+
# This line sets up loggers basically.
14+
if (
15+
config.config_file_name is not None
16+
and "no_alembic_loggers" not in config.attributes
17+
):
18+
fileConfig(config.config_file_name)
19+
20+
# add your model's MetaData object here
21+
# for 'autogenerate' support
22+
# from myapp import mymodel
23+
# target_metadata = mymodel.Base.metadata
24+
target_metadata = [ModelBase.metadata]
25+
26+
# other values from the config, defined by the needs of env.py,
27+
# can be acquired:
28+
# my_important_option = config.get_main_option("my_important_option")
29+
# ... etc.
30+
31+
32+
def run_migrations_offline() -> None:
33+
"""Run migrations in 'offline' mode.
34+
35+
This configures the context with just a URL
36+
and not an Engine, though an Engine is acceptable
37+
here as well. By skipping the Engine creation
38+
we don't even need a DBAPI to be available.
39+
40+
Calls to context.execute() here emit the given string to the
41+
script output.
42+
43+
"""
44+
url = config.get_main_option("sqlalchemy.url")
45+
context.configure(
46+
url=url,
47+
target_metadata=target_metadata,
48+
literal_binds=True,
49+
dialect_opts={"paramstyle": "named"},
50+
)
51+
52+
with context.begin_transaction():
53+
context.run_migrations()
54+
55+
56+
def run_migrations_online() -> None:
57+
"""Run migrations in 'online' mode.
58+
59+
In this scenario we need to create an Engine
60+
and associate a connection with the context.
61+
62+
"""
63+
connectable = engine_from_config(
64+
config.get_section(config.config_ini_section, {}),
65+
prefix="sqlalchemy.",
66+
poolclass=pool.NullPool,
67+
)
68+
69+
with connectable.connect() as connection:
70+
context.configure(connection=connection, target_metadata=target_metadata)
71+
72+
with context.begin_transaction():
73+
context.run_migrations()
74+
75+
76+
if context.is_offline_mode():
77+
run_migrations_offline()
78+
else:
79+
run_migrations_online()

migrations/script.py.mako

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""${message}
2+
3+
Revision ID: ${up_revision}
4+
Revises: ${down_revision | comma,n}
5+
Create Date: ${create_date}
6+
7+
"""
8+
from typing import Sequence, Union
9+
10+
from alembic import op
11+
import sqlalchemy as sa
12+
${imports if imports else ""}
13+
14+
# revision identifiers, used by Alembic.
15+
revision: str = ${repr(up_revision)}
16+
down_revision: Union[str, None] = ${repr(down_revision)}
17+
branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
18+
depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
19+
20+
21+
def upgrade() -> None:
22+
${upgrades if upgrades else "pass"}
23+
24+
25+
def downgrade() -> None:
26+
${downgrades if downgrades else "pass"}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
"""First migration
2+
3+
Revision ID: a29aedea6bce
4+
Revises:
5+
Create Date: 2025-02-02 22:16:04.229508
6+
7+
"""
8+
9+
from typing import Sequence, Union
10+
11+
import sqlalchemy as sa
12+
from alembic import op
13+
14+
# revision identifiers, used by Alembic.
15+
revision: str = "a29aedea6bce"
16+
down_revision: Union[str, None] = None
17+
branch_labels: Union[str, Sequence[str], None] = None
18+
depends_on: Union[str, Sequence[str], None] = None
19+
20+
21+
def upgrade() -> None:
22+
# ### commands auto generated by Alembic - please adjust! ###
23+
op.create_table(
24+
"guild",
25+
sa.Column(
26+
"id",
27+
sa.Integer(),
28+
sa.Identity(always=True, start=1, increment=1),
29+
nullable=False,
30+
),
31+
sa.Column("guild_id", sa.Integer(), nullable=False),
32+
sa.Column("guild_name", sa.String(length=100), nullable=False),
33+
sa.Column("bot_channel", sa.Integer(), nullable=True),
34+
sa.Column("welcome_message", sa.String(length=2000), nullable=True),
35+
sa.PrimaryKeyConstraint("id", name=op.f("pk_guild")),
36+
sa.UniqueConstraint("guild_id", name=op.f("uq_guild_guild_id")),
37+
)
38+
# ### end Alembic commands ###
39+
40+
41+
def downgrade() -> None:
42+
# ### commands auto generated by Alembic - please adjust! ###
43+
op.drop_table("guild")
44+
# ### end Alembic commands ###

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
[project]
22
name = "my-discord-bot"
3-
version = "4.0.0"
3+
version = "4.0.1"
44
description = "Discord Bot by Reguna"
55
readme = "README.md"
66
requires-python = ">=3.11"
77
dependencies = [
88
"aiohttp==3.*",
99
"aiosqlite==0.*",
10+
"alembic==1.*",
1011
"discord-py[voice]==2.*",
1112
"gallery-dl==1.*",
1213
"openai==1.*",

0 commit comments

Comments
 (0)