0

So, I am working on a private discord bot with kinda like an onlinestreak. And for that i need to get all members. Im tying to use fetch_members and for that i have to have the members intent. But trying to set it literaly anywhere, in the on_ready, the init and i even tried to modify the library for that, but nothing worked.

import discord
from discord.ext import commands, tasks
from dataclasses import dataclass

class MyClient(discord.Client):
    async def on_ready(self):
        self.intents = discord.Intents().all()

        print('Logged on as {self.user}!')

        self.userlist = []
        print((self.get_guild("id")).fetch_members())

client = MyClient()
client.intents = discord.Intents().all()
client.run("token")

The error message always says

Ignoring exception in on_ready
Traceback (most recent call last):
    File "C:\Users\woelf\AppData\Local\Programs\Python\Python39\lib\site- 
packages\discord\client.py", line 344, in _run_event    
    await coro(*args, **kwargs)
File "main.py", line 25, in on_ready 
self.intents = discord.Intents().all()
AttributeError: can't set attribute

Any one got an idea how to fix this?

nomedia
  • 25
  • 5
  • the members intent is a privileged intent. If you are part of less than 100 servers and not verified, you can enable them in the Discord Developer Portal, otherwise you need approval from Discord. – Esther Mar 23 '22 at 20:05
  • also, intents.all() enables *all* intents, you probably want defaults + members, see here https://stackoverflow.com/questions/64831017/how-do-i-get-the-discord-py-intents-to-work – Esther Mar 23 '22 at 20:09
  • Well thank you.. That help a lot after 3 hours of sreaming at my pc. – nomedia Mar 23 '22 at 20:09
  • 1
    also, you want discord.Intents.defaults() (no () after Intents I believe) – Esther Mar 23 '22 at 20:10
  • I deceided to use all intents bc its only a server from me and my friends so it doesnt matter anyways but thank you. – nomedia Mar 23 '22 at 20:11

0 Answers0