async def restrictuser(context, *args, **kwargs): # need exactly one mentioned user (the order in the mentioned list is unreliable) if len(context["message"].mentions) != 1: return await koduck.sendmessage( context["message"], sendcontent=settings.message_nomentioneduser) userid = context["message"].mentions[0].id userlevel = koduck.getuserlevel(userid) # already restricted if userlevel == 0: return await koduck.sendmessage( context["message"], sendcontent=settings.message_restrict_failed) # don't restrict high level users elif userlevel >= 2: return await koduck.sendmessage( context["message"], sendcontent=settings.message_restrict_failed2.format( settings.botname)) else: koduck.updateuserlevel(userid, 0) return await koduck.sendmessage( context["message"], sendcontent=settings.message_restrict_success.format( userid, settings.botname))
async def unrestrictuser(context, *args, **kwargs): # need exactly one mentioned user (the order in the mentioned list is unreliable) if len(context["message"].mentions) != 1: return await koduck.sendmessage( context["message"], sendcontent=settings.message_nomentioneduser) userid = context["message"].mentions[0].id userlevel = koduck.getuserlevel(userid) if userlevel != 0: return await koduck.sendmessage( context["message"], sendcontent=settings.message_unrestrict_failed) else: koduck.updateuserlevel(userid, 1) return await koduck.sendmessage( context["message"], sendcontent=settings.message_unrestrict_success.format( userid, settings.botname))
async def admin(context, *args, **kwargs): # need exactly one mentioned user (the order in the mentioned list is unreliable) if len(context["message"].mentions) != 1: return await koduck.sendmessage( context["message"], sendcontent=settings.message_nomentioneduser) userid = context["message"].mentions[0].id userlevel = koduck.getuserlevel(userid) # already an admin if userlevel == 2: return await koduck.sendmessage( context["message"], sendcontent=settings.message_addadmin_failed.format( settings.botname)) else: koduck.updateuserlevel(userid, 2) return await koduck.sendmessage( context["message"], sendcontent=settings.message_addadmin_success.format( userid, settings.botname))