我创建了一个warn命令,但是我想创建一个命令,玩家可以检查自己的警告或其他人的警告,我不在乎我必须使用什么(json,logging等)
warn命令有点长,所以我只显示了imports和命令本身:
import discord
from discord.ext import commands
from discord.ext.commands import has_permissions, MissingPermissions
from discord.utils import get
@client.command()
@has_permissions(kick_members=True)
async def warn(ctx, member:discord.Member, *, reason=None):
arg=reason
author=ctx.author
guild=ctx.message.guild
overwritee = discord.PermissionOverwrite()
overwrite = discord.PermissionOverwrite()
channel = get(guild.text_channels, name='warn-logs')
mrole = get(ctx.guild.roles, name="Multi-Galaxy")
if channel is None:
channel = await guild.create_text_channel('warn-logs', category=category)
overwritee.read_messages = False
overwritee.read_message_history = False
overwritee.send_messages = False
overwrite.read_messages = True
overwrite.read_message_history = True
overwrite.send_messages = True
await channel.set_permissions(guild.default_role, overwrite=overwritee)
await channel.set_permissions(mrole, overwrite=overwrite)
if member is None:
await ctx.send("Please specify a user and/or reason!")
await channel.send(f'{member.mention} got warned for: ```\n{arg}\n``` Warned by: {author.mention}')
await member.send(f'You got warned for: ```\n{arg}\n``` Warned by: {author} Warned on: **{guild.name}**')
await ctx.send(f'{member.mention} got warned for: ```\n{arg}\n``` Warned by: {author.mention}')
await ctx.message.delete()