Answer the question
In order to leave comments, you need to log in
Condition not working in discord.py?
@client.command( pass_context=True )
async def test(ctx):
#head
author = ctx.message.author
#body
with open( "premium.txt", 'r' ) as file:
for line in file:
await ctx.send(line)#проверял что line содержит строку.
if author.guild.id == line:#тут сама проблема
await ctx.send("Done")
else:
await ctx.send("Error")#всегда error
Answer the question
In order to leave comments, you need to log in
We open the discord.py documentation and see that:
1. pass_context does not exist on the current version of the library
2. The Guild.id attribute is of type int
. You are comparing it with the type str
.
Yes, everyone has it now. Called those. Python support, they said they were aware that their if expression stopped working, they promised to fix it soon.
Try it:
with open( "premium.txt", 'r' ) as file:
for line in file:
with open( "premium.txt", 'r' ) as file:
lines = file.read().splitlines()
for line in lines:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question