I
I
ILIIA22892020-11-07 22:01:07
Python
ILIIA2289, 2020-11-07 22:01:07

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


This is how the event "if author.guild.id == line" does not work for me
in the premium.txt file, I have the id of the server on which the user is now and other id servers
, this is how the event does not work

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Maxim Nevzorov, 2020-11-07
@ILIIA2289

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.AJeUSeq.png

S
sswwssww, 2020-11-07
@sswwssww

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.

S
Sergey Karbivnichy, 2020-11-07
@hottabxp

Try it:

with open( "premium.txt", 'r' ) as file:
    for line in file:

replace with this:
with open( "premium.txt", 'r' ) as file:
  lines = file.read().splitlines()
  for line in lines:

But something tells me...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question