Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
186 views
in Technique[技术] by (71.8m points)

python 3.x - Why does it show me a sum of 0?

I just wrote a discord bot and used a function to show me the members of each guild the bot is in. That worked all the time but now i wanted to use a other server so i copied my files and dragged them on the other server. But for some reason now it says the sum of all the member = 0. Can someone help me?

Thx in advance ^^

async def member():
    while True:
        for guild in my_guild_id: # list of guild id's
            guild = bot.get_guild(guild)
            member = sum(discord.member and not member.bot for member in guild.members)
            for channel in members_channel_id: # list of channel id's
                check = str(guild.get_channel(channel)).encode('ascii', 'ignore') 
                if check != none:               # none = b'None' cause there were some bugs
                    channel = bot.get_channel(channel)
                    await channel.edit(name=f"??Servermember: {Member}")
        await asyncio.sleep(20)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Your function has the same name as a variable in the function, you should be using a different name for it.

Also, none takes a capitalized N: None.

Finally, you're using the variable Member when editing the channel, but this variable isn't defined, python is case-sensitive.

I don't think you just "copied and dragged" your files, and that couldn't work on another server...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...