Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
179 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 Reply

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...