add back server id configuration, but better this time
This commit is contained in:
parent
77c352c7ac
commit
b0b7c643cc
7
bot.py
7
bot.py
@ -13,6 +13,7 @@ import heavynode
|
||||
|
||||
|
||||
DISCORD_TOKEN = lib.getconfig('DISCORD_TOKEN')
|
||||
DISCORD_SERVER_ID = int(lib.getconfig('DISCORD_SERVER_ID', 0))
|
||||
HEAVYNODE_TOKEN = lib.getconfig('HEAVYNODE_TOKEN')
|
||||
COOKIE_NAME = lib.getconfig('HEAVYNODE_COOKIE_NAME')
|
||||
COOKIE_VALUE = lib.getconfig('HEAVYNODE_COOKIE_VALUE')
|
||||
@ -30,7 +31,11 @@ bot.add_cleanup(hn.shutdown)
|
||||
|
||||
async def is_admin(ctx):
|
||||
user = ctx.message.author
|
||||
member = bot.guilds[0].get_member(user.id)
|
||||
if DISCORD_SERVER_ID != 0:
|
||||
guild = discord.utils.get(bot.guilds, id=DISCORD_SERVER_ID)
|
||||
else:
|
||||
guild = bot.guilds[0]
|
||||
member = guild.get_member(user.id)
|
||||
if member is not None:
|
||||
for role in member.roles:
|
||||
if role.name == 'Admin' or role.name == 'Mod':
|
||||
|
5
lib.py
5
lib.py
@ -26,13 +26,14 @@ class MineBot(commands.Bot):
|
||||
await super().close()
|
||||
|
||||
|
||||
def getconfig(key, default=None):
|
||||
nodefault = object()
|
||||
def getconfig(key, default=nodefault):
|
||||
if key in os.environ:
|
||||
return os.environ[key]
|
||||
elif f'{key}_FILE' in os.environ:
|
||||
p = os.environ[f'{key}_FILE']
|
||||
return pathlib.Path(p).read_text()
|
||||
elif default != None:
|
||||
elif default is not nodefault:
|
||||
return default
|
||||
else:
|
||||
raise ConfigError('Missing config:', key)
|
Loading…
x
Reference in New Issue
Block a user