From 0f21810d2ab5727a83206847eb5e91adf423323c Mon Sep 17 00:00:00 2001 From: Johannes Daub Date: Wed, 27 Oct 2021 17:17:56 +0200 Subject: [PATCH 1/2] Add command prefix environment variable --- .env.template | 1 + src/bot.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.env.template b/.env.template index 6613d8c..559a170 100644 --- a/.env.template +++ b/.env.template @@ -1,2 +1,3 @@ DISCORD_BOT_TOKEN= +DISCORD_CMD_PREFIX=! YOUTUBE_COOKIES=youtube.com_cookies.txt \ No newline at end of file diff --git a/src/bot.py b/src/bot.py index c18804a..0f0903e 100644 --- a/src/bot.py +++ b/src/bot.py @@ -152,7 +152,7 @@ class Music(commands.Cog): if __name__ == "__main__": - bot = commands.Bot(command_prefix=commands.when_mentioned_or("!"), description='Relatively simple music bot example') + bot = commands.Bot(command_prefix=commands.when_mentioned_or(os.environ.get("DISCORD_CMD_PREFIX", None)), description='Relatively simple music bot example') @bot.event async def on_ready(): From 74e408fa57540e7d6a5b512a4b9a4178a5d6afbe Mon Sep 17 00:00:00 2001 From: Johannes Daub Date: Wed, 27 Oct 2021 17:30:48 +0200 Subject: [PATCH 2/2] Set default prefix --- .env.template | 2 +- src/bot.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.env.template b/.env.template index 559a170..8b33c29 100644 --- a/.env.template +++ b/.env.template @@ -1,3 +1,3 @@ DISCORD_BOT_TOKEN= -DISCORD_CMD_PREFIX=! +DISCORD_CMD_PREFIX= YOUTUBE_COOKIES=youtube.com_cookies.txt \ No newline at end of file diff --git a/src/bot.py b/src/bot.py index 0f0903e..12d9a40 100644 --- a/src/bot.py +++ b/src/bot.py @@ -152,7 +152,9 @@ class Music(commands.Cog): if __name__ == "__main__": - bot = commands.Bot(command_prefix=commands.when_mentioned_or(os.environ.get("DISCORD_CMD_PREFIX", None)), description='Relatively simple music bot example') + prefix = os.environ.get("DISCORD_CMD_PREFIX", "!") + bot = commands.Bot(command_prefix=commands.when_mentioned_or(prefix), + description='Relatively simple music bot example') @bot.event async def on_ready():