mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-06-30 16:40:05 +08:00
rename TOKEN env var to BOT_TOKEN
This commit is contained in:
@@ -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="./"
|
||||
|
||||
@@ -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}.")
|
||||
|
||||
|
||||
@@ -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="./")
|
||||
|
||||
Reference in New Issue
Block a user