server = ctx.message.server
msg = ""
if server.id not in self.slowed_db:
await self.bot.say(error("There isn't anyone in Slow Mode in this server."))
return
names = [server.get_member(x).name for x in self.slowed_db[server.id]]
names_len = len(max(names, key=len))
for key, value in self.slowed_db[server.id].items():
try:
member = server.get_member(key)
msg += "{:<{names_len}} {}\n".format(member, value['seconds'], names_len=names_len)
except AttributeError: # User isn't in server
continue
if msg:
await self.bot.say(box(msg, lang="css"))
else:
await self.bot.say(error("There isn't anyone in Slow Mode in this server."))
return
谁能解释为什么这行不通?错误在此行上:
msg += "{:<{names_len}} {}\n".format(member, value['seconds'], names_len=names_len)
names_len
可以很好地打印为整数,所以我很困惑。
答案 0 :(得分:0)
我认为您想在此处传递member.name
,而不是member
本身。