代码:
def get_channels(client, guild):
with open('channels.json','r') as f:
channelss = json.load(f)
return channelss[str(guild.id)]
@client.event
async def on_ready():
print("testing...")
@client.command()
async def setreportchannel(ctx, channels: discord.TextChannel):
with open('channels.json','r') as f:
channel = json.load(f)
channel[str(ctx.guild.id)] = int(channels.id)
with open('channels.json','w') as f:
json.dump(channel,f,indent=4)
await ctx.send(f"set the report channel to {channels}")
@client.command()
async def report(ctx, member:discord.Member, *, reason):
channel = client.get_channel(get_channels)
await ctx.channel.send(f"{member} has been reported for: {reason}")
json文件:{“850356901232771082”:8503578338816}
问题:它没有在json文件中存储的内容上发送正确的通道,它假设位于用户使用命令setreportchannel设置通道的位置
1条答案
按热度按时间mdfafbf11#
所以有人找到了它并帮助我(不是勺子)。。。问题是我在频道日志中所做的部分,我将频道id而不是公会id放在其中