miscellaneous fixes

This commit is contained in:
osmarks 2021-05-30 20:11:01 +01:00
parent 134a6e6e31
commit c1b5007d33
4 changed files with 7 additions and 3 deletions

View File

@ -22,7 +22,8 @@ achievements = {
}
async def achieve(bot: commands.Bot, message: discord.Message, achievement):
guild_conf = await bot.database.execute_fetchone("SELECT achievement_messages FROM guild_config WHERE id = ?", (message.guild.id,))
if message.guild:
guild_conf = await bot.database.execute_fetchone("SELECT achievement_messages FROM guild_config WHERE id = ?", (message.guild.id,))
if guild_conf and guild_conf["achievement_messages"] == 0: return
channel = message.channel

View File

@ -11,7 +11,7 @@ role_transfer_lock = asyncio.Lock()
def setup(bot):
@bot.listen()
async def on_message(message):
if message.guild.id == util.config["esoserver"]["id"]:
if message.guild and message.guild.id == util.config["esoserver"]["id"]:
async with role_transfer_lock: # prevent concurrency horrors - serialize accesses, probably
for role in message.role_mentions:
if role.id == util.config["esoserver"]["transfer_role"]: # transfer the role from sender to other pinged person

View File

@ -42,11 +42,14 @@ def setup(bot):
async def send_by_dm(info, text):
user = bot.get_user(info["author_id"])
if not user:
user = await bot.fetch_user(info["author_id"])
if not user: raise Exception(f"user {info['author_id']} unavailable/nonexistent")
if not user.dm_channel: await user.create_dm()
await user.dm_channel.send(text)
async def send_to_guild(info, text):
if not "guild_id" in info: raise Exception("Guild unknown")
guild = bot.get_guild(info["guild_id"])
member = guild.get_member(info["author_id"])
self = guild.get_member(bot.user.id)

View File

@ -21,7 +21,7 @@ def setup(bot):
@userdata.command(name="list", brief="List userdata keys in a given scope matching a query.")
async def list_cmd(ctx, query="%", scope="guild", show_values: bool = False):
"Lsit userdata keys in a given scope (guild/global) matching your query (LIKE syntax). Can also show the associated values."
"List userdata keys in a given scope (guild/global) matching your query (LIKE syntax). Can also show the associated values."
if scope == "global":
rows = await bot.database.execute_fetchall("SELECT * FROM user_data WHERE user_id = ? AND guild_id = '_global' AND key LIKE ?", (ctx.author.id, query))
else: