def getUserInfo(array, guild_id):
for user_id in array:
time.sleep(config['sleep'])
user_info = bot.getProfile(str(user_id), guildID = guild_id)
if user_info.status_code == 200:
userInfo = user_info.json()
print('Checkend {}'.format(userInfo['user']['username']))
else:
print(user_info.text)
print('Error:', user_info.status_code)
def close_after_fetching(resp, guild_id):
if bot.gateway.finishedMemberFetching(guild_id):
users = bot.gateway.session.guild(guild_id).members
print('Users count: {} | Guild_ID: {}'.format(len(users), guild_id))
getUserInfo(users, guild_id)
bot.gateway.removeCommand({'function': close_after_fetching, 'params': {'guild_id': guild_id}})
def get_members(guild_id, channel_id):
bot.gateway.fetchMembers(guild_id, channel_id, keep="all", wait=1)
bot.gateway.command({'function': close_after_fetching, 'params': {'guild_id': guild_id}})
return bot.gateway.session.guild(guild_id).members
@bot.gateway.command
def helloworld(resp):
if resp.event.ready_supplemental:
user = bot.gateway.session.user
print("Logged in as {}#{}".format(user['username'], user['discriminator']))
guilds = bot.gateway.session.allGuildIDs
print('Guilds count: {}'.format(len(guilds)))
for guild_id in guilds:
channels = bot.gateway.findVisibleChannels(guild_id)
print('Visible Channels count: {} | Guild_ID: {}'.format(len(channels), guild_id))
get_members(guild_id, channels[0])
time.sleep(config['sleep_channel'])
Почему-то получаю флуд функцией, хотя она должна запускаться один раз
Users count: 305 | Guild_ID: 822975436740362260
Users count: 305 | Guild_ID: 822975436740362260
Users count: 305 | Guild_ID: 822975436740362260
Users count: 305 | Guild_ID: 822975436740362260
Users count: 305 | Guild_ID: 822975436740362260
Users count: 305 | Guild_ID: 822975436740362260
Users count: 305 | Guild_ID: 822975436740362260
Users count: 305 | Guild_ID: 822975436740362260
Users count: 305 | Guild_ID: 822975436740362260
Users count: 305 | Guild_ID: 822975436740362260
Users count: 305 | Guild_ID: 822975436740362260
Users count: 305 | Guild_ID: 822975436740362260
Users count: 305 | Guild_ID: 822975436740362260
Users count: 305 | Guild_ID: 822975436740362260
Users count: 305 | Guild_ID: 822975436740362260
Users count: 305 | Guild_ID: 822975436740362260
Users count: 305 | Guild_ID: 822975436740362260
Users count: 305 | Guild_ID: 822975436740362260Users count: 305 | Guild_ID: 822975436740362260
Users count: 305 | Guild_ID: 822975436740362260
Users count: 305 | Guild_ID: 822975436740362260
Users count: 305 | Guild_ID: 822975436740362260
Users count: 305 | Guild_ID: 822975436740362260
Users count: 305 | Guild_ID: 822975436740362260
Users count: 305 | Guild_ID: 822975436740362260
Users count: 305 | Guild_ID: 822975436740362260
Users count: 305 | Guild_ID: 822975436740362260
Users count: 305 | Guild_ID: 822975436740362260
После получаю ошибку
Traceback (most recent call last):
File "C:\Users\semen\AppData\Local\Programs\Python\Python310\lib\site-packages\discum\gateway\gateway.py", line 303, in _response_loop
function(resp, **params)
File "C:\Users\semen\Desktop\disocrod\index.py", line 58, in close_after_fetching
getUserInfo(users, guild_id)
File "C:\Users\semen\Desktop\disocrod\index.py", line 41, in getUserInfo
if user_info.status_code == 200:
AttributeError: 'NoneType' object has no attribute 'status_code
что делаю не так?