@client.command(aliases=["logchannel, setlog"])
@commands.has_permissions(manage_messages=True)
async def log(ctx, *args: discord.TextChannel):
with open("configs/channels.json", "r") as f:
channels = json.load(f)
channel = channels.get(str(ctx.guild.id), ctx.channel.id)
if len(args) == 0:
await ctx.send("Which channel should I set the logs? :thinking:")
elif args[0] != discord.TextChannel:
await ctx.send("That is not a valid channel!")
elif args[0] == discord.TextChannel:
with open("configs/channels.json", "w") as f:
json.dump(channels, f, indent=4)
embed = discord.Embed(title="Log channel set! :white_check_mark:",
description=f"**{channel}** has been set as logs channel!",
color=0x2f3136)
await ctx.send(embed=embed)
所以我的这部分代码是为使用 JSON 设置日志通道而制作的。json 部分工作正常,因为我在其他几个命令中使用过它。但它看不到是否提供了有效的频道。据我所知,它应该是,discord.TextChannel但事实并非如此。该if len(args) == 0部分有效,但其他部分无效。我怎样才能使这项工作?我应该放什么而不是discord.TextChannel?
有只小跳蛙
GCT1015
慕标5832272
相关分类