def listwarns(self, ctx, user):
"""List warns for a user. Staff only."""
try:
member = ctx.message.mentions[0]
except IndexError:
await self.bot.say("Please mention a user.")
return
embed = discord.Embed(color=discord.Color.dark_red())
embed.set_author(name="Warns for {}#{}".format(member.display_name, member.discriminator), icon_url=member.avatar_url)
with open("data/warnsv2.json", "r") as f:
warns = json.load(f)
try:
if len(warns[member.id]["warns"]) == 0:
embed.description = "There are none!"
embed.color = discord.Color.green()
else:
for idx, warn in enumerate(warns[member.id]["warns"]):
embed.add_field(name="{}: {}".format(idx + 1, warn["timestamp"]), value="Issuer: {}\nReason: {}".format(warn["issuer_name"], warn["reason"]))
except KeyError: # if the user is not in the file
embed.description = "There are none!"
embed.color = discord.Color.green()
await self.bot.say("", embed=embed)
评论列表
文章目录