async def add_keyword(ctx: commands.Context, args): if not util.user_is_admin(ctx.author.id): return await ctx.send(str(ctx.message.author.mention) + ", you are not authorized.") conn = db_access.create_connection() try: db_access.add_keyword(conn, args) return await ctx.send(str(ctx.message.author.mention) + " added keyword: \"" + args + "\".") except sqlite3.IntegrityError: return await ctx.send(str(ctx.message.author.mention) + ", this keyword already exists")
async def delete_response(ctx: commands.Context, args): if not util.user_is_admin(ctx.author.id): return await ctx.send(str(ctx.message.author.mention) + ", you are not authorized.") conn = db_access.create_connection() if db_access.is_response(args): db_access.delete_response(conn, args) return await ctx.send(str(ctx.message.author.mention) + " removed response: \"" + args + "\".") else: return await ctx.send(str(ctx.message.author.mention) + " \"" + args + "\" is not a response*.")
async def add_admin(ctx: commands.Context, args): conn = db_access.create_connection() if not util.user_is_admin(ctx.author.id): return await ctx.send(str(ctx.message.author.mention) + ", you are not authorized.") if len(ctx.message.mentions) < 1: return await ctx.send(str(ctx.message.author.mention) + ", please mention at least one user to promote to admin.") for mention in ctx.message.mentions: try: db_access.add_admin(conn, mention.id) await ctx.send(str(ctx.message.author.mention) + ", user " + mention.mention + " is now an admin.") except sqlite3.IntegrityError: return await ctx.send(str(ctx.message.author.mention) + ", user " + mention.mention + " is already an admin.")
async def remove_admin(ctx: commands.Context, args): conn = db_access.create_connection() if not util.user_is_admin(ctx.author.id): return await ctx.send(str(ctx.message.author.mention) + ", you are not authorized.") if len(ctx.message.mentions) < 1: return await ctx.send(str(ctx.message.author.mention) + ", please mention at least one user to demote from admin.") for mention in ctx.message.mentions: if not db_access.is_admin(conn, mention.id): return await ctx.send(str(ctx.message.author.mention) + ", user " + mention.mention + " isn't an admin.") try: db_access.delete_admin(conn, mention.id) await ctx.send(str(ctx.message.author.mention) + ", user " + mention.mention + " is no longer an admin.") except sqlite3.IntegrityError: return await ctx.send(str(ctx.message.author.mention) + ", user " + mention.mention + " isn't an admin.")