Дискорд бот должен получить весь список пользователей и внести в базу данных(Mongo.db), но он вносит только себя.
Хотя видит и остальных.
Intents включены
Исходный код:
intents = discord.Intents.all()
Intents.members = True
bot = commands.Bot(command_prefix= '-', intents = intents)
@bot.event
async def on_ready():
for guild in bot.guilds:
for member in guild.members:
print(member)
post = {
"_id": member.id,
"balance": 0,
"xp": 0,
"lvl": 0
}
print(collection)
if collection.find({"_id": member.id}) == None:
collection.insert_one(post)
print('пользователь занесен в таблицу')
Консоль
me.wizzy#1111
Collection(Database(MongoClient(host=['cluster0-shard-00-02.sbgr7.mongodb.net:27017', 'cluster0-shard-00-01.sbgr7.mongodb.net:27017', 'cluster0-shard-00-00.sbgr7.mongodb.net:27017'], document_class=dict, tz_aware=False, connect=True, retrywrites=True, w='majority', authsource='admin', replicaset='atlas-kvlg4c-shard-0', ssl=True), 'bot'), 'keta')
Server Monitoring#8312
Collection(Database(MongoClient(host=['cluster0-shard-00-02.sbgr7.mongodb.net:27017', 'cluster0-shard-00-01.sbgr7.mongodb.net:27017', 'cluster0-shard-00-00.sbgr7.mongodb.net:27017'], document_class=dict, tz_aware=False, connect=True, retrywrites=True, w='majority', authsource='admin', replicaset='atlas-kvlg4c-shard-0', ssl=True), 'bot'), 'keta')
ToNi#2025
Collection(Database(MongoClient(host=['cluster0-shard-00-02.sbgr7.mongodb.net:27017', 'cluster0-shard-00-01.sbgr7.mongodb.net:27017', 'cluster0-shard-00-00.sbgr7.mongodb.net:27017'], document_class=dict, tz_aware=False, connect=True, retrywrites=True, w='majority', authsource='admin', replicaset='atlas-kvlg4c-shard-0', ssl=True), 'bot'), 'keta')
! #0001
Collection(Database(MongoClient(host=['cluster0-shard-00-02.sbgr7.mongodb.net:27017', 'cluster0-shard-00-01.sbgr7.mongodb.net:27017', 'cluster0-shard-00-00.sbgr7.mongodb.net:27017'], document_class=dict, tz_aware=False, connect=True, retrywrites=True, w='majority', authsource='admin', replicaset='atlas-kvlg4c-shard-0', ssl=True), <bot'), 'keta')
HaGle#2222
Collection(Database(MongoClient(host=['cluster0-shard-00-02.sbgr7.mongodb.net:27017', 'cluster0-shard-00-01.sbgr7.mongodb.net:27017', 'cluster0-shard-00-00.sbgr7.mongodb.net:27017'], document_class=dict, tz_aware=False, connect=True, retrywrites=True, w='majority', authsource='admin', replicaset='atlas-kvlg4c-shard-0', ssl=True), <b>'bot'), 'keta')</b>
Seba#5041
Collection(Database(MongoClient(host=['cluster0-shard-00-02.sbgr7.mongodb.net:27017', 'cluster0-shard-00-01.sbgr7.mongodb.net:27017', 'cluster0-shard-00-00.sbgr7.mongodb.net:27017'], document_class=dict, tz_aware=False, connect=True, retrywrites=True, w='majority', authsource='admin', replicaset='atlas-kvlg4c-shard-0', ssl=True), bot'), 'keta')
Хагис#4815
Collection(Database(MongoClient(host=['cluster0-shard-00-02.sbgr7.mongodb.net:27017', 'cluster0-shard-00-01.sbgr7.mongodb.net:27017', 'cluster0-shard-00-00.sbgr7.mongodb.net:27017'], document_class=dict, tz_aware=False, connect=True, retrywrites=True, w='majority', authsource='admin', replicaset='atlas-kvlg4c-shard-0', ssl=True), 'bot'), 'keta')