Refactored /g into /chat and /gpt-chat into /converse Both have the grouping "gpt" so the full is /gpt chat, and /gpt converse Added pycord-multicog to the project for easier slash grouping across cogs Made the role check case insensitive and added some comments to the sample.env Removed the rest of the discord.ext imports, it's not really used, ymmv Removed another admin check i had missed in local-size
parent
583b766264
commit
e5eeb035c1
@ -1,22 +1,50 @@
|
||||
import discord
|
||||
|
||||
from models.env_service_model import EnvService
|
||||
from typing import Callable
|
||||
|
||||
|
||||
ALLOWED_ROLES = EnvService.get_allowed_roles()
|
||||
ADMIN_ROLES = EnvService.get_admin_roles()
|
||||
DALLE_ROLES = EnvService.get_dalle_roles()
|
||||
GPT_ROLES = EnvService.get_gpt_roles()
|
||||
ALLOWED_GUILDS = EnvService.get_allowed_guilds()
|
||||
|
||||
|
||||
class Check:
|
||||
def check_valid_roles() -> Callable:
|
||||
def check_admin_roles() -> Callable:
|
||||
async def inner(ctx: discord.ApplicationContext):
|
||||
if not any(role.name in ALLOWED_ROLES for role in ctx.user.roles):
|
||||
if not any(role.name.lower() in ADMIN_ROLES for role in ctx.user.roles):
|
||||
await ctx.defer(ephemeral=True)
|
||||
await ctx.respond(
|
||||
"You don't have permission to use this.",
|
||||
"You don't have admin permission to use this.",
|
||||
ephemeral=True,
|
||||
delete_after=10,
|
||||
)
|
||||
return False
|
||||
return True
|
||||
return inner
|
||||
|
||||
def check_dalle_roles() -> Callable:
|
||||
async def inner(ctx: discord.ApplicationContext):
|
||||
if not any(role.name.lower() in DALLE_ROLES for role in ctx.user.roles):
|
||||
await ctx.defer(ephemeral=True)
|
||||
await ctx.respond(
|
||||
"You don't have dalle permission to use this.",
|
||||
ephemeral=True,
|
||||
delete_after=10,
|
||||
)
|
||||
return False
|
||||
return True
|
||||
return inner
|
||||
|
||||
def check_gpt_roles() -> Callable:
|
||||
async def inner(ctx: discord.ApplicationContext):
|
||||
if not any(role.name.lower() in GPT_ROLES for role in ctx.user.roles):
|
||||
await ctx.defer(ephemeral=True)
|
||||
await ctx.respond(
|
||||
"You don't have gpt permission to use this.",
|
||||
ephemeral=True,
|
||||
delete_after=10,
|
||||
)
|
||||
return False
|
||||
return True
|
||||
return inner
|
@ -1,6 +1,10 @@
|
||||
OPENAI_TOKEN="<openai_api_token>"
|
||||
DISCORD_TOKEN="<discord_bot_token>"
|
||||
DEBUG_GUILD="755420092027633774"
|
||||
DEBUG_CHANNEL="907974109084942396"
|
||||
ALLOWED_GUILDS="971268468148166697,971268468148166697"
|
||||
ALLOWED_ROLES="Admin,gpt"
|
||||
DEBUG_GUILD="<debug_guild_id>"
|
||||
DEBUG_CHANNEL="<debug_channel_id>"
|
||||
# make sure not to include an id the bot doesn't have access to
|
||||
ALLOWED_GUILDS="<guild_id>,<guild_id>"
|
||||
# no spaces, case insensitive
|
||||
ADMIN_ROLES="admin,owner"
|
||||
DALLE_ROLES="admin,openai,dalle"
|
||||
GPT_ROLES="admin,openai,gpt"
|
Loading…
Reference in new issue