rename TOKEN env var to BOT_TOKEN

This commit is contained in:
Alex Ott
2022-12-31 03:52:09 -08:00
parent a7b7487611
commit 8067dc8f78
4 changed files with 15 additions and 3 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
TOKEN=<discord bot token>
BOT_TOKEN=<discord bot token>
DECLARE_GLOBAL_COMMANDS=<testing guild id>
OWNER_IDS=[<your user id>, <other user ids>]
PREFIX="./"
+2 -1
View File
@@ -9,8 +9,9 @@ from bot.settings import Settings
settings = Settings()
# TODO: Revisit cache settings
bot = lightbulb.BotApp(
token=settings.token,
token=settings.bot_token,
logs="DEBUG",
prefix=settings.prefix,
default_enabled_guilds=settings.declare_global_commands,
@@ -5,6 +5,7 @@ import lightbulb
from aiosqlite import Connection
from bot.db.schemas import GuildSettings
from bot.utils import mention
from lightbulb.utils.permissions import permissions_in
from loguru import logger
plugin = lightbulb.Plugin("GuildSettings")
@@ -62,6 +63,16 @@ async def log_channel(ctx: lightbulb.SlashContext) -> None:
channel: hikari.TextableGuildChannel = ctx.options.channel
conn: Connection = ctx.bot.d.db
assert ctx.guild_id is not None # `guild_only` check
assert isinstance(channel, hikari.PermissibleGuildChannel)
# Check if the bot can send messages in that channel
assert (me := ctx.bot.get_me()) is not None # non-None after `StartedEvent`
if (own_member := ctx.bot.cache.get_member(ctx.guild_id, me.id)) is None:
own_member = await ctx.bot.rest.fetch_member(ctx.guild_id, me.id)
perms = permissions_in(channel, own_member)
if perms & ~hikari.Permissions.SEND_MESSAGES:
await ctx.respond("I don't have permission to send messages in that channel.")
return
await ctx.respond(f"Setting `log_channel` to {channel.mention}.")
+1 -1
View File
@@ -6,7 +6,7 @@ from pydantic import BaseSettings, Field
class Settings(BaseSettings):
"""Settings for the bot."""
token: str = Field(env="TOKEN", default="")
bot_token: str = Field(env="BOT_TOKEN", default="")
declare_global_commands: int = Field(env="DECLARE_GLOBAL_COMMANDS", default=0)
owner_ids: list[int] = Field(env="OWNER_IDS", default_factory=list)
prefix: str = Field(env="PREFIX", default="./")