import discord
from discord import message
from discord import member
from discord.ext import commands
import json
import os.path
import datetime
import asyncio
import os
_dict = {}
SAVEPATH = 'MuteData.json'
MUTEROLEID = x
GUILDID = x
MODERATIONROLEID = x
TOKEN = 'X'
MUTEROLE = ''
GUILD = ''
MODERATIONROLE = ''
intents = discord.Intents.all()
bot = commands.Bot(command_prefix='+', intents=intents)
@bot.event
async def on_ready():
print('invoked')
global MUTEROLE, GUILD, MODERATIONROLE
GUILD = await bot.fetch_guild(GUILDID)
MUTEROLE = GUILD.get_role(MUTEROLEID)
MODERATIONROLE = GUILD.get_role(MODERATIONROLEID)
bot.loop.create_task(getMuteList())
if (not os.path.exists(SAVEPATH)) or (len(_dict) == 0):
print(GUILD.members)
for member in GUILD.members:
if MUTEROLE in member.roles:
await member.remove_roles(MUTEROLE)
bot.run(TOKEN)
GUILD.members возвращает пустой список
Ещё интересно то, что событие присоединения на сервер срабатывает, хотя оно тоже, насколько я знаю требует intents.