def setrole(self, id: int, key: str, value: str): guild = self.getguild(id=id) if guild: g = guild['roles'] if key not in g.keys(): return False g[key] = d(value) guild['roles'] = g return self.r.set(id, d(guild))
def setchannel(self, id: int, key: str, v1: str, v2: str): guild = self.getguild(id=id) if guild: g = guild['channels'] if key not in g.keys(): return False g = g[key] g[v1] = d(v2) guild['channels'][key] = g return self.r.set(id, d(guild))
def __init__(self): self.r = redis.Redis(host=e("host"), port=17489, password=e("pwd")) none = d(None) self.guild = { "prefix": none, "channels": { "welcome": { "channel": none, "message": none, "information": none }, "leave": { "channel": none, "message": none }, "logs": { "channel": none, "delete": none, "edit": none, "role": none, "invite": none }, "testing": { "channel": none } }, "roles": { "self": none, "member": none, "mod": none, "muted": none, "dev": none }, "verify": { "channel": none, "message": none, "role": none }, "filters": { "swear": none, "spam": none, "invite": none } }
# Чому наступний код падає з помилкою? from pickle import dumps as d d([])
def addguild(self, id: int): return self.r.set(id, d(self.guild))
def setprefix(self, id: int, new_prefix: str): guild = self.getguild(id=id) if guild and new_prefix: guild['prefix'] = d(new_prefix) return self.r.set(id, d(guild))
def dump(obj, file, protocol=2): _flush_traits(obj) from pickle import dump as d return d(obj, file, protocol)