Answer the question
In order to leave comments, you need to log in
Why can't I get server members?
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)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question